<?php
include 'includes/config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = $_POST['id'];
    $amount = $_POST['amount'];
    $type = $_POST['type'];

    try {
        if ($type == 'debit') {
            $sql = "UPDATE bank_debit_amount SET amount = :amount WHERE id = :id";
        } elseif ($type == 'credit') {
            $sql = "UPDATE cash_deposit SET amount = :amount WHERE id = :id";
        }

        $stmt = $conn->prepare($sql);
        $stmt->bindParam(':amount', $amount);
        $stmt->bindParam(':id', $id);
        $stmt->execute();
        echo "Transaction updated successfully";
    } catch (PDOException $e) {
        echo "Error: " . $e->getMessage();
    }
}
?>
