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

class ViewInputPindahRuang extends HtmlResponse 
{
	function TemplateModule()
   {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/gedung/template');
		$this->SetTemplateFile('view_input_pindah_ruang.html');
	}
   
   function ProcessRequest()
   {
		$msg = Messenger::Instance()->Receive(__FILE__);
      $this->Data = $msg[0][0];
		$this->Pesan = $msg[0][1];
		$this->css = $msg[0][2];
		
      $Obj = new Ruang;
      $gId = $Obj->gId;
		
		if(!empty($_GET['id']) && !empty($_GET['lantaiId'])){
			$getDataRuang = $Obj->GetDataRuangById($_GET['id']);
			$getDataGedungLantai = $Obj->GetGedungLantai($_GET['lantaiId']);
		
			$result = array(
				'ruangId' => $getDataRuang['id'],
				'ruangNama' => $getDataRuang['kode'].' - '.$getDataRuang['nama'],
				'lantaiId' => $getDataGedungLantai[0]['lantaiId'],
				'lantaiNama' => $getDataGedungLantai[0]['lantaiKode'].' - '.$getDataGedungLantai[0]['lantaiNama'],
				'gedungId' => $getDataGedungLantai[0]['gedung_id'],
				'gedungNama' => $getDataGedungLantai[0]['gedungKode'].' - '.$getDataGedungLantai[0]['gedungNama']
			);
			$gId = '';
		} elseif($this->Data){
			$gId = $this->Data['gedung'];
			$lantai = $this->Data['lantai'];
			$result = $this->Data;
		}
		
		$comboGedung = $Obj->GetComboGedung();
		Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'gedung', array('gedung', $comboGedung, $gId, 'false', 'onchange=\'setComboLantai(this.value);\''), Messenger::CurrentRequest);
		
		$comboLantai = $Obj->GetComboLantai($gId);
		Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'lantai', array('lantai', $comboLantai, $lantai, 'false', ''), Messenger::CurrentRequest);
		
      $return['link']['back'] = Dispatcher::Instance()->GetUrl('gedung', 'listRuang', 'view', 'html').'&id='.$_GET['id'].'&lantaiId='.$_GET['lantaiId'];
      $return['link']['action'] = Dispatcher::Instance()->GetUrl('gedung', 'inputPindahRuang', 'do', 'html');
   	$return['data'] = $result;
      return $return;
   }
   
	function ParseTemplate($data = NULL)
   {
      $this->mrTemplate->AddVars('content', $data['link'], 'URL_');
		
      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'], '');
		}
   }
}
?>
