<?php 
	class DataGrup extends mysql{

		function delete_detil_grup($id){
			  $sql = "delete from tbdetilgrup where id ='".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_temp_id($id){
			  $sql = "DELETE FROM tempgrup WHERE id = '".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}
				
		function delete_temp($id){
			  $sql = "DELETE FROM tempgrup WHERE idSession = '".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}

		function add_detil_grup($idMaster, $idTemplate){
			  $sql = "INSERT INTO tbdetilgrup (idGrup, idTemplate) values ('".$idMaster."', '".$idTemplate."')";
			  $this->query = $this-> execute($sql,''); 
		}

		function get_last_trans($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbgrup";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_detil($kolom,$a,$type, $ids){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.id, tb1.idGrup, tb1.idTemplate, tb2.NamaTRX, tb2.BiayaReguler, tb2.BiayaNonReguler, tb2.NamaBendahara, tb2.idBendahara from tbdetilgrup tb1 INNER JOIN  tbtemplatetransaksi tb2 on tb1.idTemplate = tb2.NoID WHERE tb1.idGrup ='".$ids."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_temp($kolom,$a,$type, $ids){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "SELECT * FROM tempgrup WHERE IdSession ='".$ids."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_grup_all($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "SELECT * FROM tbgrup ";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_detil_grup_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select tb1.id, tb1.idGrup, tb1.idTemplate, tb2.NamaTRX, tb2.BiayaReguler, tb2.BiayaNonReguler, tb2.NamaBendahara, tb2.idBendahara from tbdetilgrup tb1 INNER JOIN  tbtemplatetransaksi tb2 on tb1.idTemplate = tb2.NoID WHERE tb1.idGrup ='".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_grup_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "SELECT * FROM tbgrup WHERE idGrup ='".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function edit_grup($id, $Nama){
			  $sql = "update tbgrup set Des = '".$Nama."' where idGrup = '".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_temp($idSession, $NoId, $namaTrx, $Biaya){
			  $sql = "INSERT INTO tempgrup (IdSession, idTemplate, Nama, Biaya) values ('".$idSession."','".$NoId."', '".$namaTrx."', '".$Biaya."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_grup_detil($idGrup, $idTrx){
			  $sql = "INSERT INTO tbdetilgrup (idGrup, idTemplate) values ('".$idGrup."','".$idTrx."')";
			  echo $sql;
			  $this->query = $this-> execute($sql,''); 
		}
		function add_grup($Id, $Nama){
			  $sql = "INSERT INTO tbgrup (idGrup, Des) values ('".$Id."','".$Nama."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_grup($id){
			  $sql = "update tbtemplatetransaksi set IsAktif ='0' where NoID ='".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}
		
		
	}
?>