<?php
include("../connection.php");
include("../user.php");
$branch=$_SESSION['division_name'];

	$quantitys = $_REQUEST['quantity'];
	$from_location = $_REQUEST['from_location'];
	$item_search = $_REQUEST['item_search'];
	
		list($a, $b) = explode('/',$item_search);
		
		$str1 = str_replace(' ','',$a); // Remove Whitespaces in string
		$str2 = ltrim($b); // Remove first Whitespaces in string
 
$check_status=mysqli_query($con,"SELECT * FROM item_master WHERE category='$str1' and category_description='$str2' and location='$from_location' and division='$branch' and status=0");

$counts_row=mysqli_num_rows($check_status);
	
if($counts_row)
{
$sql=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM item_master WHERE location='$from_location' and division='$branch' and category_description='$str2' and category='$str1' and status=0")); 
	 
		$data = $sql['quantity'];
		if($data >= $quantitys)
		{
			echo 0;
		}
		else
		{
			echo 1;
		}
}
else
{
	echo 2;
}
?>