$delete_page = new helpdesk();
if ($_POST['type'] == "delete") {
    $midarray = explode(",", $_POST['selectcheck']);
    foreach ($midarray as $w) {
        $delete_page->delete_request($w);
    }
    //disconnect_db($cn);
    if ($_GET['type'] == "all") {
        echo "<script>alert('Request Deleted ...'); window.location='helpdesk_management.php?type=" . $_GET['type'] . "';</script>";
    } else {
        echo "<script>alert('Request Deleted ...'); window.location='helpdesk_management.php';</script>";
    }
} elseif ($_POST['type'] == "open") {
    $midarray = explode(",", $_POST['selectcheck']);
    foreach ($midarray as $w) {
        $delete_page->open_request($w);
    }
    //disconnect_db($cn);
    if ($_GET['type'] == "all") {
        echo "<script>alert('Request is now: Open !..'); window.location='helpdesk_management.php?type=" . $_GET['type'] . "';</script>";
    } else {
        echo "<script>alert('Request is now: Open !..'); window.location='helpdesk_management.php';</script>";
    }
} elseif ($_POST['type'] == "close") {
    $midarray = explode(",", $_POST['selectcheck']);
    foreach ($midarray as $w) {
        $delete_page->close_request($w);
    }
    //disconnect_db($cn);
    if ($_GET['type'] == "all") {
        echo "<script>alert('Request is now: Closed ...'); window.location='helpdesk_management.php?type=" . $_GET['type'] . "';</script>";