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

    $master_vendor       = combine(getAllRecords('vendor_master'), 'id', 'name');
    $vendor_name       = @$master_vendor[$_POST['vendor_id']];
  
    $billing = "SELECT `lr_from`,`lr_to`,`bill_date`,`invoice_no`,`net_amt` FROM `billing` WHERE  `vendor_id` = '".$vendor_id."' AND `branch_id` = '".$_SESSION['branch_id']."' AND `company_id` = '".$_SESSION['company_id']."' AND `invoice_no` like '%$search%' ";

    $bill_res = mysqli_query($conn,$billing);
    $response  = array();
    while($billl_row = mysqli_fetch_assoc($bill_res) ){

        $temp        = array();
        $temp['invoice_no']  = $billl_row['invoice_no'];
        $temp['bill_date']      = risFormatDate($billl_row['bill_date']); 
        $temp['bill_from']  = $billl_row['lr_from'];
        $temp['bill_to']  = $billl_row['lr_to'];
        $temp['bill_net_amount']  = $billl_row['net_amt'];
        $response[]          = $temp;
    }

  
    echo json_encode($response);
}
exit;
