<?php 
	include("../config.php");
	$lr_no    = $_POST['lr_no'];
	$vendor   = $_POST['vendor'];

	$nor     = "SELECT * FROM `billing` WHERE (consignor_name = '".$vendor_id."' OR consignee_name = '".$vendor_id."' OR billing_to = '".$vendor_id."') AND (billing_party = 'CONSIGNOR' OR billing_party = 'CONSIGNEE' OR billing_party = 'TRANSPORTER' OR billing_party = 'OTHER' OR billing_party = 'TO PAY') AND branch_id = '".$_SESSION['branch_id']."' AND company_id = '".$_SESSION['company_id']."'";
	$nor_res = mysqli_query($conn,$nor);
	$nor_row = mysqli_fetch_array($nor_res);
	
	if($nor_row['billing_party'] == 'CONSIGNOR' || $nor_row['billing_party'] == 'CONSIGNEE' || $nor_row['billing_party'] == 'TRANSPORTER' || $nor_row['billing_party'] == 'OTHER' || $nor_row['billing_party'] == 'TO PAY'){
		$select  = "SELECT * FROM `billing` WHERE (consignor_name = '".$vendor_id."' OR consignee_name = '".$vendor_id."' OR billing_to = '".$vendor_id."') AND lr_no = '".$lr_no."' AND (billing_party = 'CONSIGNOR' OR billing_party = 'CONSIGNEE' OR billing_party = 'TRANSPORTER' OR billing_party = 'OTHER' OR billing_party = 'TO PAY') AND branch_id = '".$_SESSION['branch_id']."' AND company_id = '".$_SESSION['company_id']."'";
	}
	$result  = mysqli_query($conn,$select);
	$num_row = mysqli_num_rows($result);
	if($num_row >= 0 ) {
		$data = array('status' => 1);
	} else {
		$data = array('status' => 0);
	}

	echo json_encode($data);
	die();
?>