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

	$quantitys = $_REQUEST['quantity'];
	$from_location = $_REQUEST['from_location'];
		$loc_name=mysqli_fetch_array(mysqli_query($con,"select * from location_master where id='$from_location'"));
		$loc_names=$loc_name['location'];
	$item_search = $_REQUEST['item_search'];
	$fdivision = $_REQUEST['fdivision'];
	
		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='$loc_names' and division='$fdivision' 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='$loc_names' and division='$fdivision' and category_description='$str2' and category='$str1' and status=0")); 
	// echo "SELECT * FROM item_master WHERE location='$loc_names' and division='$fdivision' and category_description='$str2' and category='$str1' and status=0";
		$data = $sql['quantity'];
		if($data >= $quantitys)
		{
			echo 0;
		}
		else
		{
			echo 1;
		}
}
else
{
	echo 2;
}
?>