<?php
session_start();
include("dbconfig.php");
if (isset($_SESSION['username']) && isset($_SESSION['password'])) {
    $username = $_SESSION['username'];
    $pass = $_SESSION['password'];
} else {
    echo '<META http-equiv="refresh" content="0;logout.php">';
}
if (isset($_GET['CBillNo'])) {
    mysqli_query($db, "DELETE FROM bill where BillNo='$_GET[CBillNo]'");
    mysqli_query($db, "DELETE FROM billparticulars where BillNo='$_GET[CBillNo]'");

    echo "<script>alert('Consolidate Bill Deleted!')</script>";
    echo "<script>window.history.go(-1)</script>";
} elseif (isset($_GET['ABillNo'])) {
    mysqli_query($db, "DELETE FROM advance where BillNo='$_GET[ABillNo]'");
    echo "<script>alert('Advance Bill Deleted!')</script>";
    echo "<script>window.history.go(-1)</script>";
} elseif (isset($_GET['FBillNo'])) {
    mysqli_query($db, "DELETE FROM finalbill where FinalBillNo='$_GET[FBillNo]'");
    echo "<script>alert('Discharge Bill Deleted!')</script>";
    echo "<script>window.history.go(-1)</script>";
} elseif (isset($_GET['EBillNo'])) {
    mysqli_query($db, "DELETE FROM examination where BillNo='$_GET[EBillNo]'");
    echo "<script>alert('Examination Bill Deleted!')</script>";
    echo "<script>window.history.go(-1)</script>";
}

if (isset($_GET['userslno'])) {
    mysqli_query($db, "DELETE FROM billlogin where SlNo='$_GET[userslno]'");
    echo "<script>alert('User Deleted!!')</script>";
    $url = "https://vidyaranyahospital.in/Billing/Admin/default/ViewUsers.php";
    echo "<meta http-equiv=\"refresh\" content=\"0;url=$url\" />";
}
