<?php

class PackagingCostSetup {

	/*************************************************
	/ This function add new Product Setup
	*************************************************/
	
	public static function AddPackagingCost($data) {
		global $db;
				
		$id = $db->query_insert(TABLE_PACKAGINGCOST, $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 UpdatePackagingCost($pid,$data) {
		global $db;
				
		$id = $db->query_update(TABLE_PACKAGINGCOST,$data,"id='$pid'");
		
		if($db->affected_rows > 0){
			//$db->query_insert("vrs_logs", $data);
			
			return $id;
		}else{
			return $id;
		}
	
	} // UpdateProduct


	public static function GetPackagingCostById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_PACKAGINGCOST." 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 GetPackagingCostByProductCode($pcode) {
	
		global $db;
		$query = "SELECT * from ".TABLE_PACKAGINGCOST." 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 CheckPackagingCost($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_PACKAGINGCOST." 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 GetPackagingCostList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_PACKAGINGCOST." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//PackagingCost

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

?>
