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

class ViewRtfMutasiBarang extends RtfResponse
{
	function __construct() 
	{
	}
	function GetFileName() 
	{		
		return "lap_mutasi_barang_" . date('d-m-Y_H-i-s') . ".rtf";
	}
	
	function ProcessRequest() 
	{
		$kodeBA = $_GET['kodeba']->Raw();

		$Obj = new LapMutasiBarang();
		$arrMutasi = $Obj->GetDataMutasiRtfByBA($kodeBA);
		$contents = GTFWConfiguration::GetValue('application', 'docroot') . 'doc/template_lap_mutasi_barang.rtf';
		$this->rtf->SetContent($contents);
		$arrCell = array(
			"NO",
			"BARANG",
			"MERK",
			"NOMOR",
			"JUMLAH",
			"KETERANGAN",
			"SATUAN"
		);
		
		$hari = array(1=>"Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu", "Minggu");

		$this->rtf->AddVar("NAMA_PENERIMA", $arrMutasi[0]['nama_penerima']);
		$this->rtf->AddVar("UNIT_PENERIMA", $arrMutasi[0]['unit_tujuan']);
		$this->rtf->AddVar("NIP_PENERIMA", '');
		$this->rtf->AddVar("NAMA_PENGIRIM", $arrMutasi[0]['nama_pengirim']);
		$this->rtf->AddVar("UNIT_PENGIRIM", $arrMutasi[0]['unit_asal']);
		$this->rtf->AddVar("NIP_PENGIRIM", '');
		$this->rtf->AddVar("HARI", $hari[date('N')]);
		$this->rtf->AddVar("TANGGAL", IndonesianDate(date('Y-m-d'), 'YYYY-MM-DD'));
		
		for ($i = 0;$i < count($arrMutasi);$i++) 
		{
			$nomor[$i] .= ($i + 1).'\par\par\par';
			$barang[$i] .= $arrMutasi[$i]['nama_aset'].'\par Merk '.$arrMutasi[$i]['merk'].'\par No. Inventaris '.$arrMutasi[$i]['kode_aset'].'\par';
			$jumlah[$i] .= number_format($arrMutasi[$i]['jumlah_aset'],0,',','.').' '.$arrMutasi[$i]['satuan'].'\par\par\par';
			$keterangan[$i] .= $arrMutasi[$i]['keterangan'].'\par\par\par';
		}
		
		$this->rtf->AddVars($arrCell[0], $nomor);
		$this->rtf->AddVars($arrCell[1], $barang);
		$this->rtf->AddVars($arrCell[4], $jumlah);
		$this->rtf->AddVars($arrCell[5], $keterangan);
	}
}
?>
