<?php
class Kodefikasi extends Database
{
   protected $mSqlFile= 'module/inventarisasi_detail/business/PopUpKodefikasi.sql.php';
   
	function __construct($connectionNumber=0)
   {
		parent::__construct($connectionNumber);
	}

	function GetComboGolongan()
   {
		$result = $this->Open($this->mSqlQueries['get_combo_golongan'], array());
      foreach (array_keys($result) as $key)
         if (strpos($result[$key]['name'], 'KIB D:') !== 0)
            $return[] = $result[$key];
		
      return $return;
	}

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

	function GetComboStnBarang()
   {
		$result = $this->Open($this->mSqlQueries['get_combo_satuan_barang'], array());
		return $result;
	}
   
   function GetDataBarangCount($data,$kibId)
   {

      $result = $this->Open($this->mSqlQueries['get_data_barang_count'], array($kibId, '%'.$data['CARI_KODE_BARANG'].'%','%'.$data['CARI_NAMA_BARANG'].'%'));

      if (is_array($result))
         return $result[0]['total'];
      else return 0;
   }
   
   function GetDataBarang($data, $kibId, $start = 0, $limit = 1000)
   {
      $result = $this->Open($this->mSqlQueries['get_data_barang'], array($kibId, '%'.$data['CARI_KODE_BARANG'].'%','%'.$data['CARI_NAMA_BARANG'].'%',$start, $limit));
       if (count($result) == 0) return array();
      foreach ($result as $value)
         $return[$value['idKelompok']][$value['idSubKelompok']][$value['id']] = $value;
	  return $return;
   }
   
   function GetKelompokList()
   {
		$result = $this->Open($this->mSqlQueries['get_kelompok_list'], array());
      if (count($result) == 0) return array();
      foreach ($result as $value)
         $return[$value['id']] = $value;
      return $return;
   }
   
   function GetSubKelompokList()
   {
		$result = $this->Open($this->mSqlQueries['get_sub_kelompok_list'], array());
      foreach ($result as $value)
         $return[$value['idKelompok']][$value['id']] = $value;
      return $return;
   }
}
?>
