<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_terdaftar/business/AppStatusTerdaftar.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_terdaftar/business/AppStatusTerdaftarToSia.class.php';

class ViewInputStatusTerdaftar extends HtmlResponse {
	
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_terdaftar/template');
		$this->SetTemplateFile('input_status_terdaftar.html');
	}
	
	function ProcessRequest() {
		$msg = Messenger::Instance()->Receive(__FILE__);
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
		
      $statusTerdaftarObj = new AppStatusTerdaftar();
		$siaObj = new AppStatusTerdaftarToSia();
		
		if(!$siaObj->addConn)
		   $return['siaConn']=false;
      else
         $return['siaConn']=true;

		$dataStatusTerdaftar = $statusTerdaftarObj->GetDataStatusTerdaftarById($idDec);
      
      $return['Pesan'] = $msg[0][1];
		$return['css'] = $msg[0][2];
		
		$return['decDataId'] = $idDec;
		$return['dataStatusTerdaftar'] = $dataStatusTerdaftar;
		$return['start'] = $startRec+1;
		return $return;
	}

	function ParseTemplate($data = NULL) {
		$dataStatusTerdaftar = $data['dataStatusTerdaftar'];
		$siaConn = $data['siaConn'];
      
      if($siaConn==false){
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'NO');
         $this->mrTemplate->AddVar('warning', 'ISI_PESAN', 'Gagal menghubungi ke database SI Akademik');
         $url_kembali=Dispatcher::Instance()->GetUrl('status_terdaftar', 'statusTerdaftar', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI', $url_kembali);
      }elseif($siaConn==true){
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'YES');
      }
      
      if ($data['Pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['Pesan']);
		}
		
		if ($_REQUEST['dataId']=='') {
			$url="addStatusTerdaftar";
			$tambah="Tambah";
		} else {
			$url="updateStatusTerdaftar";
			$tambah="Ubah";
		}
		$this->mrTemplate->AddVar('connection', 'JUDUL', $tambah);
		$this->mrTemplate->AddVar('connection', 'STATUS_TERDAFTAR_NAMA', empty($dataStatusTerdaftar[0]['status_terdaftar_nama'])?$data['data']['status_terdaftar_nama']:$dataStatusTerdaftar[0]['status_terdaftar_nama']);
		$this->mrTemplate->AddVar('connection', 'URL_ACTION', Dispatcher::Instance()->GetUrl('status_terdaftar', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
		$this->mrTemplate->AddVar('connection', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('connection', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
	}
}
?>