<?php

class ExpenseCategorySetup {

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


	public static function GetExpenseCategorySetupById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_EXPENSECATEGORYSETUP." 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 CheckExpenseCategory($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_EXPENSECATEGORYSETUP." 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 GetExpenseCategorySetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT *, ".TABLE_EXPENSECATEGORYSETUP.".name AS catname, ".TABLE_EXPENSECATEGORYSETUP.".id AS catid from ".TABLE_EXPENSECATEGORYSETUP." ". $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(); }
		
	
}

?>
