
<?php  
error_reporting(0);
require_once("config/configDB.php"); 
require "userPermission.php";
if(isset($_POST["explosivename"]))  
 {  
	if($_POST["explosivename"]!=""){
     $output = '';  
	  $explosivename = $_POST["explosivename"];
	  $utilizedate = $_POST["utilizedate"];
	  
	$product=mysqli_query($conn,"select * from product_master where id='$explosivename'");
	
	//echo "select * frpm product_master where productname='$explosivename'";
	 
	 $rowm=mysqli_fetch_array($product);
	 $pid=$rowm['id'];
	 $pname=$rowm['productname'];
	 
	 $sqlpurchase = mysqli_query($conn,"select sum(purchase_eqty) as  purqty from purchasedetails where productID='$explosivename' and status=''  ");
	 
//	echo "select sum(purchase_eqty) as  purqty from purchasedetails where productID='$explosivename' and status='' ";


 $rowpurchase = mysqli_fetch_array($sqlpurchase);
 
 $explosive_purchaseqty=$rowpurchase['purqty'];
 
 //echo $explosive_purchaseqty;
 
  $sqlpurchasewo = mysqli_query($conn,"select sum(purchase_eqty) as  purqtywo from purchasedetailswo where productID='$explosivename' and status=''  ");
  
//  echo "select sum(purchase_eqty) as  purqtywo from purchasedetailswo where productID='$explosivename' and status=''  ";

 $rowpurchasewo = mysqli_fetch_array($sqlpurchasewo);
 
 $explosive_purchaseqtywo=$rowpurchasewo['purqtywo'];
	 // echo $explosive_purchaseqtywo;
	 
	 $availqty=$explosive_purchaseqty+$explosive_purchaseqtywo;
	 
	 //echo $availqty;
     
$sql = mysqli_query($conn,"select sum(qty) as  explosiveqty from explosive_utiliz_dtl where explosiveID='$explosivename' and status='' ");

 $row = mysqli_fetch_array($sql);



$explosive_qty=$availqty-$row['explosiveqty'];




   		


      $output = $explosive_qty.'||'.$pname.'||';
	}  
 }
echo $output;  
 ?>  

 