<?php
require_once GTFWConfiguration::GetValue('application', 'docroot').'module/'.Dispatcher::Instance()->mModule.'/business/LapMutasiBarang.class.php';

class PopupGedungRuang extends HtmlResponse
{
	function TemplateModule ()
   {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/'.Dispatcher::Instance()->mModule.'/template');
		$this->SetTemplateFile('popup_gedung_ruang.html');
	}
	
	function ProcessRequest ()
   {
		//$mahasiswa=Dispatcher::Instance()->Decrypt($_GET['mahasiswa']);
		$Obj = new LapMutasiBarang;
		$_GET = $_GET->AsArray();
		if(isset($_POST['keyword'])) {
			$keyword = $_POST['keyword'];
		} elseif(isset($_GET['keyword'])) {
			$keyword = Dispatcher::Instance()->Decrypt($_GET['keyword']);
		} else {
			$keyword = '';
		}
		
		$totalData = $Obj->GetCountData($keyword);
		$itemViewed = 20;
		$currPage = 1;
		$startRec = 0;
		if(isset($_GET['page'])) {
			$currPage = (string)$_GET['page'];
			$startRec =($currPage-1) * $itemViewed;
		}
		
		$data = $Obj->GetDataGedung($keyword, $startRec, $itemViewed);
		$url = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, Dispatcher::Instance()->mSubModule, Dispatcher::Instance()->mAction, Dispatcher::Instance()->mType . '&keyword=' . Dispatcher::Instance()->Encrypt($keyword) . '&cari=' . Dispatcher::Instance()->Encrypt(1));
		Messenger::Instance()->SendToComponent('paging', 'paging', 'view', 'html', 'paging_top', array($itemViewed, $totalData, $url, array($currPage, $keyword), 'popup-subcontent'), Messenger::CurrentRequest);

		$return['dataGedung'] = $data;
		$return['start'] = $startRec+1;
		$return['search']['keyword'] = $keyword;

      return $return;
	}
	
	function ParseTemplate ($data = NULL)
	{
		$search = $data['search'];
		$this->mrTemplate->AddVar('content', 'KEYWORD', $search['keyword']);
		$this->mrTemplate->AddVar('content', 'URL_SEARCH', Dispatcher::Instance()->GetUrl('lap_mutasi_barang', 'gedungRuang', 'popup', 'html'));
				
		if (empty($data['dataGedung'])) {
			$this->mrTemplate->AddVar('data_gedung', 'GEDUNG_EMPTY', 'YES');
		} else {
			$this->mrTemplate->AddVar('data_gedung', 'GEDUNG_EMPTY', 'NO');
			$dataGedung = $data['dataGedung'];
			
			for ($i=0; $i<sizeof($dataGedung); $i++) {
				$no = $i+$data['start'];
				$dataGedung[$i]['number'] = $no;
				if ($no % 2 == 0) $dataGedung[$i]['class_name'] = 'table-common-even';
				else $dataGedung[$i]['class_name'] = '';
				$this->mrTemplate->AddVars('data_gedung_item', $dataGedung[$i], 'GEDUNG_');
				$this->mrTemplate->parseTemplate('data_gedung_item', 'a');	 
			}
		}
	}
}


?>
