<?php

class ProductSetup {

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

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


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

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


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

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

?>
