<?php
class AppKdp extends Database {

   protected $mSqlFile= 'module/laporan_kdp/business/laporan_kdp.sql.php';
   
   function __construct($connectionNumber=0) {
      parent::__construct($connectionNumber);
      #$this->setDebugOn();
   }
   
	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 GetCbxJenisKib() {
      $result = $this->Open($this->mSqlQueries['get_combo_jenis_kib'], array());
      foreach (array_keys($result) as $key)
      {
			if($result[$key]['kode'] == 'g') 
			$return[] = $result[$key];
		}
      return $return;
   }
	
	function GetComboUnit(){
		$User = $this->GetDataUserByUsername($_SESSION['username']);		
		$array = array(
			$User['unitkerjaId'], $User['unitkerjaId'], $User['role_id']
		);
		return $this->Open($this->mSqlQueries['get_combo_unit'], $array);
	}
	
	function GetListKdpOld($data){
		$tahun = $data['tahun'];
		$tahunAwal = $tahun - 1;

      $result = $this->Open(
			$this->mSqlQueries['get_list_kdp'],
				array(
					$tahunAwal, $tahunAwal,
					$tahun
				)
			);
			
		return $result;
	}
	
	function GetListKdp($data){
		$tahun = $data['tahun'];
		$tahunAwal = $data['tahunAwal'];
	
		$result = $this->Open(
				$this->mSqlQueries['get_list_kdp'],
				array(
						$tahunAwal, 
						$tahunAwal,$tahun,
						$tahunAwal,$tahun
				)
		);
			
		return $result;
	}
}
?>
