<?php 
	class dataInventaris extends mysql{
		function get_ruangan($kolom,$idruangan){
			if($this->cek_result != "on"){
			$sql = "select * from tbruangan where idruangan='".$idruangan."'";
			//echo $sql;
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function get_barang($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select * from tbinventori where id='".$id."'";
			//echo $sql;
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
			
		function get_data_ruangan($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbruangan";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_data_ruangan_lantai($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbruangan group by lantai ";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_data_ruangan_lantai_order($kolom,$a,$type, $lantai){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbruangan where lantai = '".$lantai."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_data_barang($kolom,$a,$type, $idruangan){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbinventori where idruangan = '".$idruangan."'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		
		function add_ruangan($ruangan, $lantai, $gedung){
		    $sql = "insert into tbruangan (ruangan, lantai, gedung) VALUES ('".$ruangan."', '".$lantai."', '".$gedung."')";
		    $this->query = $this-> execute($sql,''); 
		}
		function edit_ruangan($idruangan, $ruangan, $lantai, $gedung){
		    $sql = "update tbruangan set ruangan = '".$ruangan."', lantai = '".$lantai."', gedung = '".$gedung."' where idruangan = '".$idruangan."'";
		    $this->query = $this-> execute($sql,''); 
		}
		function add_barang($barang, $idruangan, $merk, $noseri, $tahun, $kodebarang, $jumlah, $baik, $kurang, $rusak, $keterangan){
		    $sql = "insert into tbinventori (barang, idruangan, merk, noseri, tahun, kodebarang, jumlah, baik, kurang, rusak, keterangan) values ('".$barang."', '".$idruangan."', '".$merk."', '".$noseri."', '".$tahun."', '".$kodebarang."', '".$jumlah."', '".$baik."', '".$kurang."', '".$rusak."', '".$keterangan."') ";
		    $this->query = $this-> execute($sql,''); 
		}
		function edit_barang($id, $barang, $merk, $noseri, $tahun, $kodebarang, $jumlah, $baik, $kurang, $rusak, $keterangan){
		    $sql = "update tbinventori set barang = '".$barang."', merk = '".$merk."', noseri = '".$noseri."', tahun = '".$tahun."', kodebarang = '".$kodebarang."', jumlah = '".$jumlah."', baik = '".$baik."', kurang = '".$kurang."', rusak = '".$rusak."', keterangan = '".$keterangan."' where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
		function delete_barang($id){
		    $sql = "delete from tbinventori where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
		function delete_ruangan($id){
		    $sql = "delete from tbruangan where idruangan = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
				
	}
?>