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

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

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

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