<?php
include("../classes/manager.class.php");
$m = new Manager();

$supplierId = $_REQUEST['id'] ?? null;
$selectedExpenseId = $_REQUEST['selected_id'] ?? null;

if ($supplierId) {
    $filter = "
        WHERE supplier_id = '$supplierId' 
        AND wht > 0 
        AND wht_paid = 0
    ";
    $expenses = ExpenseTaxSetup::GetExpenseTaxSetupList($filter);

    if (!$expenses || count($expenses) === 0) {
        echo '<option value="">No matching records</option>';
        exit;
    }

    echo '<option value="">Select Expense Transaction</option>';

    foreach ($expenses as $expense) {
        echo '<option value="' . htmlspecialchars($expense->id) . '"';
        if ($expense->id == $selectedExpenseId) echo ' selected';
        echo '>';
        echo 'Bill No: ' . htmlspecialchars($expense->bill_no) . ' | ';
        echo 'Amount: ' . number_format($expense->amount, 2);
        echo '</option>';
    }
}
?>
