<?php
require_once GTFWConfiguration::GetValue('application', 'docroot') . 'module/penggunaan_ruang/business/PenggunaanRuang.class.php';
require_once GTFWConfiguration::GetValue('application', 'docroot') . 
'main/function/date.php';

class PrintXlsPenggunaanRuang extends XlsResponse {
   var $mWorksheets = array('Data');
	
	function GetFileName() {
      return 'PenggunaanRuang'.date("Y-m-d").'.xls';
   }
	
   function ProcessRequest()
   {
      $Obj	 	= new PenggunaanRuang();
		$return	= $Obj->GetDataGridForPrintRtf();
		if (empty($return)) {
         $this->mWorksheets['Data']->write(0, 0, 'Data kosong');
      } else {
		
			$fTitle = $this->mrWorkbook->add_format();
		   $fTitle->set_bold();
         $fTitle->set_size(12);
         $fTitle->set_align('vcenter');

		   $fTableTitle = $this->mrWorkbook->add_format();
         $fTableTitle->set_border(1);
		   $fTableTitle->set_bold();
         $fTableTitle->set_size(10);
         $fTableTitle->set_align('center');
			
			$fColData = $this->mrWorkbook->add_format();
         $fColData->set_border(1);
			
			$this->mWorksheets['Data']->write(0, 0, 'Daftar Penggunaan Ruang', $fTitle);
			
			$no = 3;
			$this->mWorksheets['Data']->write($no, 0, 'No', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 1, 'Kode Ruang', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 2, 'Nama Ruang', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 3, 'Jenis', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 4, 'Tanggal Awal', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 5, 'Jam Awal', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 6, 'Tanggal Akhir', $fTableTitle);
         $this->mWorksheets['Data']->write($no, 7, 'Jam Akhir', $fTableTitle);
			
			$no = 4;
			$data = $return;
			for($i=0;$i<sizeof($data);$i++){
				$n++;
				//-- convert dulu
				$startDate		= IndonesianDate($data[$i]['tglawal'], 'YYYY-MM-DD');
				$lastDate		= IndonesianDate($data[$i]['tglakhir'], 'YYYY-MM-DD');
				//-- end of convert
				
				$this->mWorksheets['Data']->write($no, 0, ($i+1), $fColData);
				$this->mWorksheets['Data']->write($no, 1, $data[$i]['kode'], $fColData);
				$this->mWorksheets['Data']->write($no, 2, $data[$i]['nama'], $fColData);
				$this->mWorksheets['Data']->write($no, 3, $data[$i]['jenis'], $fColData);
				$this->mWorksheets['Data']->write($no, 4, $startDate, $fColData);
				$this->mWorksheets['Data']->write($no, 5, $data[$i]['jamawal'], $fColData);
				$this->mWorksheets['Data']->write($no, 6, $lastDate, $fColData);
				$this->mWorksheets['Data']->write($no, 7, $data[$i]['jamakhir'], $fColData);
            $no++;
			}
		}
   }
}
?>