<?php
include 'includes/config.php';
$data = json_decode(file_get_contents('php://input'), true);

if (!isset($data['id'], $data['amount'])) {
    echo json_encode(['success' => false, 'error' => 'Invalid data received.']);
    exit;
}

try {
    $query = "UPDATE customer_bill_manual SET amount = :amount WHERE id = :id";
    $stmt = $conn->prepare($query);
    $stmt->execute([
        'amount' => $data['amount'],
        'id' => $data['id'],
    ]);

    echo json_encode(['success' => true]);
} catch (PDOException $e) {
    echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
