<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/mahasiswa/business/AppMahasiswa.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') .'main/function/date.php';

class PrintHasilImportMahasiswa extends HtmlResponse{
   function TemplateModule() {
      $this->SetTemplateBasedir($this->mrConfig->mApplication['docroot'].'module/mahasiswa/template');
      $this->SetTemplateFile('print_hasil_import_mahasiswa.html');
   }
   
   function TemplateBase() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-print.html');
      $this->SetTemplateFile('layout-common-print.html');
   }
  
   function ProcessRequest(){
      $view=Dispatcher::Instance()->Decrypt($_GET['view']);

      if($view=="exist"){
         $arrData=$_SESSION['arrDataMhsExist'];
      }elseif($view=="not_exist"){
         $arrData=$_SESSION['arrDataMhsNotExist'];
      }else{
         $arrData=$_SESSION['arrDataMhsFail'];
      }
      //print_r($_SESSION['arrDataMhsFail']);
     // array_count_values($dataMhs)
      for ($i=0; $i<sizeof($arrData); $i++){
         for($j=0;$j<sizeof($arrData[$i]); $j++)
         {
            $dataMhs[$i]['mhs_'.$j]=$arrData[$i][$j];
         }
      }
      //print_r($dataMhs);
      $return ['dataDaftarMhs']=$dataMhs;
      return $return;
   }
   
   function ParseTemplate($data=NULL){
         $dataDaftarMhs=$data['dataDaftarMhs'];
     // print_r($dataDaftarMhs);
         
         if(empty($dataDaftarMhs)){
      	$this->mrTemplate->AddVar('data','DATA_EMPTY','YES');
      	return;
		}else
			$this->mrTemplate->AddVar('data','DATA_EMPTY','NO');
         $no=1;
        for ($i=0; $i<sizeof($dataDaftarMhs); $i++){
            $dataDaftarMhs[$i]['no'] = $no+$i;
            $dataDaftarMhs[$i]['tgl_lahir']=ConvertDate($dataDaftarMhs[$i]['mhs_tgl_lahir'],"YYYY-MM-DD","DD-MM-YYYY");
            $dataDaftarMhs[$i]['mhs_tempat_tgl_lahir']=$dataDaftarMhs[$i]['mhs_tempat_lahir'].', '.$dataDaftarMhs[$i]['tgl_lahir'];
            $this->mrTemplate->AddVars('data_item',$dataDaftarMhs[$i],'MHS_');
				$this->mrTemplate->parseTemplate('data_item','a');
         }
   }
}
?>