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

class ViewInputJenisPenggunaanRuang extends HtmlResponse {
	
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot')  . 'module/jenis_penggunaan_ruang/template');
		$this->SetTemplateFile('input_jenis_penggunaan_ruang.html');
	}
	
	function ProcessRequest() {
		$jenisObj = new JenisPenggunaanRuang();
		$idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
		$dataJenis = $jenisObj->GetDataPeriodeById($idDec);
		

		$idStt = $dataJenis['0']['jenis_id'];
							
		@$msg = Messenger::Instance()->Receive(__FILE__);
		@$return['Pesan'] = $msg[0][1];
		@$return['Data'] = $msg[0][0];

		$dataJenis = $jenisObj->GetDataJenisById($idDec);

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

	function ParseTemplate($data = NULL) {
		if ($data['Pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['Pesan']);
		}
		$dataJenis = $data['dataJenis'];
		
		if ($_REQUEST['dataId']=='') {
			$url="addJenisPenggunaanRuang";
			$tambah="Tambah";
		} else {
			$url="updateJenisPenggunaanRuang";
			$tambah="Ubah";
		}
		
		@$cek=$dataJenis[0]['jenis_status'];
		//print_r($cek);
		
		if ($cek=="Y"){$checked='checked';}else
		if	($cek=="T"){$checked='';}

		
		$this->mrTemplate->AddVar('content', 'JUDUL', $tambah);

		@$this->mrTemplate->AddVar('content', 'JENIS_STATUS', $checked);
		$this->mrTemplate->AddVar('content', 'JENIS_KODE', empty($data['dataJenis'][0]['jenis_kode'])?$data['Data']['jenis_kode']:$data['dataJenis'][0]['jenis_kode']);
		$this->mrTemplate->AddVar('content', 'JENIS_NAMA', empty($data['dataJenis'][0]['jenis_nama'])?$data['Data']['jenis_nama']:$data['dataJenis'][0]['jenis_nama']);
		//$this->mrTemplate->AddVar('content', 'JENIS_STATUS', empty($data['dataJenis'][0]['jenis_status'])?$data['Data']['jenis_status']:$data['dataJenis'][0]['jenis_status']);
		
		$this->mrTemplate->AddVar('content', 'URL_ACTION', Dispatcher::Instance()->GetUrl('jenis_penggunaan_ruang', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));

		$this->mrTemplate->AddVar('content', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('content', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
	}
}
?>
