<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/predikat_lulus/business/AppPredikatLulus.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/predikat_lulus/business/AppPredikatLulusToSia.class.php';

class ViewInputPredikatLulus extends HtmlResponse {
	
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/predikat_lulus/template');
		$this->SetTemplateFile('input_predikat_lulus.html');
	}
	
	function ProcessRequest() {
		$idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      
		$predikatObj = new AppPredikatLulus();
		$predikatObjToSia = new AppPredikatLulusToSia();
       
      if(!$predikatObjToSia->addConn)
         $return['siaConn']=false;
      else
         $return['siaConn']=true;
		$msg = Messenger::Instance()->Receive(__FILE__);

		$dataPredikat = $predikatObj->GetDataPredikatLulusById($idDec);
    ///print_r($dataPredikat);
		$return['decDataId'] = $idDec;
      $return['pesan']=$msg[0][1];
      $return['data']=$msg[0][0];
		$return['dataPredikat'] = $dataPredikat;
		return $return;
	}

	function ParseTemplate($data = NULL) {
      $siaConn=$data['siaConn'];
      
      if($siaConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
			$this->mrTemplate->AddVar('warning', 'ISI_PESAN_SIA', 'Gagal Menghubungi SI Akademik');
         $url_kembali=Dispatcher::Instance()->GetUrl('predikat_lulus', 'predikatLulus', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI_SIA',$url_kembali );
      }elseif($siaConn==true){
         $this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'YES');
      }
      
		if ($data['pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['pesan']);
		}
		$dataPredikat= $data['dataPredikat'];

		
		if ($_REQUEST['dataId']=='') {
			$url="addPredikatLulus";
			$tambah="Tambah";
		} else {
			$url="updatePredikatLulus";
			$tambah="Ubah";
		}

		$this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
		$this->mrTemplate->AddVar('status_koneksi', 'PREDIKAT_ID', empty($dataPredikat[0]['predikat_id'])?$data['data']['predikat_id']:$dataPredikat[0]['predikat_id']);
      $this->mrTemplate->AddVar('status_koneksi', 'PREDIKAT_NAMA', empty($dataPredikat[0]['predikat_nama'])?$data['data']['predikat_nama_lokal']:$dataPredikat[0]['predikat_nama']);
      $this->mrTemplate->AddVar('status_koneksi', 'PREDIKAT_NAMAASING', empty($dataPredikat[0]['predikat_namaAsing'])?$data['data']['predikat_nama_asing']:$dataPredikat[0]['predikat_namaAsing']);
    

		$this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('predikat_lulus', $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']));
	}
}
?>
