<?php

class JenisPenggunaanRuang extends Database {

	protected $mSqlFile= 'module/jenis_penggunaan_ruang/business/jenispenggunaanruang.sql.php';
	
	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
		
		
	}
		
	function GetDataJenis($offset, $limit, $jenis='') {
		return $this->Open($this->mSqlQueries['get_data_jenis'], array('%'.$jenis.'%', $offset, $limit));
	}

	function GetCountDataJenis($jenis) {
		$result = $this->Open($this->mSqlQueries['get_count_data_jenis'], array('%'.$jenis.'%'));
		if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
	}

	function GetCount(){
		$result = $this->Open($this->mSqlQueries['get_count'],array());
		return $result[0]['total'];
	}
	
	function GetDataJenisById($jenisId) {
		$result = $this->Open($this->mSqlQueries['get_data_jenis_by_id'], array($jenisId));
		return $result;
	}

	function GetDataJenisByArrayId($arrJenisId) {
		$jenisId = implode("', '", $arrJenisId);
		$result = $this->Open($this->mSqlQueries['get_data_jenis_by_array_id'], array($jenisId));
		return $result;
	}
		
	//===DO==
	function DoAddJenis($jenisKode,$jenisNama,$jenisStatus) {
	 
		if($jenisStatus==""){	   
			$jenisStatus = "T";
		} elseif ($jenisStatus="Y") {
			$result = $this->Execute($this->mSqlQueries['do_deaktif'],array());
		}
	 
		$result = $this->Execute($this->mSqlQueries['do_add_jenis'], array($jenisKode,$jenisNama,$jenisStatus));
	//echo $this->GetLastError();	
		return $result;
	}
	
	function DoUpdateJenis($jenisKode,$jenisNama,$jenisStatus,$jenisId) {
		 
		if($jenisStatus==""){	   
			$jenisStatus="T";
		} elseif($jenisStatus="Y"){
			$result= $this->Execute($this->mSqlQueries['do_deaktif'],array());
		}
		
		$result = $this->Execute($this->mSqlQueries['do_update_jenis'], array($jenisKode,$jenisNama,$jenisStatus, $jenisId));
	//echo $this->GetLastError();exit;
		return $result;
	}
	
	function DoDeleteJenisById($jenisId) {
		$result = $this->Execute($this->mSqlQueries['do_delete_jenis_by_id'], array($jenisId));
		return $result;
	}

	function DoDeleteJenisByArrayId($arrJenisId) {
		$jenisId = implode("', '", $arrJenisId);
		$result	= $this->Execute($this->mSqlQueries['do_delete_jenis_by_array_id'], array($jenisId));
		return $result;
	}
}
?>
