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

class PopupPengadaanVerifikasiBarangDetil extends HtmlResponse
{

	function TemplateBase()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application', 'docroot') . 'main/template/');
      $this->SetTemplateFile('document-common-popup.html');
      $this->SetTemplateFile('layout-common-popup.html');
   }
	
   function TemplateModule()
   {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot').'module/pb_pengadaan_verifikasi/template');
      $this->SetTemplateFile('popup_pengadaan_verifikasi_barang_detil.html');
   }
   
   function ProcessRequest()
   {
		$Obj = new Komponen();
      /*
      // inisialisasi default value
      $data = array();
		if (isset($_GET['id']))
      {
         $result = $Obj->GetPengadaanDetById($_GET['id']->Integer()->Raw());
         if ($result === false) unset($_GET['id']);
         else $data = $result;
      }
      
      $KIB = $Obj->GetCbxJenisKib();
      $tmp = $Obj->GetPengadaanDetail();
      if ($tmp['jenis_pb_pengadaan_verifikasi'] == 'BHP') $KIB = array(end($KIB));
      else array_pop($KIB);
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'jenis_kib', array('golbrgId', $KIB, $data['golbrgId'], false, 'id="jenisKib" style="display: none"'), Messenger::CurrentRequest);
      $tmp = $Obj->ConvertCombo($KIB);
      $data['jenis_kib'] = $tmp[$data['golbrgId']];
      
      $satuanBarang = $Obj->ConvertCombo($Obj->GetCbxSatuan());
      $data['satuan_barang'] = $satuanBarang[$data['PengadaanDetSatuan']];
      
      $pagar = $Obj->ConvertCombo($Obj->GetCbxPagar());
      $data['pagar'] = $pagar[$data['PengadaanDetPagar']];
      
      $sifatBangunan = $Obj->ConvertCombo($Obj->GetCbxSifatBangunan());
      $data['sifat_bangunan'] = $sifatBangunan[$data['PengadaanDetSifatBangunan']];
      
      $IMB = $Obj->ConvertCombo($Obj->GetCbxIMB());
      $data['IMB'] = $IMB[$data['PengadaanDetIMB']];
      
      $kepemilikan = $Obj->ConvertCombo($Obj->GetCbxKepemilikan());
      $data['kepemilikan'] = $kepemilikan[$data['PengadaanDetPmlkBrg']];
      
      $kepenguasaan = $Obj->ConvertCombo($Obj->GetCbxPenguasaanBarang());
      $data['kepenguasaan'] = $kepenguasaan[$data['PengadaanDetPenguasaan']];
      
      $kondisiBarang = $Obj->ConvertCombo($Obj->GetCbxKondisi());
      $data['kondisi_barang'] = $kondisiBarang[$data['PengadaanDetKondisi']];
      
      if ($data['PengadaanDetDenah'] != '' && file_exists(GTFW_APP_DIR.'/'.$Obj->mImagePath.$data['PengadaanDetDenah']))
         $data['PengadaanDetDenah'] = '<img src="'.$Obj->mImagePath.$data['PengadaanDetDenah'].'">';
      else $data['PengadaanDetDenah'] = 'Tidak ada';
      if ($data['PengadaanDetFoto'] != '' && file_exists(GTFW_APP_DIR.'/'.$Obj->mImagePath.$data['PengadaanDetFoto']))
         $data['PengadaanDetFoto'] = '<img src="'.$Obj->mImagePath.$data['PengadaanDetFoto'].'">';
      else $data['PengadaanDetFoto'] = 'Tidak ada';
      
      foreach (array_keys($data) as $tmp)
         if (is_numeric($data[$tmp]) && strpos($data[$tmp], '.') !== false)
            $data[$tmp] = number_format($data[$tmp], 2, ',', '.');
      foreach (array_keys($data['biaya_lain']) as $tmp)
         $data['biaya_lain'][$tmp] = number_format($data['biaya_lain'][$tmp], 2, ',', '.');
      // ---------
      
      // inisialisasi link address
      // $return['link']['back'] = Dispatcher::Instance()->GetUrl('pb_pengadaan_verifikasi', 'komponenList', 'view', 'html');
      $return['link']['action'] = Dispatcher::Instance()->GetUrl('pb_pengadaan_verifikasi', 'komponenInput', 'do', 'html');
      if (isset($_GET['id'])) $return['link']['action'] .= '&id='.$_GET['id']->Integer()->Raw();
      $return['link']['pop_up_kode_aset'] = Dispatcher::Instance()->GetUrl('inventarisasi', 'popUpKodefikasi', 'view', 'html');
      // ---------
      
      $return['list_biaya_lain'] = $Obj->GetListBiayaLain();
      */
		$return['data'] = $data;
      return $return;
   }
   
	function ParseTemplate($data = NULL)
   {
      if ($data == null) return null;
      
      // render link
      //$this->mrTemplate->AddVars('content', $data['link'], 'URL_');
      
		/*
      // render data detail
      $biayaLain = $data['data']['biaya_lain'];
      unset($data['data']['biaya_lain']);
      $this->mrTemplate->AddVars('content', $data['data'], '');
      
      // render biaya lain
      if (empty($data['list_biaya_lain']))
         $this->mrTemplate->AddVar('biaya_lain', 'BIAYA_LAIN_EMPTY', 'YES');
      else
      {
         $this->mrTemplate->AddVar('biaya_lain', 'BIAYA_LAIN_EMPTY', 'NO');
         foreach ($data['list_biaya_lain'] as $value)
         {
            $this->mrTemplate->AddVar('biaya_item', 'BIAYAID', $value['id']);
            $this->mrTemplate->AddVar('biaya_item', 'BIAYANAME', $value['name']);
            $this->mrTemplate->AddVar('biaya_item', 'BIAYANILAI', $biayaLain[$value['id']]);
            $this->mrTemplate->parseTemplate('biaya_item', 'a');
         }
      }
      // ---------
		*/
   }
}
?>