<?php
include("includes/db_config.php");

$customer_id = $_POST["customer_id"];
$response = ["balance" => 0]; // Default response

if (!empty($customer_id)) {
    $sql_fetch = "SELECT opening_balance,party_phone_no,gst_state FROM ah_party WHERE id = '$customer_id'";
    $result = mysqli_query($conn, $sql_fetch);

    if ($result && mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);
        $response["balance"] = floatval($row['opening_balance']);
        $response["party_phone_no"] = $row['party_phone_no'];
        $response["gst_state"] = $row['gst_state'];
    }
}

echo json_encode($response);
?>
