<?php

class PurchaseSetup {

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


	public static function GetPurchaseSetupById($id) {
		global $db;
		$query = "SELECT * from ".TABLE_PURCHASE." 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 CheckPurchase($name, $id) {
		global $db;
		$query = "SELECT * from ".TABLE_PURCHASE." 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 GetPurchaseSetupList($filter="",$pageno="null",$pagesize="null") {

		global $db;
		$query = "SELECT * from ".TABLE_PURCHASE." ". $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(); }
		
	
}

?>
