本文整理汇总了PHP中Contract::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract::update方法的具体用法?PHP Contract::update怎么用?PHP Contract::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contract
的用法示例。
在下文中一共展示了Contract::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sprintf
$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"]));
}
$contract->redirectToList();
} else {
if (isset($_POST["update"])) {
$contract->check($_POST['id'], 'w');
if ($contract->update($_POST)) {
Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
}
Html::back();
} else {
Html::header(Contract::getTypeName(2), $_SERVER['PHP_SELF'], "financial", "contract");
$contract->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
Html::footer();
}
}
}
}
}
示例2: createLinkWithItem
public function createLinkWithItem($detailID = 0, $items_id = 0, $itemtype = 0, $plugin_order_orders_id = 0, $entity = 0, $templateID = 0, $history = true, $check_link = true)
{
global $DB;
if (!$check_link || !$this->itemAlreadyLinkedToAnOrder($itemtype, $items_id, $plugin_order_orders_id, $detailID)) {
$detail = new PluginOrderOrder_Item();
$restricted = array('ConsumableItem', 'CartridgeItem');
if ($itemtype == 'SoftwareLicense') {
$detail->getFromDB($detailID);
$query = "SELECT `id`\n FROM `glpi_plugin_order_orders_items`\n WHERE `plugin_order_orders_id` = '{$plugin_order_orders_id}'\n AND `plugin_order_references_id` = '{$detail->fields["plugin_order_references_id"]}'\n AND `price_taxfree` LIKE '{$detail->fields["price_taxfree"]}'\n AND `discount` LIKE '{$detail->fields["discount"]}'\n AND `states_id` = 1 ";
$result = $DB->query($query);
$nb = $DB->numrows($result);
if ($nb) {
for ($i = 0; $i < $nb; $i++) {
$ID = $DB->result($result, $i, 'id');
$input["id"] = $ID;
$input["items_id"] = $items_id;
$detail->update($input);
$this->generateInfoComRelatedToOrder($entity, $ID, $itemtype, $items_id, 0);
$lic = new SoftwareLicense();
$lic->getFromDB($items_id);
$values["id"] = $lic->fields["id"];
$values["number"] = $lic->fields["number"] + 1;
$lic->update($values);
}
if ($history) {
$order = new PluginOrderOrder();
$new_value = __("Item linked to order", "order") . ' : ' . $lic->getField("name");
$order->addHistory('PluginOrderOrder', '', $new_value, $plugin_order_orders_id);
}
}
} elseif (in_array($itemtype, $restricted)) {
if ($itemtype == 'ConsumableItem') {
$item = new Consumable();
$type = 'Consumable';
$pkey = 'consumableitems_id';
} elseif ($itemtype == 'CartridgeItem') {
$item = new Cartridge();
$type = 'Cartridge';
$pkey = 'cartridgeitems_id';
}
$detail->getFromDB($detailID);
$input[$pkey] = $items_id;
$input["date_in"] = $detail->fields["delivery_date"];
$newID = $item->add($input);
$input["id"] = $detailID;
$input["items_id"] = $newID;
$input["itemtype"] = $itemtype;
if ($detail->update($input)) {
$this->generateInfoComRelatedToOrder($entity, $detailID, $type, $newID, 0);
}
} elseif ($itemtype == 'Contract') {
$input["id"] = $detailID;
$input["items_id"] = $items_id;
$input["itemtype"] = $itemtype;
if ($detail->update($input)) {
$detail->getFromDB($detailID);
$item = new Contract();
if ($item->update(array('id' => $items_id, 'cost' => $detail->fields["price_discounted"]))) {
$order = new PluginOrderOrder();
$order->getFromDB($plugin_order_orders_id);
if (!countElementsInTable('glpi_contracts_suppliers', "`contracts_id`='{$items_id}' AND `suppliers_id`='" . $order->fields['suppliers_id'] . "'")) {
$contract_supplier = new Contract_Supplier();
$contract_supplier->add(array('contracts_id' => $items_id, 'suppliers_id' => $order->fields['suppliers_id']));
}
}
}
} else {
$input["id"] = $detailID;
$input["items_id"] = $items_id;
$input["itemtype"] = $itemtype;
if ($detail->update($input)) {
$this->generateInfoComRelatedToOrder($entity, $detailID, $itemtype, $items_id, $templateID);
if ($history) {
$order = new PluginOrderOrder();
$order->getFromDB($detail->fields["plugin_order_orders_id"]);
$item = new $itemtype();
$item->getFromDB($items_id);
$new_value = __("Item linked to order", "order") . ' : ' . $item->getField("name");
$order->addHistory('PluginOrderOrder', '', $new_value, $order->fields["id"]);
}
}
}
if ($history) {
$order = new PluginOrderOrder();
$order->getFromDB($detail->fields["plugin_order_orders_id"]);
$new_value = __("Item linked to order", "order") . ' : ' . $order->fields["name"];
$order->addHistory($itemtype, '', $new_value, $items_id);
}
Session::addMessageAfterRedirect(__("Item linked to order", "order"), true);
} else {
Session::addMessageAfterRedirect(__("Item already linked to another one", "order"), true, ERROR);
}
}