<?php

class CustomerSetup {

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


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

	public static function GetCustomerSetupByCode($pcode) {
	
		global $db;
		$query = "SELECT * from ".TABLE_CUSTOMERSETUP." WHERE code LIKE '$pcode%'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Customer


	public static function CheckCustomer($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_CUSTOMERSETUP." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Customer
	
	/**********************************************************
	/ This function will return CustomerSetup
	**********************************************************/
		
	public static function GetCustomerSetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_CUSTOMERSETUP." ". $filter." ORDER BY name ASC" ;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	//	echo $query;
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//CustomerSetup

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

?>
