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

class ViewInputBiayaSewaRuang extends HtmlResponse 
{
	function TemplateModule() 
	{
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/biaya_sewa_ruang/template');
      $this->SetTemplateFile('view_input_biaya_sewa_ruang.html');
   }
	
   function ProcessRequest() 
	{
      $obj = new BiayaSewa;
		
		$msg = Messenger::Instance()->Receive(__FILE__);
		$this->Data = $msg[0][0];
		$this->Pesan = $msg[0][1];
		$this->css = $msg[0][2];
		
		$id = $_GET['id']->Integer()->Raw();
      $result = $obj->GetDataBiayaSewaRuangById($id);
		
		$data = array();
		if(is_array($this->Data))
		{
			$data = $this->Data;
		} 
			elseif(isset($_GET['id']))
		{
         $data = $result;
      } else {
			$data['biaya_sewa_kode'] = 'SWRW.'.date('YmdHis');
		}

		$return['data'] = $data;
      return $return;
   }

   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', 'NOTEBOX', $this->css);
		}
		
		$urlRuang = Dispatcher::Instance()->GetUrl('biaya_sewa_ruang', 'ruangSewa', 'popup', 'html');
		$this->mrTemplate->AddVar('content', 'URL_RUANG_POPUP', $urlRuang);
		
		$data['data']['status']='checked="checked"';
      $data['data']['nstatus']='';
      
      if (isset($data['data']['biaya_sewa_status']) && $data['data']['biaya_sewa_status']!='Y') {
         $data['data']['status'] ='';
         $data['data']['nstatus'] = 'checked="checked"';
      }
		//$data['data']['biaya_sewa'] = number_format($data['data']['biaya_sewa'], 2, ',','.');
      if($data['data']['biaya_sewa_id']=='')
         $urlAction = Dispatcher::Instance()->GetUrl('biaya_sewa_ruang', 'inputBiayaSewaRuang', 'do', 'html');
      else
			$urlAction = Dispatcher::Instance()->GetUrl('biaya_sewa_ruang', 'inputBiayaSewaRuang', 'do', 'html').'&id='.Dispatcher::Instance()->Encrypt($data['data']['biaya_sewa_id']);
			
      $this->mrTemplate->AddVar('content', 'ACTION_URL', $urlAction);
		
      $this->mrTemplate->AddVars('content', $data['data'],'');
   }
}
?>