function _edit($OID = 0, $CID = 0) { loginRequireMgmt(); if (!loginCheckPermission(USER::MGMT_CTS_DATA)) { redirect("errors/401"); } $item = "CTS Data"; $urlPrefix = "mgmt_cts_data"; $object = new CTSData(); $object->retrieve($OID, $CID); if (!$object->exists()) { $data['body'][] = "<p>{$item} Not Found!</p>"; } else { $fdata['form_heading'] = "Edit {$item}"; $fdata['object'] = $object; $fdata['actionUrl'] = myUrl("{$urlPrefix}/ops_update"); $fdata['actionLabel'] = "Submit"; $fdata['cancelUrl'] = myUrl("{$urlPrefix}/manage"); $fdata['cancelLabel'] = "Cancel"; $form = View::do_fetch(VIEW_PATH . "{$urlPrefix}/form.php", $fdata); $data['head'][] = View::do_fetch(VIEW_PATH . "{$urlPrefix}/form_js.php"); $data['body'][] = "<h2>Edit {$item}</h2>"; $data['body'][] = $form; } View::do_dump(VIEW_PATH . 'layouts/mgmtlayout.php', $data); }
function _ops_delete($OID = 0, $CID = 0) { $OID = max(0, intval($OID)); $CID = max(0, intval($CID)); $msg = ''; loginRequireMgmt(); if (!loginCheckPermission(USER::MGMT_CTS_DATA)) { redirect("errors/401"); } $itemName = "CTS Data"; $urlPrefix = "mgmt_cts_data"; $object = new CTSData($OID, $CID); if (!$object->exists()) { $msg = "{$itemName} not found!"; } else { transactionBegin(); if ($object->delete()) { transactionCommit(); $msg = "{$itemName} deleted!"; } else { TransactionRollback(); $msg = "{$itemName} delete failed!"; } } redirect("{$urlPrefix}/manage", $msg); }
function _ops_update() { $OID = max(0, intval($_POST['OID'])); $CID = max(0, intval($_POST['CID'])); $encode = isset($_POST["encode"]); $msg = ""; loginRequireMgmt(); if (!loginCheckPermission(USER::MGMT_CTS_DATA)) { redirect("errors/401"); } $itemName = "CTS Data"; $urlPrefix = "mgmt_cts_data"; $object = new CTSData(); if ($OID) { $object->retrieve($OID, $CID); if (!$object->exists()) { $msg = "{$itemName} not found!"; } else { transactionBegin(); $object->merge($_POST); $object->set("encode", $encode); if ($object->update()) { transactionCommit(); $msg = "{$itemName} updated!"; } else { transactionRollback(); $msg = "{$itemName} update failed"; } } } else { $object->merge($_POST); $object->set("encode", $encode); transactionBegin(); if ($object->create()) { transactionCommit(); $msg = "{$itemName} created!"; } else { transactionRollback(); $msg = "{$itemName} Create failed"; } } redirect("{$urlPrefix}/manage", $msg); }