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

class ViewInputInventarisasiTanah extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/inventarisasi_tanah/template');
      $this->SetTemplateFile('view_input_inventarisasi_tanah.html');
   }

   function ProcessRequest() {
   	$Obj = new InventarisasiTanah();
		
		$msg = Messenger::Instance()->Receive(__FILE__);
      $this->Data = $msg[0][0];
		$this->Pesan = $msg[0][1];
		$this->css = $msg[0][2];
		
		if (is_array($this->Data)){
         $data = $this->Data;
      } elseif(isset($_GET['id'])){
         $result = $Obj->GetInventarisasiTanahById($_GET['id']->Integer()->Raw());
			if ($result == false) unset($_GET['id']);
         else $data = $result;
      }
		
		$peruntukan = $Obj->GetComboPeruntukan();
		Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'peruntukan', array('peruntukan', $peruntukan, $data['peruntukan'], false, ''), Messenger::CurrentRequest);
		
		$penggunaan = $Obj->GetComboStatusPenggunaan();
		Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'penggunaan', array('penggunaan', $penggunaan, $data['penggunaan'], false, 'id="penggunaan"'), Messenger::CurrentRequest);
		
		$result['data'] = $data;
		return $result;
   }

   function ParseTemplate($data = NULL) {
		if ($this->Pesan) {
			$this->mrTemplate->SetAttribute('warning-box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning-box', 'ISI_PESAN', $this->Pesan);
			$this->mrTemplate->AddVar('warning-box', 'CLASS_PESAN', $this->css);
		}

		if($data['data']){
			$this->mrTemplate->addVars('content',$data['data'],'');
		}
		
		if(!empty($_GET['id'])){
			$this->mrTemplate->addVar('content','DISPLAY','none');
		}
			
		$urlAction = Dispatcher::Instance()->GetUrl('inventarisasi_tanah', 'inputInventarisasiTanah', 'do', 'html').'&id='.$_GET['id'];
		$this->mrTemplate->AddVar('content','URL_ACTION', $urlAction);

		$urlList = Dispatcher::Instance()->GetUrl('inventarisasi_tanah', 'inventarisasiTanah', 'view', 'html');
		$this->mrTemplate->AddVar('content','URL_LIST', $urlList);	

		$urlPopup = Dispatcher::Instance()->GetUrl('inventarisasi_tanah','popupInventarisasiTanah','view','html');
		$this->mrTemplate->AddVar('content','URL_POPUP', $urlPopup);	
   }
}
?>
