Example #1
0
function ArchiveDeviceType()
{
    global $deviceForm;
    $deviceForm->setCols(2);
    $device_type_id = $_GET[devtype_id];
    if (empty($device_type_id)) {
        print "Sorry invalid device type<br>";
        return;
    }
    $devType = new Device_type($device_type_id);
    // Confimration part
    if (!isset($_POST['confirm']) || $_POST['confirm'] != 'No' && $_POST['confirm'] != 'Yes') {
        $form = new Form(auto, 2);
        $msg = "<b>Are you sure your want to delete Device Type: " . $devType->get_name() . "</b>";
        print $form->confirm($msg);
        return;
    } elseif ($_POST['confirm'] == 'No') {
        echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . $_SERVER['PHP_SELF'] . "?action=show_device_type&devtype_id={$device_type_id}\">";
    } else {
        if ($devType->delete()) {
            $_SESSION['action'] = $_POST[Name] . " Deleted";
            echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . $_SERVER['PHP_SELF'] . "?action=list_device_types&delete=success\">";
        } else {
            $deviceForm->error("Warning: Failed to delete device type. Reason: " . $devType->get_error());
        }
    }
}