<?php

class ExpenseMartSetup {

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

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


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


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

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

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

		if($db->affected_rows > 0){

			return $rows;
		}else{

			return false;
		}
	}//ExpenseMartSetupSetup


	/**********************************************************
	/ This function will delete the Expense Mart
	 **********************************************************/

	public static function DeleteExpenseMartSetup($id) {
		global $db;
		$query = "Delete from " . TABLE_EXPENSE_MART . "  WHERE id='$id'";
		$rows = $db->query_first($query);
		if($db->affected_rows > 0){
			return true;
		}else{
			return false;
		}
	}//DeleteExpenseMart

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

?>
