<?php

 include("includes/dbconfig.php");

 
 
if(isset($_POST['comand'])){
	if( $_POST['comand'] ==1 || $_POST['comand'] ==2 ){
		 ?>
	<form onsubmit ="return Finish_adjust();" >
	<div class="col-md-3">
	<?php 
	if( $_POST['comand'] ==1   ){
		echo '<h4>Add on stock </h4>';
	    }else echo '<h4>Reduce on stock</h4>';
		 ?>
		 </div>
	<input type ="hidden"   id ="command"  value = "<?php echo $_POST['comand'];?>" class ="form" />
	<input type ="hidden"   id ="id"  value ="<?php echo $_POST['dataSend'];?>" class="form-control"  />
	
 
		 
						<div class="col-md-3">
							<input type ="number"   id ="adjust"  placeholder="Customer" class="form-control"   />
						</div>
						<div class="col-md-3">
							<input type="submit" value="Search" class="form-control btn btn-info"   />
						</div>
					</div>
					<br />
					 
	</form>
	<?php
	}else 	if( $_POST['comand'] ==3 ){
		 
		$data =  $_POST['dataSend'];
		$action  =$data[0]; 
		$item  =$data[1]; 
		$number  =$data[2];//$pricedata = DB::query("SELECT item_stock_level.id, 
		$pricedata = DB::query('SELECT quantity FROM item_stock_level WHERE id ='.$item.''); 
		if(DB::count() == 0){
			exit('Item not found');
		}
		ELSE {
			$quantity =  $pricedata[0]['quantity'] + $number ;
			 
			DB::query('UPDATE item_stock_level SET quantity = '.$quantity.' WHERE id  = '.$item.'');
			echo 'Operation was sucessfull';
		}
		 
	}
}
 



?>