

<?php  
require_once("config/configDB.php"); 
require "financial_year_calculation.php";
$accountyear    = $financialYearStart."-".$financialYearEnd;

if(!isset($_SESSION))  { session_start(); }
if(isset($_POST["query"]))  
 {  
	if($_POST["query"]!=""){
      $output = '';  
	  $pono = $_POST["query"];
      $query = "SELECT * FROM poheader WHERE po_num='$pono' and status='' ";  
      $exec = mysqli_query($conn,$query) or die ("Error in Query".mysqli_error());
      $row = mysqli_fetch_array($exec);
	  $customer_id = $row['customer_id'];
	  $location = $row['location'];
	  $del_address = trim($row['del_address']);
	  $billing_address = trim($row['billing_address']);
	  
	  $query_cus = "SELECT * FROM customer_master WHERE id='$customer_id' ";  
      $exec_cus = mysqli_query($conn,$query_cus) or die ("Error in Query".mysqli_error());
      $row_cus = mysqli_fetch_array($exec_cus);

	 $cname=$row_cus['cname'];
	 $vendor=$row_cus['vendor'];
	 $caddress=$row_cus['caddress'].','.$row_cus['customer_state'].'-'.$row_cus['pincode'];
	 $product_list = [];
	 $row_product = mysqli_query($conn,"SELECT productId from podetails where po_num = '$pono' and status=''");
	 while($product_data = mysqli_fetch_array($row_product)){
		$product_id = $product_data['productId'];
		$product_name_data = mysqli_query($conn,"SELECT productname from product_master where productcode = '$product_id'");
		$pro_name = mysqli_fetch_assoc($product_name_data)['productname'];
		$product_list[]= (object)['productId'=>$product_data['productId'],'productName'=>$product_data['productId']];
	 }
		$product_data_output = json_encode($product_list);
		//echo $product_data_output;
		
 $output = $customer_id.'||'.$location.'||'.$del_address.'||'.$cname.'||'.$billing_address.'||'.$product_data_output.'||'.$vendor;
	}  
 }
echo $output;  
 ?>  

