<?php
include("../classes/manager.class.php");

$m = new Manager();

// Get supplier ID from request
$supplierId = isset($_GET['supplier_id']) ? intval($_GET['supplier_id']) : 0;

if ($supplierId > 0) {
    $filter = "WHERE supplier_id = '$supplierId' AND status = 'active'";
    $banks = SupplierBankSetup::GetBankList($filter); // Fetch bank details from DB

    // Format the response as JSON
    echo json_encode(array_map(function ($bank) {
        return [
            'id' => $bank->id,
            'bank_name' => $bank->bank_name,
            'bank_account_number' => $bank->bank_account_number,
        ];
    }, $banks));
} else {
    echo json_encode([]); // Return an empty array if the supplier ID is invalid
}
?>
