
<?php  
require_once("config/configDB.php"); 
require "userPermission.php";
if(isset($_POST["query"]))  
 {  
	if($_POST["query"]!=""){
      $output = '';  
	  $rm_number = $_POST["query"];
	  $customer_id = $_POST["customer_id"];
	  
	  
      $query = "SELECT * FROM product_master  WHERE id='$rm_number' ";
      $exec = mysqli_query($conn,$query) or die ("Error in Query".mysqli_error());
      $row = mysqli_fetch_array($exec);
	 
	   $qty_type = $row['qty_type'];
	  $gst = $row['gst'];
	  $productname = $row['productname'];
	  
	  
	  
$query1 = "SELECT * FROM customer_master  WHERE id='$customer_id' ";
      $exec1 = mysqli_query($conn,$query1) or die ("Error in Query".mysqli_error());
      $row1 = mysqli_fetch_array($exec1);
	  $sname = $row1['cname'];
	  
$query2 = "SELECT * FROM product_mapping_customer  WHERE productID='$rm_number' and customerID='$customer_id' ";
      $exec2 = mysqli_query($conn,$query2) or die ("Error in Query".mysqli_error());
      $row2 = mysqli_fetch_array($exec2);
	  $sale_rate = $row2['sale_rate'];
	  
	  if($sale_rate==0.00)
	  {
		  $sale_rate = $row2['purchase_rate'];
	  }
	  else
	  {
$sale_rate = $row2['sale_rate'];
	  }
   		
		
		
      $output = $qty_type.'||'.$sale_rate.'||'.$gst.'||'.$sname.'||'.$productname.'||';
	}  
 }
echo $output;  
 ?>  

 