<?php

class BatchSetup {

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

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


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


	public static function CheckBatchAccount($name, $id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_BATCHSETUP." WHERE name ='$name' && id <> '$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Batch
	
	/**********************************************************
	/ This function will return BatchSetup
	**********************************************************/
		
	public static function GetBatchSetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_BATCHSETUP." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//BatchSetup

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

?>
