<?php

require_once("../config/configDB.php"); 
//productID='".$_GET['pid']."' and

$cid= $_GET['cid'];
$pid= $_GET['pid'];

$sql_gst=mysqli_query($conn,"SELECT * FROM product_master WHERE   id='".$pid."' ");
		$row_master_gst=mysqli_fetch_array($sql_gst,MYSQLI_ASSOC);

$result = mysqli_query($conn,"SELECT purchase_rate,sale_rate  FROM product_mapping_customer WHERE   customerID='".$cid."' and productID='".$pid."'   ");

$res = array(); 
		
while($row = mysqli_fetch_array($result)){

	
	if($row['sale_rate']==0)
	{
		//$row['sale_rate']  = number_format(($row['purchase_rate']*100/118),2,'.','');
		$row['sale_rate']  = number_format(($row['purchase_rate']),2,'.','');
	}


	array_push($res, array(
		"purchase_rate"=>($row['purchase_rate']),
		//"sale_rate"=>number_format(($row['sale_rate']*100/118),2,'.',''),
		"sale_rate"=>number_format(($row['sale_rate']),2,'.',''),
		"gst"=>$row_master_gst['gst']
        	) 
 		);
 	}
 	echo json_encode($res);

//echo "tesing".$_GET['key'];




?>