<?php

class IngSetup {

	/*************************************************
	/ This function add new Ing Setup
	*************************************************/
	
	public static function AddIngSetup($data) {
		global $db;
				
		$id = $db->query_insert(TABLE_INGSETUP, $data);
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			return $id;
		}else{
			return false;
		}
	
	} // AddIng

	/*************************************************
	/ This function update Ing
	*************************************************/
	
	public static function UpdateIngSetup($pid,$data) {
		global $db;
				
		$id = $db->query_update(TABLE_INGSETUP,$data,"id='$pid'");
		
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			
			return $id;
		}else{
			return $id;
		}
	
	} // UpdateIng


	public static function GetIngSetupById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_INGSETUP." WHERE id ='$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Ing

	public static function GetIngSetupByIngCode($pcode) {
	
		global $db;
		$query = "SELECT * from ".TABLE_INGSETUP." WHERE code LIKE '$pcode%'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Ing


	public static function CheckIng($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_INGSETUP." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Ing
	
	/**********************************************************
	/ This function will return IngSetup
	**********************************************************/
		
	public static function GetIngSetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_INGSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//IngSetup

	public static function GetNumRows() { global $db; return $db->GetNumRows(); }
	public static function GetNumberOfPages() { global $db; return $db->GetNumberOfPages(); }
		
	
}

?>
