<?php

class AppGedungAkademik extends Database {

	protected $mSqlFile= 'module/gedung/business/app_gedung_akakademik.sql.php';
	
	public function __construct($connectionNumber=2) {
		parent::__construct($connectionNumber);
	}
	
	public function CheckIdLab($ids){
      $result = $this->Open($this->mSqlQueries['check_id_lab'], array($ids));
		return $result;
	}
	
	public function ComboboxProdi(){      
      $result = $this->Open($this->mSqlQueries['combobox_program_studi'], array());
		return $result;
	}
	
	public function GetIdProdi($idGedung){
      $result = $this->Open($this->mSqlQueries['get_id_gedung'], array($idGedung));
		return $result[0];
	}
	
	public function addEgedung($data){
		extract($data);
		$arg = array
      (
			$gdId,
			$gdKode,
			$gdNama
      );
      
      $result = $this->Execute($this->mSqlQueries['add_e_gedung'], $arg);
		return $result;
	}
	
	public function updateEgedung($data){
		extract($data);
		$arg = array
      (
			$gedung_kode,
			$gedung_nama,
			$gedung_id
      );
      $result = $this->Execute($this->mSqlQueries['update_e_gedung'], $arg);
		return $result;
	}
	
	public function addElaboratorium($data){
		extract($data);
		$arg = array
      (
			$ruId
      );
      $result = $this->Execute($this->mSqlQueries['add_e_laboratorium'], $arg);
		return $result;
	}
	
	public function addEruang($data){
		extract($data);
		$arg = array
      (
			$ruId,
			$ruKode,
			$ruNama,
			$ruGdId,
			$ruKapasitas,
			$ruGruId,
			$ruIsKuliah,
			$ruIsLayakPakai,
			$ruLuas
      );
      
      $result = $this->Execute($this->mSqlQueries['add_e_ruang'], $arg);
		return $result;
	}
	
	public function updateEruang($ids, $data){
		extract($data);
		$arg = array
      (
			$kode,
			$nama,
			$kapasitas,
			$jnsRuangId,
			$tipeRuangId,
			$kondisiRuangId,
			$luas,
			$ids
      );
      $result = $this->Execute($this->mSqlQueries['update_e_ruang'], $arg);
		return $result;
	}
	
	public function deleteElaboratorium($id){
		$arg = array
      (
			$id
      );
      $result = $this->Execute($this->mSqlQueries['delete_e_laboratorium'], $arg);
		return $result;
	}
	
	function deleteEgedung($arrayId)
   {
      $query = implode(", ", array_fill(0, count($arrayId), '%d'));
      $query = str_replace('%REPLACE%', $query, $this->mSqlQueries['delete_e_gedung']);
		
      $result = $this->Execute($query, $arrayId);
      if (!$result) return 1;
      else return 0;
   }
	
	function deleteEruang($arrayId)
   {
      $query = implode(", ", array_fill(0, count($arrayId), '%d'));
      $query = str_replace('%REPLACE%', $query, $this->mSqlQueries['delete_e_ruang']);

      $result = $this->Execute($query, $arrayId);
      if (!$result) return 1;
      else return 0;
   }
}
?>
