<?php

class CustomerCategorySetup {

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

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


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


	public static function CheckCustomerCategory($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_CUSTOMERCATEGORYSETUP." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//CustomerSetupSetup
	
	/**********************************************************
	/ This function will return CustomerSetupSetup
	**********************************************************/
		
	public static function GetCustomerCategorySetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT *, ".TABLE_CUSTOMERCATEGORYSETUP.".name AS catname, ".TABLE_CUSTOMERCATEGORYSETUP.".id AS catid from ".TABLE_CUSTOMERCATEGORYSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//CustomerSetupSetup

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

?>
