<?php

require_once GTFWConfiguration::GetValue( 'application', 'docroot').'module/'.Dispatcher::Instance()->mModule.'/business/AppInventarisasi.class.php';

class ViewCetakLogLokasi extends HtmlResponse {	
	
	function ProcessRequest() {	
		$Obj = new AppInventarisasi();
		
		$dataHeader = $Obj->GetLogHeader($_GET['id']->Integer()->Raw());
        $dataBody = $Obj->GetLogLokasiBody($_GET['id']->Integer()->Raw());

		$contents = file_get_contents(GTFWConfiguration::GetValue( 'application', 'docroot')."doc/template_log_lokasi.rtf");
		$contents = str_replace('[NAMA_COMPANY]',GTFWConfiguration::GetValue('organization', 'company_name'), $contents);
		$contents = str_replace('[HEADER]', 'Log Lokasi', $contents);
		
		$contents = str_replace('[KODE_BARANG]', $dataHeader['kodeBarang'], $contents);
		$contents = str_replace('[NAMA_BARANG]', $dataHeader['barangNama'], $contents);
		$contents = str_replace('[LABEL_BARANG]', $dataHeader['invMstLabel'], $contents);
		$contents = str_replace('[MEREK]', $dataHeader['invMerek'], $contents);
		$contents = str_replace('[SPESIFIKASI]', $dataHeader['invSpesifikasi'], $contents);
		
		for ($i=0; $i<sizeof($dataBody); $i++) {
		$no = $i+1;
		$nomor .= ' '.$no.'.'.'\par';
		$tanggal .= ' '.$dataBody[$i]['InvHisTanggal'].'\par';
		$kampus .= ' '.$dataBody[$i]['kampusNama'].'\par';
		$lokasi .= ' '.$dataBody[$i]['lokasiAset'].'\par';
		}
		
		$contents = str_replace('[NOMOR]',$nomor, $contents);
		$contents = str_replace('[TANGGAL]',$tanggal, $contents);
		$contents = str_replace('[KAMPUS]',$kampus, $contents);
		$contents = str_replace('[LOKASI]',$lokasi, $contents);
		
		header("Content-type: application/msword");
		header("Content-disposition: inline; filename=log_lokasi". (date('d-m-Y')).".rtf");
		header("Content-length: " . strlen($contents));
		print $contents;
      
	}
   
}
?>
