<?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 PrintRtfPenggunaanRuang extends HtmlResponse
{
	
   function ProcessRequest()
   {
      $Obj	 	= new PenggunaanRuang();
		$return	= $Obj->GetDataGridForPrintRtf();
      return $return;
   }
	
   function ParseTemplate($data = NULL)
   {
		$contents = file_get_contents(GTFWConfiguration::GetValue( 'application', 'docroot')."doc/template_penggunaan_ruang.rtf");
		
		$i=0;
		$n=0;
		for($i;$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
			
			$nomor 			.='\f1\fs20'.' '.$n.'\par';
			$kode				.='\f1\fs20'.' '.$data[$i][kode].'\par';
			$nama 			.='\f1\fs20'.' '.$data[$i][nama].'\par';
			$jenis			.='\f1\fs20'.' '.$data[$i][jenis].'\par';
			$tglawal			.='\f1\fs20'.' '.$startDate.'\par';
			$jamawal			.='\f1\fs20'.' '.$data[$i][jamawal].'\par';
			$tglakhir		.='\f1\fs20'.' '.$lastDate.'\par'; 
			$jamakhir		.='\f1\fs20'.' '.$data[$i][jamakhir].'\par';
		}
		//-- buat asesorisnya
		$namacompany 	= GTFWConfiguration::GetValue('organization', 'company_name');
		$header 	= "Penggunaan Ruang";
		$tglcetak		= IndonesianDate(date('Y-m-d'), 'YYYY-MM-DD');
		
		//-- disini kontennya
		$contents = str_replace('[NAMACOMPANY]', $namacompany, $contents);
		$contents = str_replace('[HEADER]', $header, $contents);
		$contents = str_replace('[NAMACETAK]', $namacetak, $contents);
		$contents = str_replace('[TGLCETAK]', $tglcetak, $contents);
		$contents = str_replace('[KOTA]', GTFWConfiguration::GetValue('organization','city'), $contents);
		$contents = str_replace('[NOMOR]', $nomor, $contents);
		$contents = str_replace('[RUANGKODE]', $kode, $contents);
		$contents = str_replace('[RUANGNAMA]', $nama, $contents);
		$contents = str_replace('[JNSPENGGUNAANRUANGNAMA]', $jenis, $contents);
		$contents = str_replace('[RUPENGTGLMULAI]', $tglawal, $contents);
		$contents = str_replace('[RUPENGJAMMULAI]', $jamawal, $contents);
		$contents = str_replace('[RUPENGTGLSELESAI]', $tglakhir, $contents);
		$contents = str_replace('[RUPENGJAMSELESAI]', $jamakhir, $contents);
		
		header("Content-type: application/msword");
		header("Content-disposition: inline; filename=penggunaan_ruang".date('d-m-Y').".rtf");
		header("Content-length: " . strlen($contents));
		print $contents;
	}
}
?>