本文整理汇总了PHP中Contract_Item类的典型用法代码示例。如果您正苦于以下问题:PHP Contract_Item类的具体用法?PHP Contract_Item怎么用?PHP Contract_Item使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contract_Item类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanDBonPurge
function cleanDBonPurge()
{
$cs = new Contract_Supplier();
$cs->cleanDBonItemDelete($this->getType(), $this->fields['id']);
$ci = new Contract_Item();
$ci->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
示例2: cronContract
/**
* Cron action on contracts : alert depending of the config : on notice and expire
*
* @param $task for log, if NULL display (default NULL)
**/
static function cronContract($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$items_notice = array();
$items_end = array();
$cron_status = 0;
$contract_infos[Alert::END] = array();
$contract_infos[Alert::NOTICE] = array();
$contract_messages = array();
foreach (Entity::getEntitiesToNotify('use_contracts_alert') as $entity => $value) {
$before = Entity::getUsedConfig('send_contracts_alert_before_delay', $entity);
$query_notice = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'Contract'\n AND `glpi_alerts`.`type`='" . Alert::NOTICE . "')\n WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::NOTICE) . ") >'0'\n AND `glpi_contracts`.`is_deleted` = '0'\n AND `glpi_contracts`.`begin_date` IS NOT NULL\n AND `glpi_contracts`.`duration` <> '0'\n AND `glpi_contracts`.`notice` <> '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL `glpi_contracts`.`duration` MONTH),\n CURDATE()) > '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL (`glpi_contracts`.`duration`\n -`glpi_contracts`.`notice`) MONTH),\n CURDATE()) < '{$before}'\n AND `glpi_alerts`.`date` IS NULL\n AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
$query_end = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'Contract'\n AND `glpi_alerts`.`type`='" . Alert::END . "')\n WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::END) . ") > '0'\n AND `glpi_contracts`.`is_deleted` = '0'\n AND `glpi_contracts`.`begin_date` IS NOT NULL\n AND `glpi_contracts`.`duration` <> '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL (`glpi_contracts`.`duration`) MONTH),\n CURDATE()) < '{$before}'\n AND `glpi_alerts`.`date` IS NULL\n AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
$querys = array('notice' => $query_notice, 'end' => $query_end);
foreach ($querys as $type => $query) {
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], $data["notice"]));
$contract_infos[$type][$entity][$data['id']] = $data;
if (!isset($contract_messages[$type][$entity])) {
switch ($type) {
case 'notice':
$contract_messages[$type][$entity] = __('Contract entered in notice time') . "<br>";
break;
case 'end':
$contract_messages[$type][$entity] = __('Contract ended') . "<br>";
break;
}
}
$contract_messages[$type][$entity] .= $message;
}
}
// Get contrats with periodicity alerts
$query_periodicity = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`alert` & " . pow(2, Alert::PERIODICITY) . " > '0'\n AND `glpi_contracts`.`entities_id` = '" . $entity . "' ";
// Foreach ones :
foreach ($DB->request($query_periodicity) as $data) {
$entity = $data['entities_id'];
// Compute end date + 12 month : do not send alerts after
$end_alert = date('Y-m-d', strtotime($data['begin_date'] . " +" . ($data['duration'] + 12) . " month"));
if (!empty($data['begin_date']) && $data['periodicity'] && $end_alert > date('Y-m-d')) {
$todo = array('periodicity' => Alert::PERIODICITY);
if ($data['alert'] & pow(2, Alert::NOTICE)) {
$todo['periodicitynotice'] = Alert::NOTICE;
}
// Get previous alerts
foreach ($todo as $type => $event) {
$previous_alerts[$type] = Alert::getAlertDate(__CLASS__, $data['id'], $event);
}
// compute next alert date based on already send alerts (or not)
foreach ($todo as $type => $event) {
$next_alerts[$type] = date('Y-m-d', strtotime($data['begin_date'] . " -" . $before . " day"));
if ($type == Alert::NOTICE) {
$next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " -" . $data['notice'] . " month"));
}
$today_limit = date('Y-m-d', strtotime(date('Y-m-d') . " -" . $data['periodicity'] . " month"));
// Init previous by begin date if not set
if (empty($previous_alerts[$type])) {
$previous_alerts[$type] = $today_limit;
}
while ($next_alerts[$type] < $previous_alerts[$type] && $next_alerts[$type] < $end_alert) {
$next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $data['periodicity'] . " month"));
}
// If this date is passed : clean alerts and send again
if ($next_alerts[$type] <= date('Y-m-d')) {
$alert = new Alert();
$alert->clear(__CLASS__, $data['id'], $event);
$real_alert_date = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $before . " day"));
$message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Html::convDate($real_alert_date));
$data['alert_date'] = $real_alert_date;
$data['items'] = Contract_Item::getItemsForContract($data['id'], $entity);
$contract_infos[$type][$entity][$data['id']] = $data;
switch ($type) {
case 'periodicitynotice':
$contract_messages[$type][$entity] = __('Contract entered in notice time for period') . "<br>";
break;
case 'periodicity':
$contract_messages[$type][$entity] = __('Contract period ended') . "<br>";
break;
}
$contract_messages[$type][$entity] .= $message;
}
}
}
}
}
foreach (array('notice' => Alert::NOTICE, 'end' => Alert::END, 'periodicity' => Alert::PERIODICITY, 'periodicitynotice' => Alert::NOTICE) as $event => $type) {
if (isset($contract_infos[$event]) && count($contract_infos[$event])) {
foreach ($contract_infos[$event] as $entity => $contracts) {
if (NotificationEvent::raiseEvent($event, new self(), array('entities_id' => $entity, 'items' => $contracts))) {
$message = $contract_messages[$event][$entity];
$cron_status = 1;
//.........这里部分代码省略.........
示例3: Contract_Item
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$contract_item = new Contract_Item();
if (isset($_POST["add"])) {
$contract_item->check(-1, CREATE, $_POST);
if ($contract_item->add($_POST)) {
Event::log($_POST["contracts_id"], "contracts", 4, "financial", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"]));
}
Html::back();
}
Html::displayErrorAndDie("lost");
示例4: replace
//.........这里部分代码省略.........
$document_added = $doc->add($input);
//Attach the document to the new item, once the document's name is correct
$docItem = new Document_Item();
$docItemId = $docItem->add(array('documents_id' => $document_added, 'itemtype' => $type, 'items_id' => (int) $newitem_id));
}
// General Informations - NAME
if ($model->fields["replace_name"]) {
if ($overwrite || empty($newitem->fields['name'])) {
$newitem->update(array('id' => $newitem_id, 'name' => $olditem->getField('name')), false);
}
}
$data['id'] = $newitem->getID();
// General Informations - SERIAL
if ($model->fields["replace_serial"]) {
if ($overwrite || empty($newitem->fields['serial'])) {
$newitem->update(array('id' => $newitem_id, 'serial' => $olditem->getField('serial')), false);
}
}
// General Informations - OTHERSERIAL
if ($model->fields["replace_otherserial"]) {
if ($overwrite || empty($newitem->fields['otherserial'])) {
$newitem->update(array('id' => $newitem_id, 'otherserial' => $olditem->getField('otherserial')), false);
}
}
// Documents
if ($model->fields["replace_documents"] && in_array($type, $CFG_GLPI["document_types"])) {
$doc_item = new Document_Item();
foreach (self::getAssociatedDocuments($olditem) as $document) {
$doc_item->update(array('id' => $document['assocID'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
}
}
// Contracts
if ($model->fields["replace_contracts"] && in_array($type, $CFG_GLPI["contract_types"])) {
$contract_item = new Contract_Item();
foreach (self::getAssociatedContracts($olditem) as $contract) {
$contract_item->update(array('id' => $contract['id'], 'itemtype' => $type, 'items_id' => $newitem_id), false);
}
}
// Infocoms
if ($model->fields["replace_infocoms"] && in_array($type, $CFG_GLPI["infocom_types"])) {
$infocom = new Infocom();
if ($overwrite) {
// Delete current Infocoms of new item
if ($infocom->getFromDBforDevice($type, $newitem_id)) {
//Do not log infocom deletion in the new item's history
$infocom->dohistory = false;
$infocom->deleteFromDB(1);
}
}
// Update current Infocoms of old item
if ($infocom->getFromDBforDevice($type, $olditem_id)) {
$infocom->update(array('id' => $infocom->getID(), 'itemtype' => $type, 'items_id' => $newitem_id), false);
}
}
// Reservations
if ($model->fields["replace_reservations"] && in_array($type, $CFG_GLPI["reservation_types"])) {
$resaitem = new ReservationItem();
if ($overwrite) {
// Delete current reservation of new item
$resa_new = new Reservation();
$resa_new->getFromDB($newitem_id);
if ($resa_new->is_reserved()) {
$resa_new = new ReservationItem();
$resa_new->getFromDBbyItem($type, $newitem_id);
if (count($resa_new->fields)) {
$resa_new->deleteFromDB(1);
示例5: addContracts
/** Generate bigdump : add contracts to an item
*
* @param $type item type
* @param $ID item ID
**/
function addContracts($type, $ID) {
global $CONTRACT_PER_ITEM, $DB, $FIRST, $LAST;
$nb = mt_rand(0, $CONTRACT_PER_ITEM);
$con = array();
for ($i=0 ; $i<$nb ; $i++) {
$con[] = mt_rand($FIRST["contract"], $LAST["contract"]);
}
$con = array_unique($con);
$ci = new Contract_Item();
foreach ($con as $val) {
$ci->add(array('contracts_id' => $val,
'itemtype' => $type,
'items_id' => $ID));
}
}
示例6: Contract_Item
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
$contract_item = new Contract_Item();
if (isset($_POST["add"])) {
$contract_item->check(-1, 'w', $_POST);
if ($contract_item->add($_POST)) {
Event::log($_POST["contracts_id"], "contracts", 4, "financial", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"]));
}
Html::back();
}
Html::displayErrorAndDie("lost");
示例7: Contact_Supplier
}
}
break;
case "add_contact":
if ($_POST["itemtype"] == 'Supplier') {
$contactsupplier = new Contact_Supplier();
foreach ($_POST["item"] as $key => $val) {
$input = array('suppliers_id' => $key, 'contacts_id' => $_POST['conID']);
if ($contactsupplier->can(-1, 'w', $input)) {
$contactsupplier->add($input);
}
}
}
break;
case "add_contract":
$contractitem = new Contract_Item();
foreach ($_POST["item"] as $key => $val) {
$input = array('itemtype' => $_POST["itemtype"], 'items_id' => $key, 'contracts_id' => $_POST['contracts_id']);
if ($contractitem->can(-1, 'w', $input)) {
$contractitem->add($input);
}
}
break;
case "add_enterprise":
if ($_POST["itemtype"] == 'Contact') {
$contactsupplier = new Contact_Supplier();
foreach ($_POST["item"] as $key => $val) {
$input = array('suppliers_id' => $_POST['entID'], 'contacts_id' => $key);
if ($contactsupplier->can(-1, 'w', $input)) {
$contactsupplier->add($input);
}
示例8: post_addItem
function post_addItem()
{
global $DB, $CFG_GLPI;
// Manage add from template
if (isset($this->input["_oldID"])) {
// ADD Infocoms
// $ic = new Infocom();
// $ic->cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
Infocom::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
//test 0.84.3
Contract_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
// ADD Contract
// $query = "SELECT `contracts_id`
// FROM `glpi_contracts_items`
// WHERE `items_id` = '".$this->input["_oldID"]."'
// AND `itemtype` = '".$this->getType()."'";
// $result = $DB->query($query);
// if ($DB->numrows($result)>0) {
// $contractitem = new Contract_Item();
// while ($data=$DB->fetch_array($result)) {
// $contractitem->add(array('contracts_id' => $data["contracts_id"],
// 'itemtype' => $this->getType(),
// 'items_id' => $this->fields['id']));
// }
//}
// ADD Documents
// $query = "SELECT `documents_id`
// FROM `glpi_documents_items`
// WHERE `items_id` = '".$this->input["_oldID"]."'
// AND `itemtype` = '".$this->getType()."'";
// $result = $DB->query($query);
//
// if ($DB->numrows($result)>0) {
// $docitem = new Document_Item();
//
// while ($data=$DB->fetch_array($result)) {
// $docitem->add(array('documents_id' => $data["documents_id"],
// 'itemtype' => $this->getType(),
// 'items_id' => $this->fields['id']));
Document_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
// }
// }
}
if (isset($this->input['_itemtype']) && isset($this->input['_items_id'])) {
$simcard_item = new PluginSimcardSimcard_Item();
$tmp['plugin_simcard_simcards_id'] = $this->getID();
$tmp['itemtype'] = $this->input['_itemtype'];
$tmp['items_id'] = $this->input['_items_id'];
$simcard_item->add($tmp);
}
}
示例9: cleanRelationTable
/**
* Clean the date in the relation tables for the deleted item
* Clear N/N Relation
**/
function cleanRelationTable()
{
global $CFG_GLPI, $DB;
// If this type have INFOCOM, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['infocom_types'])) {
$infocom = new Infocom();
if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
$infocom->delete(array('id' => $infocom->fields['id']));
}
}
// If this type have NETPORT, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['networkport_types'])) {
$query = "SELECT `id`\n FROM `glpi_networkports`\n WHERE (`items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . $this->getType() . "')";
$result = $DB->query($query);
while ($data = $DB->fetch_array($result)) {
$q = "DELETE\n FROM `glpi_networkports_networkports`\n WHERE (`networkports_id_1` = '" . $data["id"] . "'\n OR `networkports_id_2` = '" . $data["id"] . "')";
$result2 = $DB->query($q);
}
$query = "DELETE\n FROM `glpi_networkports`\n WHERE (`items_id` = '" . $this->fields['id'] . "'\n AND `itemtype` = '" . $this->getType() . "')";
$result = $DB->query($query);
}
// If this type is RESERVABLE clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['reservation_types'])) {
$rr = new ReservationItem();
if ($rr->getFromDBbyItem($this->getType(), $this->fields['id'])) {
$rr->delete(array('id' => $infocom->fields['id']));
}
}
// If this type have CONTRACT, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['contract_types'])) {
$ci = new Contract_Item();
$ci->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
// If this type have DOCUMENT, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI["document_types"])) {
$di = new Document_Item();
$di->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
}
示例10: post_addItem
function post_addItem()
{
global $DB, $CFG_GLPI;
// Manage add from template
if (isset($this->input["_oldID"])) {
// ADD Infocoms
$ic = new Infocom();
$ic->cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
// ADD Ports
$query = "SELECT `id`\n FROM `glpi_networkports`\n WHERE `items_id` = '" . $this->input["_oldID"] . "'\n AND `itemtype` = '" . $this->getType() . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_array($result)) {
$np = new NetworkPort();
$npv = new NetworkPort_Vlan();
$np->getFromDB($data["id"]);
unset($np->fields["id"]);
unset($np->fields["ip"]);
unset($np->fields["mac"]);
unset($np->fields["netpoints_id"]);
$np->fields["items_id"] = $this->fields['id'];
$portid = $np->addToDB();
foreach ($DB->request('glpi_networkports_vlans', array('networkports_id' => $data["id"])) as $vlan) {
$npv->assignVlan($portid, $vlan['vlans_id']);
}
}
}
// ADD Contract
$query = "SELECT `contracts_id`\n FROM `glpi_contracts_items`\n WHERE `items_id` = '" . $this->input["_oldID"] . "'\n AND `itemtype` = '" . $this->getType() . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$contractitem = new Contract_Item();
while ($data = $DB->fetch_array($result)) {
$contractitem->add(array('contracts_id' => $data["contracts_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
}
}
// ADD Documents
$query = "SELECT `documents_id`\n FROM `glpi_documents_items`\n WHERE `items_id` = '" . $this->input["_oldID"] . "'\n AND `itemtype` = '" . $this->getType() . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$docitem = new Document_Item();
while ($data = $DB->fetch_array($result)) {
$docitem->add(array('documents_id' => $data["documents_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
}
}
}
}
示例11: define
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
if (!isset($_GET["id"])) {
$_GET["id"] = -1;
}
$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", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $_POST["num"] . ".");
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["delete"])) {
$contract->check($_POST['id'], 'w');
if ($contract->delete($_POST)) {
Event::log($_POST["id"], "contracts", 4, "financial", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
}
$contract->redirectToList();
} else {
示例12: cleanRelationTable
/**
* Clean the date in the relation tables for the deleted item
* Clear N/N Relation
**/
function cleanRelationTable()
{
global $CFG_GLPI, $DB;
// If this type have INFOCOM, clean one associated to purged item
if (Infocom::canApplyOn($this)) {
$infocom = new Infocom();
if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
$infocom->delete(array('id' => $infocom->fields['id']));
}
}
// If this type have NETPORT, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['networkport_types'])) {
// If we don't use delete, then cleanDBonPurge() is not call and the NetworkPorts are not
// clean properly
$networkPortObject = new NetworkPort();
$networkPortObject->cleanDBonItemDelete($this->getType(), $this->getID());
// Manage networkportmigration if exists
if (TableExists('glpi_networkportmigrations')) {
$networkPortMigObject = new NetworkPortMigration();
$networkPortMigObject->cleanDBonItemDelete($this->getType(), $this->getID());
}
}
// If this type is RESERVABLE clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['reservation_types'])) {
$rr = new ReservationItem();
if ($rr->getFromDBbyItem($this->getType(), $this->fields['id'])) {
$rr->delete(array('id' => $infocom->fields['id']));
}
}
// If this type have CONTRACT, clean one associated to purged item
if (in_array($this->getType(), $CFG_GLPI['contract_types'])) {
$ci = new Contract_Item();
$ci->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
// If this type have DOCUMENT, clean one associated to purged item
if (Document::canApplyOn($this)) {
$di = new Document_Item();
$di->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
// If this type have NOTEPAD, clean one associated to purged item
if ($this->usenotepad) {
$note = new Notepad();
$note->cleanDBonItemDelete($this->getType(), $this->fields['id']);
}
}
示例13: post_addItem
function post_addItem()
{
global $DB, $CFG_GLPI;
// Manage add from template
if (isset($this->input["_oldID"])) {
Infocom::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
Contract_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
Document_Item::cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
}
if (isset($this->input['_itemtype']) && isset($this->input['_items_id'])) {
$simcard_item = new PluginSimcardSimcard_Item();
$tmp['plugin_simcard_simcards_id'] = $this->getID();
$tmp['itemtype'] = $this->input['_itemtype'];
$tmp['items_id'] = $this->input['_items_id'];
$simcard_item->add($tmp);
}
}
示例14: doMassiveActions
//.........这里部分代码省略.........
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
}
}
}
break;
case "activate_infocoms":
$ic = new Infocom();
if ($ic->canCreate()) {
foreach ($input["item"] as $key => $val) {
$input = array('itemtype' => $input['itemtype'], 'items_id' => $key);
if (!$ic->getFromDBforDevice($input['itemtype'], $key)) {
if ($ic->can(-1, 'w', $input)) {
if ($ic->add($input)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
} else {
$res['ko']++;
}
}
}
break;
case "add_contract_item":
$contractitem = new Contract_Item();
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Add items to contracts
$input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
}
if (isset($input['contracts_id'])) {
// Add contract to item
$input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
} else {
return false;
}
if ($contractitem->can(-1, 'w', $input)) {
if ($contractitem->add($input)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
break;
case "remove_contract_item":
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Remove item to contracts
$input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
} else {
// Remove contract to items
$input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
}
$contractitem = new Contract_Item();
示例15: post_addItem
function post_addItem()
{
global $DB, $CFG_GLPI;
// Manage add from template
if (isset($this->input["_oldID"])) {
// ADD Infocoms
$ic = new Infocom();
$ic->cloneItem($this->getType(), $this->input["_oldID"], $this->fields['id']);
// ADD Contract
$query = "SELECT `contracts_id`\n FROM `glpi_contracts_items`\n WHERE `items_id` = '" . $this->input["_oldID"] . "'\n AND `itemtype` = '" . $this->getType() . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$contractitem = new Contract_Item();
while ($data = $DB->fetch_array($result)) {
$contractitem->add(array('contracts_id' => $data["contracts_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
}
}
// ADD Documents
$query = "SELECT `documents_id`\n FROM `glpi_documents_items`\n WHERE `items_id` = '" . $this->input["_oldID"] . "'\n AND `itemtype` = '" . $this->getType() . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$docitem = new Document_Item();
while ($data = $DB->fetch_array($result)) {
$docitem->add(array('documents_id' => $data["documents_id"], 'itemtype' => $this->getType(), 'items_id' => $this->fields['id']));
}
}
}
}