<?php

require_once GTFWConfiguration::GetValue( 'application', 'docroot').'module/mutasi_barang/business/AppMutasi.class.php';
require_once GTFWConfiguration::GetValue('application', 'docroot') . 'main/function/date.php';

class ViewCetakMutasiBarang extends HtmlResponse {	
	
	function ProcessRequest() {	
		$id = $_GET['mutasiId']->Raw();

		$Obj = new AppMutasiBarang();
		$arrMutasi = $Obj->GetMutasiDetail($id);
		$arrMutasi = $arrMutasi[0];
		
		# Header
		$contents = file_get_contents(GTFWConfiguration::GetValue('application', 'docroot') . 'doc/template_ba_mutasi_barang.rtf');
		$contents = str_replace('[COMPANY_NAME]',GTFWConfiguration::GetValue('organization', 'company_name'), $contents);
		$contents = str_replace('[COMPANY_ADDRESS]',GTFWConfiguration::GetValue('organization', 'company_address'), $contents);
		$contents = str_replace('[KOTA_TGL_CETAK]', GTFWConfiguration::GetValue('organization', 'city').', '.IndonesianDate(date('Y-m-d'), 'YYYY-MM-DD'), $contents);
		
		# Body
		$contents = str_replace('[UNIT_ASAL]', $arrMutasi['unit_asal'], $contents);
		$contents = str_replace('[UNIT_TUJUAN]', $arrMutasi['unit_tujuan'], $contents);
		$contents = str_replace('[BERITA_ACARA]', $arrMutasi['ba_mutasi'], $contents);
		$contents = str_replace('[TGL_MUTASI]', IndonesianDate($arrMutasi['tgl'], 'YYYY-MM-DD'), $contents);
		$contents = str_replace('[PIC]', $arrMutasi['pic'], $contents);
		$contents = str_replace('[KEPALA]', $arrMutasi['username'], $contents);
		
		header("Content-type: application/msword");
		header("Content-disposition: inline; filename=mutasi_barang_". (date('d-m-Y_H-i-s')).".rtf");
		header("Content-length: " . strlen($contents));
		print $contents;
      
	}
   
}
?>
