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

class PrintCetakKtm extends HtmlResponse {	
	function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/cetak_ktm/template');
		$this->SetTemplateFile('print_cetak_ktm.html');
	}
	
	
	function TemplateBase() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-print.html');
      $this->SetTemplateFile('layout-common-print.html');
   }
	
	function ProcessRequest() {
      $dokObj=new AppCetakKtm();
      $dokObjSia = new AppMahasiswaSia();
      
      $idMhs = Dispatcher::Instance()->Decrypt($_GET['idMhs']);
      
      $dataCetak = $dokObj->GetDataCetak($idMhs);
      $dataFoto = $dokObjSia->GetFoto($idF);
      //print_r($dataFoto);
      //print_r($dataCetak);
      $return['dataCetak']=$dataCetak;
      $return['dataFoto'] = $dataFoto;
      return $return;
       
   }
    
    function Parsetemplate($data=null){
    
    $photo_path = GTFWConfiguration::GetValue( 'application', 'photo_save_path');
    $dataCetak=$data['dataCetak'];
    $dataFoto=$data['dataFoto'];
    
    if (empty($dataCetak[0]['mhs_foto_lama'])) { 
      $this->mrTemplate->AddVar('data_item', 'MHS_FOTO', $photo_path.'unknown.gif');
      }else{
      $this->mrTemplate->AddVar('data_item', 'MHS_FOTO', $photo_path.$dataCetak[0]['mhs_foto_lama']);
      }
    
       foreach($dataCetak as $dataNim)
       {
         $dataNim['tgl_lahir']=ConvertDate($dataNim['tgl_lahir'],"YYYY-MM-DD","DD-MM-YYYY");
         $dataNim['jenis_kelamin']=empty($dataNim['jenis_kelamin'])?'Tidak diketahui':$dataNim['jenis_kelamin'];
         $nextyear=date("Y")+1;
         $dataNim['next_year_date']=date("d").'&nbsp;'.date("M").'&nbsp;'.$nextyear;
         $this->mrTemplate->AddVars('content', $dataNim, 'KTM_');
         $this->mrTemplate->parseTemplate('content', 'a');
       }
    
    }
}
?>
