<?php

class ExpenseMartCategorySetup {

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


	public static function GetExpenseMartCategorySetupById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_EXPENSEMARTCATEGORYSETUP." 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 CheckExpenseMartCategory($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_EXPENSEMARTCATEGORYSETUP." 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 GetExpenseMartCategorySetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT *, ".TABLE_EXPENSEMARTCATEGORYSETUP.".name AS catname, ".TABLE_EXPENSEMARTCATEGORYSETUP.".id AS catid from ".TABLE_EXPENSEMARTCATEGORYSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//ExpenseMartSetupSetup

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

?>
