<?php

class IngredientCategorySetup {

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

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


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


	public static function CheckIngredientCategory($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_INGREDIENTCATEGORYSETUP." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//IngredientSetupSetup
	
	/**********************************************************
	/ This function will return IngredientSetupSetup
	**********************************************************/
		
	public static function GetIngredientCategorySetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT *, ".TABLE_INGREDIENTCATEGORYSETUP.".name AS catname, ".TABLE_INGREDIENTCATEGORYSETUP.".id AS catid from ".TABLE_INGREDIENTCATEGORYSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//IngredientSetupSetup

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

?>
