<?php

class ExpenseSetup {

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

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


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


	public static function CheckExpense($name, $id) {
		global $db;
		$query = "SELECT * from ".TABLE_EXPENSE." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
                if($db->affected_rows > 0){
                        return $rows;
                }else{
                        return false;
                }
	}//ExpenseSetupSetup
	
	/**********************************************************
	/ This function will return ExpenseSetupSetup
	**********************************************************/

	public static function GetExpenseSetupList($filter="",$pageno="null",$pagesize="null") {

		global $db;
		$query = "SELECT * from ".TABLE_EXPENSE." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//ExpenseSetupSetup

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

?>
