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

class ViewInputWaktuKuliah extends HtmlResponse {
   
   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot') . 'module/waktu_kuliah/template');
      $this->SetTemplateFile('input_waktu_kuliah.html');
   }
   
   function ProcessRequest() {
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $wktObj= new AppWaktuKuliahToSia();
         
      if(!$wktObj->addConn){
         $return['siaConn']=false;
      }else{
         $return['siaConn']=true;
      }
      
      $msg = Messenger::Instance()->Receive(__FILE__);
      $return['Pesan'] = $msg[0][1];
      $return['Data'] = $msg[0][0];

      $dataWaktuKuliah = $wktObj->GetDataWaktuKuliahById($idDec);

      $return['decDataId'] = $idDec;
      $return['dataWaktuKuliah'] = $dataWaktuKuliah;
      return $return;
   
   }   

   function ParseTemplate($data = NULL) {
      $dataGel=$data['Data'];
      $siaConn = $data['siaConn'];
   //print_r($dataGel);
      if($siaConn==false){
         $this->mrTemplate->AddVar('status_koneksi', 'CONNECTION', 'NO');
         $this->mrTemplate->AddVar('warning', 'ISI_PESAN', 'Gagal menghubungi ke database SI Akademik');
         $url_kembali=Dispatcher::Instance()->GetUrl('waktu_kuliah', 'waktuKuliah', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI', $url_kembali);
      }elseif($siaConn==true){
         $this->mrTemplate->AddVar('status_koneksi', 'CONNECTION', 'YES');
      }
	
      $url_kembali=Dispatcher::Instance()->GetUrl('waktu_kuliah', 'waktuKuliah', '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']);
      }
      $dataWaktuKuliah = $data['dataWaktuKuliah'];
      
      if ($_REQUEST['dataId']=='') {
         $url="addWaktuKuliah";
         $tambah="Tambah";
      } else {
         $url="updateWaktuKuliah";
         $tambah="Ubah";
      }
      $this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('status_koneksi', 'WKT_NAMA', empty($dataWaktuKuliah[0]['NAMA'])?$dataWaktuKuliah['NAMA']:$dataWaktuKuliah[0]['NAMA']);
      $this->mrTemplate->AddVar('status_koneksi', 'WKT_KETERANGAN', empty($dataWaktuKuliah[0]['KETERANGAN'])?$dataWaktuKuliah['KETERANGAN']:$dataWaktuKuliah[0]['KETERANGAN']);
      $this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('waktu_kuliah', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
      $this->mrTemplate->AddVar('status_koneksi', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
      $this->mrTemplate->AddVar('status_koneksi', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
   }
}
?>
