<?php

class Popup extends Database {

	protected $mSqlFile= 'module/kodefikasi_barang_perencanaan/business/PopupBidang.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
	}
		
	function GetData($offset, $limit, $gol='', $nama='') {
      if($gol == 'all' || $gol == 0) {
         $str_gol = 0;
			$sql = str_replace("%OPERATOR%", "OR", $this->mSqlQueries['get_data']);
      } else {
         $str_gol = $gol;
			$sql = str_replace("%OPERATOR%", "AND", $this->mSqlQueries['get_data']);
      }
      
      $result = $this->Open($sql, array($str_gol, '%'.$nama.'%', '%'.$nama.'%', $offset, $limit));
      return $result;
	}

	function GetCountData($gol='', $nama='') {
      if($gol == 'all' || $gol == 0) {
         $str_gol = 0;
			$sql = str_replace("%OPERATOR%", "OR", $this->mSqlQueries['get_count_data']);
      } else {
         $str_gol = $gol;
			$sql = str_replace("%OPERATOR%", "AND", $this->mSqlQueries['get_count_data']);
      }
      
      $result = $this->Open($sql, array($str_gol, '%'.$nama.'%', '%'.$nama.'%', $offset, $limit));
      if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}

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

	function GetComboGolongan() {
		$result = $this->Open($this->mSqlQueries['get_combo_golongan'], array());
		return $result;
	}
	
	function GetGolonganList(){
      $result = $this->Open($this->mSqlQueries['get_golongan_list'], array());
      return $result;
	}
}
?>
