<?php require ('my_functions.php');
		
		 
	
	if(isset($_POST['id'])){
			  $id = trim($_POST['id']); 
             $item = trim($_POST['item']); 
             $shop = trim($_POST['shop']);  
			?>
			 <div class="col-md-12 col-sm-12 col-xs-12" id ='flash'>
			
			 <div class="col-md-6 col-sm-6 col-xs-6">
			<input type='hidden' class='form ' id ='item_id' name ='item_id'  value="<?php  echo $item;?>"  />
			<input type='hidden' class='form ' name ='shop_id' id ='shop_id' value="<?php  echo $shop;?>"  />
			<input type='hidden' class='form ' name ='specific_id' id ='specific_id' value="<?php  echo $id;?>" />
			<input type='number' class="form form-control col-md-6"  name ='quantity' id ='quantity'   />
			<button onclick ='return complete_recall();' class='btb btn-info form form-control'> Button </button> 
			</div>
			</div>
			 

			<?php			
			 
	}
	
		if(isset($_POST['specific_id'])){
			 echo  $id = trim($_POST['specific_id']); 
              $quantity = trim($_POST['quantity']); 
			  $shop_id = trim($_POST['shop_id']);
			  $item     = trim($_POST['item_id']);
			  if($quantity > 0){
				  echo  time();
			    Recal_items( $id, $quantity);
			   //Change_quantity(  $quantity , $item, $_SESSION["connecteduserid"] , $shop_id);
			  }else echo 'Please enter a value or zero 0';

			
            			
			 
	}
	//stock_item_movement
	
	function Change_quantity(  $quantity , $item, $user , $shop){
		 
			$s = DB::query('UPDATE item_stock_level SET updated_date = current_timestamp(), updated_by = '.$user.', quantity = ' . $quantity . ' WHERE   shop ='.$shop.'   AND  item ='.$item.''  );
		
		 
	}
	
									
							
											  
	function Recal_items( $id,  $no){
		 
		DB::query('UPDATE stock_item_movement SET quantity='.$no.' WHERE id ='.$id.' ');
			
		 
	} 
									
									
?>