本文整理汇总了PHP中Contract::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::delete方法的具体用法?PHP Contract::delete怎么用?PHP Contract::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract
的用法示例。
在下文中一共展示了Contract::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transferContracts
//.........这里部分代码省略.........
$newcontractID = -1;
// is already transfer ?
if (isset($this->already_transfer['Contract'][$item_ID])) {
$newcontractID = $this->already_transfer['Contract'][$item_ID];
if ($newcontractID != $item_ID) {
$need_clean_process = true;
}
} else {
// No
// Can be transfer without copy ? = all linked items need to be transfer (so not copy)
$canbetransfer = true;
$query = "SELECT DISTINCT `itemtype`\n FROM `glpi_contracts_items`\n WHERE `contracts_id` = '{$item_ID}'";
if ($result_type = $DB->query($query)) {
if ($DB->numrows($result_type) > 0) {
while (($data_type = $DB->fetch_array($result_type)) && $canbetransfer) {
$dtype = $data_type['itemtype'];
if (isset($this->item_search[$dtype])) {
// No items to transfer -> exists links
$query_search = "SELECT count(*) AS CPT\n FROM `glpi_contracts_items`\n WHERE `contracts_id` = '{$item_ID}'\n AND `itemtype` = '{$dtype}'\n AND `items_id`\n NOT IN " . $this->item_search[$dtype];
$result_search = $DB->query($query_search);
if ($DB->result($result_search, 0, 'CPT') > 0) {
$canbetransfer = false;
}
} else {
$canbetransfer = false;
}
}
}
}
// Yes : transfer
if ($canbetransfer) {
$this->transferItem('Contract', $item_ID, $item_ID);
$newcontractID = $item_ID;
} else {
$need_clean_process = true;
$contract->getFromDB($item_ID);
// No : search contract
$query = "SELECT *\n FROM `glpi_contracts`\n WHERE `entities_id` = '" . $this->to . "'\n AND `name` = '" . addslashes($contract->fields['name']) . "'";
if ($result_search = $DB->query($query)) {
if ($DB->numrows($result_search) > 0) {
$newcontractID = $DB->result($result_search, 0, 'id');
$this->addToAlreadyTransfer('Contract', $item_ID, $newcontractID);
}
}
// found : use it
// not found : copy contract
if ($newcontractID < 0) {
// 1 - create new item
unset($contract->fields['id']);
$input = $contract->fields;
$input['entities_id'] = $this->to;
unset($contract->fields);
$newcontractID = $contract->add($input);
// 2 - transfer as copy
$this->transferItem('Contract', $item_ID, $newcontractID);
}
}
}
// Update links
if ($ID == $newID) {
if ($item_ID != $newcontractID) {
$query = "UPDATE `glpi_contracts_items`\n SET `contracts_id` = '{$newcontractID}'\n WHERE `id` = '" . $data['id'] . "'";
$DB->query($query);
}
// Same Item -> update links
} else {
// Copy Item -> copy links
if ($item_ID != $newcontractID) {
$query = "INSERT\n INTO `glpi_contracts_items`\n (`contracts_id`, `items_id`, `itemtype`)\n VALUES ('{$newcontractID}', '{$newID}', '{$itemtype}')";
$DB->query($query);
} else {
// same contract for new item update link
$query = "UPDATE `glpi_contracts_items`\n SET `items_id` = '{$newID}'\n WHERE `id` = '" . $data['id'] . "'";
$DB->query($query);
}
}
// If clean and unused ->
if ($need_clean_process && $this->options['clean_contract']) {
$query = "SELECT COUNT(*) AS CPT\n FROM `glpi_contracts_items`\n WHERE `contracts_id` = '{$item_ID}'";
if ($result_remaining = $DB->query($query)) {
if ($DB->result($result_remaining, 0, 'CPT') == 0) {
if ($this->options['clean_contract'] == 1) {
$contract->delete(array('id' => $item_ID));
}
if ($this->options['clean_contract'] == 2) {
// purge
$contract->delete(array('id' => $item_ID), 1);
}
}
}
}
}
}
}
} else {
// else unlink
$query = "DELETE\n FROM `glpi_contracts_items`\n WHERE `items_id` = '{$ID}'\n AND `itemtype` = '{$itemtype}'";
$DB->query($query);
}
}
示例2: Contract
if (!isset($_GET["withtemplate"])) {
$_GET["withtemplate"] = "";
}
$contract = new Contract();
$contractitem = new Contract_Item();
$contractsupplier = new Contract_Supplier();
if (isset($_POST["add"])) {
$contract->check(-1, 'w', $_POST);
if ($newID = $contract->add($_POST)) {
Event::log($newID, "contracts", 4, "financial", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
}
Html::back();
} else {
if (isset($_POST["delete"])) {
$contract->check($_POST['id'], 'd');
if ($contract->delete($_POST)) {
Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
}
$contract->redirectToList();
} else {
if (isset($_POST["restore"])) {
$contract->check($_POST['id'], 'd');
if ($contract->restore($_POST)) {
Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
}
$contract->redirectToList();
} else {
if (isset($_POST["purge"])) {
$contract->check($_POST['id'], 'd');
if ($contract->delete($_POST, 1)) {
Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));