<?php
/**
* @package : ViewJadwalRuang
* @copyright : Copyright (c) PT Gamatechno Indonesia
* @Analyzed By : Nanang Ruswianto
* @author : Didi Zuliansyah
* @version : 01
* @startDate : 2013-01-01
* @lastUpdate : 2013-01-01
* @description : Class ViewJadwalRuang
*/

require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jadwal_ruang_kuliah/business/jadwalRuangKuliah.class.php';

class ViewJadwalRuang extends HtmlResponse {

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

	function ProcessRequest() {
		$obj = new jadwalRuangKuliah(1);
		if($obj->Connect()) $return['db_connect'] = true;
		else $return['db_connect'] = false;
		
		$tmpDate = date('Y-m-d',strtotime('-7 days'));
		$startDate = explode('-',$tmpDate);
		$tgl['tanggal_awal_year'] = $startDate[0];
		$tgl['tanggal_awal_mon'] = $startDate[1];
		$tgl['tanggal_awal_day'] = $startDate[2];
		$tgl['tanggal_akhir_year'] = date('Y');
		$tgl['tanggal_akhir_mon'] = date('m');
		$tgl['tanggal_akhir_day'] = date('d');
		
		Messenger::Instance()->SendToComponent('tanggal', 'tanggal', 'view', 'html', 'tanggal_awal', array($tgl['tanggal_awal_year'].'-'.$tgl['tanggal_awal_mon'].'-'.$tgl['tanggal_awal_day'], 1970), Messenger::CurrentRequest);
		Messenger::Instance()->SendToComponent('tanggal', 'tanggal', 'view', 'html', 'tanggal_akhir', array($tgl['tanggal_akhir_year'].'-'.$tgl['tanggal_akhir_mon'].'-'.$tgl['tanggal_akhir_day'], 1970), Messenger::CurrentRequest);
		
		return $return;
	}

	function ParseTemplate($data = NULL) {
		if(!$data['db_connect']) {
         	$this->mrTemplate->AddVar('data_grid', 'IS_NOT_CONNECT', 'YES');
      	}else{
         	$this->mrTemplate->AddVar('data_grid', 'IS_NOT_CONNECT', 'NO');
			$urlSearch = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'GetJadwalRuang', 'do', 'json');
			$this->mrTemplate->AddVar('data_grid', 'URL_SEARCH', $urlSearch);
			$this->mrTemplate->AddVar('data_grid', 'URL_POPUP', $urlPopup);
      	}
	}
}
?>