<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/penilaian/business/AppPenilaian.class.php';

class ViewImportPenilaian extends HtmlResponse{

	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/penilaian/template');
		$this->SetTemplateFile('import_penilaian.html');
	}

   function ProcessRequest() {
   unset($_SESSION['arrDataMhsFail']);
      $nilaiObj=new AppTaruna();
      
     
      $msg = Messenger::Instance()->Receive(__FILE__);
      $reset= Dispatcher::Instance()->Decrypt($_REQUEST['reset']);
      $dataTahun=$nilaiObj->GetTahun(1990);
      //print($reset);

      $pesan=$msg[0][1];
      $data=$msg[0][0];         
      $countMhsExist=$_SESSION['countMhsExist'];
      $countMhsNotExist=$_SESSION['countMhsNotExist'];
      
      if((!empty($countMhsExist) or !empty($countMhsNotExist))and $reset==''){
        $uploaded=true;
      }else{
        $uploaded=false;
        $_SESSION['countMhsExist']="";
        $_SESSION['countMhsNotExist']="";
        }
      
      $tahunMasukDefault=$nilaiObj->GetTahunPeriodeAktif();
      
      $tahunMasuk=empty($data['tahun_masuk'])?$tahunMasukDefault:$data['tahun_masuk'];
      
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'tahun_masuk',
            array('tahun_masuk',$dataTahun,$tahunMasuk,'false',''), Messenger::CurrentRequest);
      
      $semsMasukDefault=$nilaiObj->GetPeriodeAktif();
      $dataSemester=$nilaiObj->GetSemesterMasuk();
      $semesterMasuk=empty($data['sems_masuk'])?$semsMasukDefault:$data['sems_masuk'];
      
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'mhs_sems_masuk',
         array('sems_masuk',$dataSemester,$semesterMasuk,'false',''), 
         Messenger::CurrentRequest); 
         
      $return['Pesan']=$pesan;
      $return['uploaded']=$uploaded;
      $return['Data']=$data;
      $return['countMhsExist']=$countMhsExist;
      $return['countMhsNotExist']=$countMhsNotExist;
     
		return $return;
	}

   function ParseTemplate($data = NULL) {
      $uploaded=$data['uploaded'];
     
      $url_kembali=Dispatcher::Instance()->GetUrl('penilaian', 'penilaian', 'view', 'html');
      $this->mrTemplate->AddVar('warning', 'URL_KEMBALI',$url_kembali ); 
      
		if ($data['Pesan']) {
         $this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
         $this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['Pesan']);
      }
      

      
      if($uploaded==true){
			   $this->mrTemplate->AddVar('uploaded', 'UPLOADED', 'YES');
      }else{
			   $this->mrTemplate->AddVar('uploaded', 'UPLOADED', 'NO');
      }
      
      if(empty($data['countMhsNotExist'])){
         $data['countMhsNotExist']=0;
      }
      
      if(empty($data['countMhsExist'])){
         $data['countMhsExist']=0;
      }
      
      $this->mrTemplate->AddVar('uploaded','IS_EXIST',$data['countMhsExist']);
      $this->mrTemplate->AddVar('uploaded','IS_NOT_EXIST',$data['countMhsNotExist']);
      $this->mrTemplate->AddVar('uploaded', 'URL_CONTOH_FILE', 'module/penilaian/contoh_file/contoh_file-2.xls');
	}
}
?>
