<?php
/*
	@ClassName : ViewUpdateLantai
	@Copyright : PT Gamatechno Indonesia
	@Analyzed By : Nanang Ruswianto <nanang@gamatechno.com>
	@Author By : Dyan Galih <galih@gamatechno.com>
	@Version : 0.1
	@StartDate : 2010-02-02
	@LastUpdate : 2010-02-02
	@Description : 
*/

require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/gedung/business/Lantai.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/gedung/business/AppGedung.class.php';

class ViewUpdateLantai extends HtmlResponse {
	
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/gedung/template');
		$this->SetTemplateFile('view_update_lantai.html');
	}
	
	function ProcessRequest() {
	
		$lantaiId = Dispatcher::Instance()->Decrypt($_GET['lantaiId']);
		$objLantai = new Lantai();
		
		if($lantaiId != ''){
			$arrLantai = $objLantai->GetLantaiById($lantaiId);
			$return['kode_lantai'] = $arrLantai['lantaiKode'];
			$return['nama_lantai'] = $arrLantai['lantaiNama'];
		}
		
		$msg = Messenger::Instance()->Receive(__FILE__);
		$post = $msg[0][0];
		$return['message'] = $msg['0'][1];
		$return['css'] = $msg['0'][2];

		if($post!=''){
			$return['kode_lantai'] = $post['kode_lantai'];
			$return['nama_lantai'] = $post['nama_lantai'];
		}

		$gedungId = Dispatcher::Instance()->Decrypt($_GET['gId']);
		
		$objGedung = new AppGedung();
		
		$arrGedung = $objGedung->GetGedungById($gedungId);
		$return['kode_gedung'] = $arrGedung['gd_kode'];
		$return['nama_gedung'] = $arrGedung['gd_nama'];
		
		$return['lantaiId'] = $lantaiId;
		$return['gedungId'] = $gedungId;
		return $return;
	}

	function ParseTemplate($data = NULL) {
		$this->mrTemplate->AddVar('content', 'KODE_LANTAI', $data['kode_lantai']);
		$this->mrTemplate->AddVar('content', 'NAMA_LANTAI', $data['nama_lantai']);
		$this->mrTemplate->AddVar('content', 'KODE_GEDUNG', $data['kode_gedung']);
		$this->mrTemplate->AddVar('content', 'NAMA_GEDUNG', $data['nama_gedung']);
		
		if($data['message']!=''){
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['message']);
			$this->mrTemplate->AddVar('warning_box', 'CLASS_PESAN', $data['css']);
		}
		
		
		if($data['lantaiId']=='')
			$urlAction = Dispatcher::Instance()->GetUrl('gedung', 'addLantai', 'do', 'json').
			'&gId='.$data['gedungId'];
		else
			$urlAction = Dispatcher::Instance()->GetUrl('gedung', 'updateLantai', 'do', 'json').
			'&lantaiId='.$data['lantaiId'].
			'&gId='.$data['gedungId'];
		
		$this->mrTemplate->AddVar('content', 'ACTION_URL', $urlAction);
	}
}
?>
