<?php 
include "../config.php";
if(isset($_POST['search'])){
    $search    = $_POST['search'];
    $vendor_id = $_POST['vendor_id'];

    $no     = "SELECT  `id`,`lr_no`,`l_date`,`party_invoice`,`party_amount`,`truck_no`,`from_place`,`to_place`,
              `consignor_name`,`consignee_name`,`billing_to`,`agent`,`nature_of_goods`,`weight`,`actual_weight`
              ,`height`,`pcs`,`rate`,`gst_paid_by`,`billing_party`,
              `remark`,`rate_on`,`freight`,`per_date`,`act_rec_date`,`billing_status`,
              `company_id`,`branch_id`,`flag`,`billing_status`,`created_id`,`updated_id`,
              `updated_datetime`
              FROM `lr_mst` WHERE billing_to = '".$vendor_id."' AND billing_status = 'N' 
              AND lr_no like '%$search%' AND branch_id = '".$_SESSION['branch_id']."' 
              AND company_id = '".$_SESSION['company_id']."' GROUP BY lr_no
              union all
              SELECT  `id`,`lr_no`,`l_date`,`party_invoice`,`party_amount`,`truck_no`,`from_place`,`to_place`,
              `consignor_name`,`consignee_name`,`billing_to`,`agent`,`nature_of_goods`,`weight`,`actual_weight`
              ,`height`,`pcs`,`rate`,`gst_paid_by`,`billing_party`,
              `remark`,`rate_on`,`freight`,`per_date`,`act_rec_date`,`billing_status`,
              `company_id`,`branch_id`,`flag`,`billing_status`,`created_id`,`updated_id`,
              `updated_datetime`
              FROM `lr_opening` WHERE billing_to = '".$vendor_id."' AND billing_status = 'N' 
              AND lr_no like '%$search%' AND branch_id = '".$_SESSION['branch_id']."' 
              AND company_id = '".$_SESSION['company_id']."' GROUP BY lr_no"              

              ;
	$no_res = mysqli_query($conn,$no);
	while($no_row = mysqli_fetch_assoc($no_res) ){
   	 	$response[] = $no_row;
	}

	echo json_encode($response);
}
exit;