<?php
class BiayaSewa extends Database
{
   protected $mSqlFile;
   function __construct($connectionNumber = 0)
   {
      $this->mSqlFile = 'module/biaya_sewa_ruang/business/biaya_sewa.sql.php';
      parent::__construct($connectionNumber);
			
   }

   function GetCount(){
   		$result = $this->Open($this->mSqlQueries['get_count'],array());
   		return $result[0]['total'];
   }
   
   function GetUnitKodeSistemByUserId(){
   	$userId = Security::Instance()->mAuthentication->GetCurrentUser()->GetUserId();
   	$result = $this->Open($this->mSqlQueries['get_unit_kode_sistem_by_user_id'],array($userId));
   	return $result[0]['unitkerjaKodeSistem'];
   }
   
	public function GetDataRuangSewaCount($label='', $kode='')
   {
      $result = $this->Open($this->mSqlQueries['get_data_ruang_sewa_count'], array('%'.$label.'%', '%'.$kode.'%'));
      if (is_array($result))
         return $result[0]['total'];
      else return 0;
   }
	
   	# multiunit
	public function GetDataRuangSewa($label='', $kode='', $start, $limit)
	{
		$kodeSistem = $this->GetUnitKodeSistemByUserId();
		$result = $this->Open($this->mSqlQueries['get_data_ruang_sewa'], array('%'.$label.'%', '%'.$kode.'%', $kodeSistem,$kodeSistem.'.%',$start, $limit));
		return $result;
	}
	
	public function GetDataBiayaSewaRuangCount($kode='', $label='')
   {
      $result = $this->Open($this->mSqlQueries['get_data_biaya_sewa_aset_count'], array('%'.$kode.'%', '%'.$label.'%'));
      if (is_array($result))
         return $result[0]['total'];
      else return 0;
   }
	
   	# multiunit
	public function GetDataBiayaSewaRuang($kode='', $label='', $start, $limit)
	{
		$kodeSistem = $this->GetUnitKodeSistemByUserId();
		$result = $this->Open($this->mSqlQueries['get_data_biaya_sewa_aset'], array('%'.$kode.'%', '%'.$label.'%', $kodeSistem,$kodeSistem.'.%',$start, $limit));
		return $result;
	}
	
	public function GetDataBiayaSewaRuangById($biayaSewaId)
	{
		$result = $this->Open($this->mSqlQueries['get_data_biaya_sewa_ruang_by_id'], array($biayaSewaId));
		return $result[0];
	}
	
	public function DoDeleteBiayaSewaRuangByArrayId($arrSewaId) {
		$sewaId = implode("', '", $arrSewaId);
		$result=$this->Execute($this->mSqlQueries['do_delete_biaya_sewa_ruang_by_array_id'], array($sewaId));
		return $result;
	}
	
	public function DoDeleteBiayaSewaRuangById($arrId) {
		$result=$this->Execute($this->mSqlQueries['do_delete_biaya_sewa_ruang_by_id'], array($arrId));
		
		return $result;
	}
	
	public function DoAddBiayaSewaRuang($label_id, $kode, $biaya, $status, $idUser)
	{
		$result = $this->Execute($this->mSqlQueries['do_add_biaya_sewa_ruang'], array($status, $label_id, $kode, $biaya, $idUser));
		return $result;
	}
	
	public function DoUpdateBiayaSewaRuang($label_id, $kode, $biaya, $status, $idUser, $Id)
	{
		$result = $this->Execute($this->mSqlQueries['do_update_biaya_sewa_ruang'], array($status, $label_id, $kode, $biaya, $idUser, $Id));
		return $result;
	}
}
?>