<?php

class PurchaseCategorySetup {

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

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


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


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

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

?>
