<?php

class AppInventarisasi extends Database {

   protected $mSqlFile= 'module/inventarisasi/business/inventarisasi.sql.php';

   function __construct($connectionNumber=0) {
      parent::__construct($connectionNumber);
	  #$this->setDebugOn();
   }

   function ConvertCombo($combo)
   {
      foreach ($combo as $value) $return[$value['id']] = $value['name'];
      return $return;
   }

   #combo
   function GetCbxJenisKib() {
      $result = $this->Open($this->mSqlQueries['get_combo_jenis_kib'], array());
      foreach (array_keys($result) as $key)
      {
			if($result[$key]['kode'] == 'b' or $result[$key]['kode'] == 'a') 
			$return[] = $result[$key];
		}
      return $return;
   }
	
	function GetCbxJenisKibAll() {
      $result = $this->Open($this->mSqlQueries['get_combo_jenis_kib'], array());
		foreach (array_keys($result) as $key)
      {
			if($result[$key]['kode'] != 'c' AND $result[$key]['kode'] != 'g') 
			$return[] = $result[$key];
		}
      return $return;
   }

	function GetCbxStatusAset() {
      $result = $this->Open($this->mSqlQueries['get_combo_status_aset'], array());
      return $result;
   }
	
   function GetCbxUnitPj() {
      $result = $this->Open($this->mSqlQueries['get_unit_pj'], array());
      return $result;
   }

   function GetCbxSumberDana() {
      $result = $this->Open($this->mSqlQueries['get_sumber_dana'], array());
      return $result;
   }

   function GetCbxKepemilikan() {
      $result = $this->Open($this->mSqlQueries['get_kepemilikan'], array());
      return $result;
   }

   function GetCbxLokasiKampus() {
      $result = $this->Open($this->mSqlQueries['get_lokasi_kampus'], array());
      return $result;
   }

   function GetCbxKondisi() {
      $result = $this->Open($this->mSqlQueries['get_kondisi'], array());
      return $result;
   }

   function GetCbxSatuan() {
      $result = $this->Open($this->mSqlQueries['get_cbx_satuan'], array());
      return $result;
   }

   function GetCbxPagar() {
      $result = $this->Open($this->mSqlQueries['get_cbx_pagar'], array());
      $array = eval('return '.str_replace('enum', 'array', $result[0]['Type']).';');
      foreach ($array as $key=>$val) $pagar[$key]['id'] = $pagar[$key]['name'] = $val;
      return $pagar;
   }
	
	function GetCbxIdentitasBarang() {
      $result = $this->Open($this->mSqlQueries['get_cbx_identitas_barang'], array());
      $array = eval('return '.str_replace('enum', 'array', $result[0]['Type']).';');
      foreach ($array as $key=>$val) $pagar[$key]['id'] = $pagar[$key]['name'] = $val;
      return $pagar;
   }

   function GetCbxPenguasaanBarang() {
      $result = $this->Open($this->mSqlQueries['get_cbx_penguasaan_barang'], array());
      return $result;
   }
   # ---------

   function GetDataUserById ($userId)
   {
      if (isset($this->mUserById[$userId])) return $this->mUserById[$userId];
      $result = $this->Open($this->mSqlQueries['get_data_user_by_id'], array($userId));
      $this->mUserById[$userId] = $result[0];
      return $result[0];
   }

   function GetDataUserByUsername ($name)
   {
      if (isset($this->mUserByUserName[$name])) return $this->mUserByUserName[$name];
      $result = $this->Open($this->mSqlQueries['get_data_user_by_user_name'], array($name));
      $this->mUserByUserName[$name] = $result[0];
      return $result[0];
   }

   function GetDataUnitByUnitName ($name)
   {
      if (isset($this->mUnitByUnitName[$name])) return $this->mUnitByUnitName[$name];
      $result = $this->Open($this->mSqlQueries['get_data_unit_by_unit_name'], array($name));
      $this->mUnitByUnitName[$name] = $result[0];
      return $result[0];
   }

   function GetListBiayaLain()
   {
      return $this->Open($this->mSqlQueries['get_list_biaya_lain'], array());
   }

   function GetCountInventarisasi($key) {
      $User = $this->GetDataUserByUsername($_SESSION['username']);
      extract ($key);
      $filter = array
      (
         (int) $jenis_kib, (int) ($jenis_kib == 'all'),
         "$tahun-1-1", "$tahun-12-31", (int) ($tahun == 'all'),
         (int) $sbr_dana, (int) ($sbr_dana == 'all'),
         (int) $kepemilikan, (int) ($kepemilikan == 'all'),
         (int) $lokasi, (int) ($lokasi == 'all'),
         (int) $kondisi, (int) ($kondisi == 'all'),
         $unit_pj_id, $unit_pj_id, $unit_pj_id,
         "%$key%", "%$key%","%$key%",
         $User['unit_kerja_id'], $User['unit_kerja_id'], $User['role_id'],
			(int) $status, (int) ($status == 'all'),
      );

      $result = $this->Open($this->mSqlQueries['get_count_inventarisasi'], $filter);
      return $result[0]['total'];
   }

   public function GetCount(){
      $result = $this->Open($this->mSqlQueries['get_count'], array());
      return $result[0]['total'];
   }

   # multiunit
   function GetInventarisasi($key, $offset, $limit) {
      $User = $this->GetDataUserByUsername($_SESSION['username']);
      $kodeSistemDefault = $User['unitkerjaKodeSistem'];
      extract ($key);
      
      $sql = $this->mSqlQueries['get_inventarisasi'];
      # set KIB
      $company_type = GTFWConfiguration::GetValue('application','company_type');
      if($company_type == '' || empty($company_type)) $company_type = '1';
      if($company_type == '1'){
      	$kodeSimak = GTFWConfiguration::GetValue('organization','kode_kemendiknas').".".
      				 GTFWConfiguration::GetValue('organization','kode_eselon1').".".
      				 GTFWConfiguration::GetValue('organization','kode_wilayah').".".
      				 GTFWConfiguration::GetValue('organization','kode_universitas').".";
      	$sql = str_replace('[SET_KIB]', sprintf('"%s",unitkerjaKode,".",YEAR(invDetTglPembelian)',$kodeSimak), $sql);
      }else{
      	$sql = str_replace('[SET_KIB]', 'YEAR(invDetTglPembelian),".",IFNULL(ruangKode,0)', $sql);
      }
      # search
      if($jenis_kib <> '' && $jenis_kib <> 'all') $sql = str_replace('[CARI_GOL]', sprintf('invDetGolId = "%s" AND ',$jenis_kib), $sql);
      else $sql = str_replace('[CARI_GOL]', '', $sql);
      if($unit_pj_id <> ''){
      	$searchUnit = '(unitkerjaId = "%s" [SHOW_SUBUNIT]) AND (unitkerjaKodeSistem = "%s" OR unitkerjaKodeSistem LIKE "%s") AND';
      	if($show_subunit == '1'){
      		$searchUnit = str_replace('[SHOW_SUBUNIT]', 'OR unitkerjaKodeSistem LIKE (SELECT CONCAT(b.unitkerjaKodeSistem,\'.%%%%\') FROM unit_kerja_ref b WHERE b.unitkerjaId = "%s")', $searchUnit);
      		$sql = str_replace('[CARI_UNIT]', sprintf($searchUnit,$unit_pj_id,$unit_pj_id,$kodeSistemDefault,$kodeSistemDefault.".%%"), $sql);
      	}else{
      		$searchUnit = str_replace('[SHOW_SUBUNIT]', '', $searchUnit);
      		$sql = str_replace('[CARI_UNIT]', sprintf($searchUnit,$unit_pj_id,$kodeSistemDefault,$kodeSistemDefault.".%%"), $sql);
      	} 
      }
      if($tahun <> '' && $tahun <> 'all') $sql = str_replace('[CARI_THN]', sprintf("(invTglPembelian > '%s-1-1 0:0:0' AND invTglPembelian < '%s-12-31 23:59:59') AND ",$tahun,$tahun), $sql);
      else $sql = str_replace('[CARI_THN]', '', $sql);
      if($sbr_dana <> '' && $sbr_dana <> 'all') $sql = str_replace('[CARI_SUMBER]', sprintf("invSumberDana = '%s' AND ",$sbr_dana), $sql);
      else $sql = str_replace('[CARI_SUMBER]', '', $sql);
      if($kepemilikan <> '' && $kepemilikan <> 'all') $sql = str_replace('[CARI_KEPEMILIKAN]', sprintf("invDetKepemilikan = '%s' AND ",$kepemilikan), $sql);
      else $sql = str_replace('[CARI_KEPEMILIKAN]', '', $sql);
      if($lokasi <> '' && $lokasi <> 'all') $sql = str_replace('[CARI_KAMPUS]', sprintf("invDetKampus = '%s' AND ",$lokasi), $sql);
      else $sql = str_replace('[CARI_KAMPUS]', '', $sql);
      if($kondisi <> '' && $kondisi <> 'all') $sql = str_replace('[CARI_KONDISI]', sprinf("invDetKondisiId = '%s' AND ",$kondisi), $sql);
      else $sql = str_replace('[CARI_KONDISI]', '', $sql);
      if($status <> '' && $status <> 'all') $sql = str_replace('[CARI_STATUS]', sprintf("statusAsetId = '%s' AND ",$status), $sql);
      else $sql = str_replace('[CARI_STATUS]', '', $sql);
      
      $filter = array
      (
         /*(int) $jenis_kib, (int) ($jenis_kib == 'all'),
         "$tahun-1-1 0:0:0", "$tahun-12-31 23:59:59", (int) ($tahun == 'all'),
         (int) $sbr_dana, (int) ($sbr_dana == 'all'),
         (int) $kepemilikan, (int) ($kepemilikan == 'all'),
         (int) $lokasi, (int) ($lokasi == 'all'),
         (int) $kondisi, (int) ($kondisi == 'all'),
         $unit_pj_id, $unit_pj_id, $unit_pj_id,*/
         "%$key%", "%$key%","%$key%",
         /*$User['unit_kerja_id'], $User['unit_kerja_id'], $User['role_id'],*/
		/*(int) $status, (int) ($status == 'all'),$User['unitkerjaKodeSistem'].'%',*/
         $offset, $limit
      );
      $result = $this->Open($sql, $filter);
      return $result;
   }

   // untuk form ReInventarisasi
   function GetInventarisasiById ($id)
   {
      $result = $this->Open($this->mSqlQueries['get_data_inventarisasi_by_id'], array($id));
      if (empty($result)) return false;
      $return = $result[0];

      // modifikasi data biar cocok dengan form
      $return['invTglPembelian'] = date ('Y', strtotime($return['invTglPembelian']));
      @$return['isInvSertifikat'] = ($return['invDetSertifikat'] == '') ? '' : 'checked';
      @$return['isInvAkta'] = ($return['invDetAkta'] == '') ? '' : 'checked';
      @$return['isInvBPKB'] = ($return['invDetBPKB'] == '') ? '' : 'checked';
      @$return['isInvSTNK'] = ($return['invDetSTNK'] == '') ? '' : 'checked';
      // ---------

      // nambah data biaya lain
      $return['biaya_lain'] = array();
      $result = $this->Open($this->mSqlQueries['get_biaya_lain_by_id'], array($id));
      foreach ($result as $val)
         $return['biaya_lain'][$val['biayaId']] = $val['biayaNilai'];
      // ---------

      return $return;
   }

   // untuk lihat detail, cetak, dan export
   function GetInventarisasiDetailById($id)
   {
      $result = $this->Open($this->mSqlQueries['get_inventarisasi_detail_by_id'], array($id));
      if (empty($result)) return false;

      if (!isset($this->CBX))
      {
         $this->CBX['GetCbxSumberDana'] = $this->ConvertCombo($this->GetCbxSumberDana());
         $this->CBX['GetCbxSatuan'] = $this->ConvertCombo($this->GetCbxSatuan());
         $this->CBX['GetCbxKepemilikan'] = $this->ConvertCombo($this->GetCbxKepemilikan());
         $this->CBX['GetCbxPenguasaanBarang'] = $this->ConvertCombo($this->GetCbxPenguasaanBarang());
         $this->CBX['GetCbxKondisi'] = $this->ConvertCombo($this->GetCbxKondisi());
         $this->CBX['GetCbxLokasiKampus'] = $this->ConvertCombo($this->GetCbxLokasiKampus());
      }

      $return = $result[0];
      $a = $this->CBX;

      // nambah data biaya lain
      $return['biaya_lain'] = array();
      $result = $this->Open($this->mSqlQueries['get_biaya_lain_by_id'], array($id));
      foreach ($result as $val)
         $return['biaya_lain'][$val['biayaId']] = $val['biayaNilai'];
      // ---------

      $return['invTglPembelian'] = date ('Y', strtotime($return['invTglPembelian']));
      $return['invSumberDana'] = $a['GetCbxSumberDana'][$return['invSumberDana']];
      $return['invSatuanBarang'] = $a['GetCbxSatuan'][$return['invSatuanBarang']];
      @$return['invKepemilikan'] = $a['GetCbxKepemilikan'][$return['invDetKepemilikan']];
      @$return['invPenguasaanBarang'] = $a['GetCbxPenguasaanBarang'][$return['invDetPenguasaanBarang']];
      @$return['invKampus'] = $a['GetCbxLokasiKampus'][$return['invDetKampus']];
      $return['invKondisi'] = $a['GetCbxKondisi'][$return['invKondisiBrgKondId']];

      return $return;
   }

   function GetInventarisasiForExcel($arrayId)
   {
		$filter = implode("', '", $arrayId);
		$result = $this->Open($this->mSqlQueries['get_inventarisasi_id_by_filter'], array($filter));

      foreach ($result as $val)
      {
         $tmp = $this->GetInventarisasiDetailById($val['id']);
         $return[$tmp['golbrgNama']][] = $tmp;
      }

      return $return;
   }

   function GetLogHeader ($id)
   {
      $result = $this->Open($this->mSqlQueries['get_log_lokasi_header'], array($id));
      return $result[0];
   }

   function GetLogLokasiBody ($id)
   {
      return $this->Open($this->mSqlQueries['get_log_lokasi_body'], array($id));
   }

   function GetLogKondisiBody ($id)
   {
      return $this->Open($this->mSqlQueries['get_log_kondisi_body'], array($id));
   }

   function GetCetakKib($list)
   {
      $list = explode('|', $list);
      $sql = str_replace('%ID%', implode(',', array_fill(0, count($list), '%s')), $this->mSqlQueries['get_cetak_kib']);
      $result = $this->Open($sql, $list);

      $return = array();
      foreach ($result as $value) $return[] = $value['KIB'];
      return $return;
   }
   
   function GetCetakKib2($list)
   {
   	$list = explode('|', $list);
   	$kemendiknas = GTFWConfiguration::GetValue('organization','kode_kemendiknas');
   	$eselon1 = GTFWConfiguration::GetValue('organization','kode_eselon1');
   	$kodewil = GTFWConfiguration::GetValue('organization','kode_wilayah');
   	$kodeuniv = GTFWConfiguration::GetValue('organization','kode_universitas');
   	$sql = str_replace('[NEWKODE]', "$kemendiknas.$eselon1.$kodewil.$kodeuniv.#", $this->mSqlQueries['get_cetak_kib2']);
   	$sql = str_replace('%ID%', implode(',', array_fill(0, count($list), '%s')), $sql);
   	$result = $this->Open($sql, $list);
   	 
   	$return = array();
   	foreach ($result as $value) $return[] = $value['KIB'];
   	return $return;
   }

   function GetPenyesuaianData ($id)
   {
      $result = $this->Open($this->mSqlQueries['get_penyesuaian_data'], array($id));
      if (empty($result)) return false;
      else return $result[0];
   }

   /*----------------------*/
   /*------ Do Query ------*/
   /*----------------------*/

   // Note: fungsi ini dipakai juga oleh verifikasi_pengadaan/business/Verifikasi.class.php :: Verifikasi ()
   function AddReInventarisasi($data)
   {
 //untuk golongan selain 2 dan 5 nilai default nilaifaktur=1
		if ($data['golbrgId'] != 2 AND $data['golbrgId'] != 5) {
		$data['invNilaiFaktur']=1;
		}


      foreach (array_keys($data) as $key) if ((string) $data[$key] == '')
         $data[$key] = NULL;
      $this->StartTrans();

      // Inserting Inventaris Master table
      if ($data['invJumlahAset'] < 1) $data['invJumlahAset'] = 1;
      $arg = array
      (
         $data['invBarangId'],
         $data['invKodeAset'],
         $data['invBarcode'],
         $data['invMstLabel'],
         $data['invMerek'],
         $data['invSpesifikasi'],
         $data['invTglPembelian'],
         $data['invSumberDana'],
         $data['invJumlahAset'],
         $data['invSatuanBarang'],
         empty($data['invLuasTanah'])?NULL:$data['invLuasTanah'],
         $data['invNilaiPerolehanSatuan'],
         empty($data['invNilaiFaktur'])?NULL:$data['invNilaiFaktur'],
			$data['invTotalPerolehan'],
			$data['invSPMNumber'],
         $_SESSION['username']
      );

      $inv_master = $this->Execute($this->mSqlQueries['add_inv_mst'], $arg);
      if (!$inv_master)
      {
         $this->EndTrans(false);
         return 1;
      }
      // ---------

      // Updating Detail Biaya
      if (!$this->AddDetailBiayaById($data['biaya_lain']))
      {
         $this->EndTrans(false);
         return 2;
      }
      // ---------

      // Updating Inventaris Detail table
      if ($data['golbrgId'] === 1) $data['invNilaiPerolehanSatuan'] = $data['invTotalPerolehan'];
      $arg = array
      (
         $data['invBarangId'],
         $data['invBarcode'],
         $data['invMstLabel'],
         $data['invMerek'],
         $data['invSpesifikasi'],
         $data['invTglPembelian'],
         empty($data['invNilaiResidu'])? NULL:$data['invNilaiResidu'],
         $data['invTipe'],
         $data['invSumberDana'],
         $data['invSatuanBarang'],
         $data['invNilaiPerolehanSatuan'],
         empty($data['invNJOP'])?NULL:$data['invNJOP'],
         $data['invUmurEkonomis'],
         $data['invLokasi'],
         $data['invKegunaan'],
         $data['invSertifikat'],
         $data['invAkta'],
         $data['invBPKB'],
         $data['invSTNK'],
         $data['invNoMesin'],
         $data['invNoRangka'],
         $data['invNoPolisi'],
         $data['invNoLain'],
         $data['invWarna'],
         $data['invPagar'],
         $data['invBatasUtara'],
         $data['invBatasTimur'],
         $data['invBatasSelatan'],
         $data['invBatasBarat'],
         $data['invKepemilikan'],
         $data['invPenguasaanBarang'],
         $data['invKeteranganLain'],
         $data['invKampus'],
         empty($data['invGedungId'])?NULL:$data['invGedungId'],
			//$data['invGedungId'],
         $data['invRuanganId'],
         $data['invUnitKerja'],
         $data['invKondisiBrgKondId'],
			$data['invNamaFile'],
         $_SESSION['username'],
			$data['statusaset'],
			$data['invDetIdentitasBarang']
      );

      for ($i = 0; $i < $data['invJumlahAset']; $i++)
      {
         $inv_detail = $this->Execute($this->mSqlQueries['add_inv_detail'], $arg);
         if (!$inv_detail)
         {
            $this->EndTrans(false);
            return 3;
         }
         
         // add new field invDetGolId,invDetBidangbrngId,invDetKelbrgId,invDetSubkelbrgId,invDetBarangId
         $this->execute($this->mSqlQueries['update_detil'],array());

         // Add Kondisi History
         $id = $this->Open('SELECT MAX(invDetId) AS id FROM inventarisasi_detail', array());
         if (!$this->Execute($this->mSqlQueries['add_kondisi_history'], array($id[0]['id'], $data['invKondisiBrgKondId'], $data['invNamaFile'], $_SESSION['username'])))
         {

            $this->EndTrans(false);
            return 4;
         }
         // ---------

         // Add Lokasi History
         if (!$this->Execute($this->mSqlQueries['add_lokasi_history'], array($data['invKampus'], empty($data['invGedungId'])?NULL:$data['invGedungId'], empty($data['invRuanganId'])?NULL:$data['invRuanganId'], $_SESSION['username'])))
         {
            $this->EndTrans(false);
            return 5;
         }
         // ---------
      }
      // --------- End of updating Inventaris Detail table

      // Insert Tabel penyusutan_brg_mst
      /*
      $perolehan = $data['invNilaiPerolehanSatuan']?$data['invNilaiPerolehanSatuan']:$data['invTotalPerolehan'];
      $residu =(($perolehan - $data['invNilaiResidu']) / $data['invUmurEkonomis']);
      $arg = array
      (
         $perolehan,
         empty($data['invNilaiResidu'])?NULL:$data['invNilaiResidu'],
         $data['invUmurEkonomis'],
         $perolehan,
         empty($residu)?NULL:$residu
      );
      */
      // aset dengan umur ekonomis kurang dari 12 bulan tidak masuk ke penyusutan
      if ($data['invUmurEkonomis'] > 11 AND !$this->Execute($this->mSqlQueries['add_penyusutan'], array()))
      {
         $this->EndTrans(false);
         return 6;
      }
      // ---------

      $this->EndTrans(true);
      #die('test');
      return 0;
   }

   function UpdateReInventarisasi($id, $data)
   {
      foreach (array_keys($data) as $key) if ((string) $data[$key] == '')
         $data[$key] = NULL;
      $this->StartTrans();
      // Updating Inventaris Detail table
      $arg = array
      (
         $data['invBarcode'],
         $data['invMstLabel'],
         $data['invMerek'],
         $data['invSpesifikasi'],
         $data['invTglPembelian'],
         $data['invNilaiResidu'],
         $data['invTipe'],
         $data['invSumberDana'],
         $data['invSatuanBarang'],
         $data['invNilaiPerolehanSatuan'],
         $data['invNJOP'],
         $data['invUmurEkonomis'],
         $data['invLokasi'],
         $data['invKegunaan'],
         $data['invSertifikat'],
         $data['invAkta'],
         $data['invBPKB'],
         $data['invSTNK'],
         $data['invNoMesin'],
         $data['invNoRangka'],
         $data['invNoPolisi'],
         $data['invNoLain'],
         $data['invWarna'],
         $data['invPagar'],
         $data['invBatasUtara'],
         $data['invBatasTimur'],
         $data['invBatasSelatan'],
         $data['invBatasBarat'],
         $data['invKepemilikan'],
         $data['invPenguasaanBarang'],
         $data['invKeteranganLain'],
         $data['invKampus'],
         $data['invGedungId'],
         $data['invRuanganId'],
         $data['invUnitKerja'],
			$data['invNamaFile'],
			$data['invKondisiBrgKondId'],
			$data['statusaset'],
			$data['invDetIdentitasBarang'],
         $_SESSION['username'],
         $id,
      );
		
      $inv_detail = $this->Execute($this->mSqlQueries['update_inv_detail'], $arg);
      // ---------

      // Add Kondisi History
		$files1 = explode('-', $data['invNamaFileOld']);
		$files2 = explode('.', $files1[1]);
		$filesA = $files1[0].'.'.$files2[1];

		$files1 = explode('-', $data['invNamaFile']);
		$files2 = explode('.', $files1[1]);
		$filesB = $files1[0].'.'.$files2[1];

      if ($data['oldKondisi'] != $data['invKondisiBrgKondId'] || $filesA != $filesB){
         $inv_kondisi = $this->Execute($this->mSqlQueries['update_kondisi_history'], array($id, $data['invKondisiBrgKondId'], $data['invNamaFile'], $_SESSION['username']));
      }else{ $inv_kondisi = true;}
      // ---------

      // Add Lokasi History
      if ($data['oldLokasi'] != $data['invKampus'].'.'.$data['invGedungId'].'.'.$data['invRuanganId'])
         $inv_lokasi = $this->Execute($this->mSqlQueries['update_lokasi_history'], array($id, $data['invKampus'], $data['invGedungId'], $data['invRuanganId'], $_SESSION['username']));
      else $inv_lokasi = true;
      // ---------

      $isDone = $inv_detail && $inv_kondisi && $inv_lokasi;
      $this->EndTrans($isDone);

      if ($isDone) return 0;
      else return 1;
   }

   function AddDetailBiayaById ($biaya)
   {
      $return = true;
      if (is_array($biaya)) foreach ($biaya as $key=>$value)
      {
         if (intval($value) < 1) continue;
         if ($this->Execute($this->mSqlQueries['add_detail_biaya_by_id'], array($key, $value))) continue;
         $return = false;
         break;
      }
      return $return;
   }

   function PenyesuaianAset ($id, $data)
   {
      extract($data);
      $arg = array($mstPenystnUmrEko, $mstPenystnNilaiPerolehan, $mstPenystnNilaiResidu, $mstPenystnBrgId);
      #TODO next : log penyesuaian (need initial first conversion log_penyesuaian = penyusutan_brg_mst)
      $result = $this->Execute($this->mSqlQueries['update_penyesuaian_aset'], $arg);
      if ($result) return 0;
      else return 1;
   }
	
	function DoDeleteInventarisasi ($id)
   {
		$data = $this->GetInventarisasiById($id);
		if(isset($data['invMstPengadaanId'])){
			$result = false;
		} else {
			$result = $this->Execute($this->mSqlQueries['do_delete_inventarisasi'], array($id));
		}
		
      if ($result) return 0;
      else return 1;
   }
}
?>
