<?php
// Include your database connection
include("dbconfig.php");

// Check if the delete form is submitted
if (isset($_POST['delete'])) {
    // Get the bill number from the form
    $billno = $_POST['bill_no'];

    // SQL query to update `is_deleted` to 0 (mark as deleted)
    $updateQuery = "UPDATE `bill` SET `is_deleted` = 0 WHERE `BillNo` = '$billno'";

    // Run the query
    if (mysqli_query($db, $updateQuery)) {
        // If update is successful, redirect with success message
        echo "<script>alert('Bill record marked as deleted successfully.'); window.location.href='https://vidyaranyahospital.in/Billing/Admin/default/opdbills.php';</script>";
    } else {
        // If there is an error, show an error message and redirect
        echo "<script>alert('Error marking bill record as deleted.'); window.location.href='https://vidyaranyahospital.in/Billing/Admin/default/opdbills.php';</script>";
    }
}
?>
