<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot').
   'module/usulan_barang/business/Usulan.class.php';

require_once GTFWConfiguration::GetValue('application', 'docroot') . 'main/function/date.php';

class PrintRtfUsulanList extends HtmlResponse
{   
   function ProcessRequest()
   {
      $Obj = new Usulan;      
      $return = $Obj->GetDataGridForPrintRtf();    
      return $return;
   }
   
   function ParseTemplate($data = NULL)
   {
		
		$contents = file_get_contents(GTFWConfiguration::GetValue( 'application', 'docroot')."doc/template_UsulanBarang.rtf");
		
		$i=0;
		$n=0;
		for($i;$i<sizeof($data);$i++){
		$n++;
			$nomor 		.='\f1\fs16'.' '.$n.'\par';
			$date			= IndonesianDate($data[$i][usulanBrgMstTglUsulan], 'YYYY-MM-DD');
			$tanggal 	.='\f1\fs16'.' '.$date.'\par';
			$nousulan	.='\f1\fs16'.' '.$data[$i][usulanBrgMstNoUsulan].'\par';
			$unit			.='\f1\fs16'.' '.$data[$i][unitkerjaNama].'\par';
			$pengusul	.='\f1\fs16'.' '.$data[$i][pengusul].'\par';
			$pic			.='\f1\fs16'.' '.$data[$i][usulanBrgMstPIC].'\par'; 
			$keterangan	.='\f1\fs16'.' '.$data[$i][usulanBrgMstKet].'\par';
			//print_r($nousulan);exit;
			
		}
		
		$contents = str_replace('[COMPANY_NAME]', GTFWConfiguration::GetValue('organization', 'company_name'), $contents);
		$contents = str_replace('[HEADER]', 'Usulan Pengadaan Barang', $contents);
		
		$contents = str_replace('[NOMOR]', $nomor, $contents);
		$contents = str_replace('[USULANBRGMSTTGLUSULAN]', $tanggal, $contents);
		$contents = str_replace('[USULANBRGMSTNOUSULAN]', $nousulan, $contents);
		$contents = str_replace('[UNITKERJANAMA]', $unit, $contents);
		$contents = str_replace('[PENGUSUL]', $pengusul, $contents);
		$contents = str_replace('[USULANBRGMSTPIC]', $pic, $contents);
		$contents = str_replace('[USULANBRGMSTKET]', $keterangan, $contents);
		
		header("Content-type: application/msword");
		header("Content-disposition: inline; filename=usulanPengadaanBarang".date('d-m-Y').".rtf");
		header("Content-length: " . strlen($contents));
		print $contents;
      // ---------
   }
}
?>