<?php

class JenisKdp extends Database {

   protected $mSqlFile = 'module/kdp_ref_jenis_kdp/business/jenis_kdp.sql.php';
   //private $userId = Security::Instance()->mAuthentication->GetCurrentUser()->GetUserId();

   function __construct($connectionNumber=0) {
	 $this->userId=Security::Instance()->mAuthentication->GetCurrentUser()->GetUserId();
      parent::__construct($connectionNumber);
      //$this->SetDebugOn();
   }
//==GET==
   function GetData($offset, $limit, $kode, $nama) {
      $result = $this->Open($this->mSqlQueries['get_data'], array('%'.$kode.'%',
                                                                  '%'.$nama.'%',
																  $offset,$limit));
	  return $result;
   }


	function GetCountJenisKdp($kode,$nama){

		$result = $this->Open($this->mSqlQueries['get_count'], array('%'.$kode.'%','%'.$nama.'%'));
		return $result[0]['total'];
	}


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

	function DoAddJenisKdp($kode,$nama){
	   $result = $this->Execute($this->mSqlQueries['do_add_jenis_kdp'],array($kode,$nama,$this->userId));
	   return $result;
	}

	function DoUpdateJenisKdp($kode,$nama,$kodeasli){
		$result = $this->Execute($this->mSqlQueries['do_update_jenis_kdp'],array($kode,$nama,$kodeasli));
		return $result;
	}

	function DoDeleteSatuan($id) {
	   $ret = $this->Execute($this->mSqlQueries['do_delete_satuan'], array($id));
       return $ret;
	}

	function DoDeleteBanyak($arrayId){
		$arrayId = implode("', '", $arrayId);
		$result = $this->Execute($this->mSqlQueries['do_delete_banyak'], array($arrayId));
		return $result;
	}

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



}
?>
