<?php
include("../config.php");

$account_name = $_POST['account_name'];
$master_accounts = combine(getAllRecords('act_master'), 'id', 'party_code');
$party_code = @$master_accounts[$account_name];

$vendor = "SELECT * FROM `vendor_master` WHERE `code` = '$party_code'";
$vendor_res = mysqli_query($conn, $vendor);
$vendor_row = mysqli_fetch_assoc($vendor_res);

$select = "SELECT * FROM lr_mst WHERE (`consignor_name` = '".$vendor_row['id']."' OR `consignee_name` = '".$vendor_row['id']."') AND branch_id = '".$_SESSION['branch_id']."' AND company_id = '".$_SESSION['company_id']."'";
$result = mysqli_query($conn, $select);

if (mysqli_num_rows($result) > 0) {
    echo '<option value=""></option>';
    while ($row = mysqli_fetch_assoc($result)) {
        echo "<option value='{$row["lr_no"]}'>{$row["lr_no"]}</option>";
    }
}
?>