<?php
class Pengadaan extends Database
{

	protected $mSqlFile;
   public $mFilePath = 'file/';

	function __construct($connectionNumber=0)
   {
      $this->mSqlFile = 'module/'.Dispatcher::Instance()->mModule.'/business/Pengadaan.sql.php';
		parent::__construct($connectionNumber);

	}

   function GetComboTahun ($awal, $akhir, $isAsc = false)
   {
      $return = array();
      for ($i = $akhir; $i >= $awal; $i--)
         $return[$i]['name'] = $return[$i]['id'] = $i;
      if ($isAsc) ksort($return);
      return array_values($return);
   }

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

   function GetListPengadaanCount ($filter)
   {
      extract($filter);
      $filter = array
      (
         $pengadaanTahun, ("$pengadaanTahun" == 'all') ? 1 : 0,
         "%$pengadaanMAK%",
         $pengadaanSumberDanaId, ("$pengadaanSumberDanaId" == 'all') ? 1 : 0,
         "%$pengadaanDetLabel%",
         "%$pengadaanNoSPK%"
      );

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

   function GetListPengadaan ($filter, $start = 0, $limit = 1048576)
   {
      extract($filter);
      $filter = array
      (
         $pengadaanTahun, ("$pengadaanTahun" == 'all') ? 1 : 0,
         "%$pengadaanMAK%",
         $pengadaanSumberDanaId, ("$pengadaanSumberDanaId" == 'all') ? 1 : 0,
         "%$pengadaanDetLabel%",
         "%$pengadaanNoSPK%",
         $start, $limit
      );
		$result = $this->Open($this->mSqlQueries['get_list_pengadaan'], $filter);
      return $result;
   }
}
?>