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

class ViewCetakDir extends HtmlResponse
{
   function TemplateModule()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/laporan_dir_barcode/template');
		$size = $_GET['size']->raw();
		if($size==10){
			$this->SetTemplateFile('view_cetak_kib.html');
		} else {
			$this->SetTemplateFile('view_cetak_kib5cm.html');
		}
	}
   
   function TemplateBase()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
   }
   
   function ProcessRequest()
   {
      $Obj = new AppLaporanDir();
      
      if (empty($_GET['gedung']) or empty($_GET['pj']))
         $return['data'] = array();
      else $return['data'] = $Obj->getDataDir($_GET['gedung']->Raw(), $_GET['pj']->Raw());
      return $return;
   }
   
   
   function ParseTemplate($data = NULL)
   {
      $keys = implode('|', array_keys($data));

      if (empty($data['data']))
      {
			$this->mrTemplate->SetAttribute('empty', 'visibility', 'visible');
         return;
      }
      else $this->mrTemplate->SetAttribute('kib', 'visibility', 'visible');
      
		//print_r($data);
      foreach ($data['data'] as $value)
      {
         //list($tmp['kode_a'], $tmp['kode_b']) = explode('|', $value);
			$tmp['kode_a'] = $value['tahun'];
			$tmp['kode_b'] = $value['kode_barang'];
         $tmp['barcode'] = Dispatcher::Instance()->GetUrl(/*Dispatcher::Instance()->mModule*/'inventarisasi','barcode','view','img')."&text=".$tmp['kode_b'];
         $this->mrTemplate->AddVars('kib', $tmp, '');
         $this->mrTemplate->parseTemplate('kib', 'a');
      }
   }
   
}
?>