<?php

class Stock {

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

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


	public static function GetStockSetupById($id) {
	
		global $db;
		$query = "SELECT * from ".TABLE_STOCK." WHERE id ='$id'";
		//print($query);exit;
		$rows = $db->query_first($query);
	
                if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//Stock
	
	/**********************************************************
	/ This function will return StockSetup
	**********************************************************/
		
	public static function GetStockSetupList($filter="",$pageno="null",$pagesize="null") {
	
		global $db;
		$query = "SELECT * from ".TABLE_STOCK." ". $filter;
		//print($query);exit;
		$rows = $db->fetch_all_array($query,$pageno,$pagesize);
	
			if($db->affected_rows > 0){
			
                        return $rows;
                }else{
			
                        return false;
                }
	}//StockSetup

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

?>
