当前位置: 首页>>代码示例>>PHP>>正文


PHP Contract_Item::add方法代码示例

本文整理汇总了PHP中Contract_Item::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Contract_Item::add方法的具体用法?PHP Contract_Item::add怎么用?PHP Contract_Item::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contract_Item的用法示例。


在下文中一共展示了Contract_Item::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sprintf

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");
开发者ID:jose-martins,项目名称:glpi,代码行数:31,代码来源:contract_item.form.php

示例2: 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));
   }
}
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:22,代码来源:generate_bigdump.function.php

示例3: foreach

     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);
             }
         }
     }
     break;
 case "activate_infocoms":
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php

示例4: Infocom

 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']));
             }
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:47,代码来源:phone.class.php

示例5: doMassiveActions

 /**
  * Do the standard massive actions
  *
  * @since version 0.84
  *
  * This must not be overloaded in Class
  * @param $input array of input datas
  *
  * @return an array of results (ok, ko, noright counts, may include REDIRECT field to set REDIRECT page)
  **/
 function doMassiveActions($input = array())
 {
     global $CFG_GLPI;
     if (!isset($input["item"]) || count($input["item"]) == 0) {
         return false;
     }
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'add_document':
         case 'remove_document':
             $doc = new Document();
             return $doc->doSpecificMassiveActions($input);
         case "add_transfer_list":
             if (!isset($_SESSION['glpitransfer_list'])) {
                 $_SESSION['glpitransfer_list'] = array();
             }
             if (!isset($_SESSION['glpitransfer_list'][$input["itemtype"]])) {
                 $_SESSION['glpitransfer_list'][$input["itemtype"]] = array();
             }
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     $_SESSION['glpitransfer_list'][$input["itemtype"]][$key] = $key;
                     $res['ok']++;
                 }
             }
             $res['REDIRECT'] = $CFG_GLPI['root_doc'] . '/front/transfer.action.php';
             break;
         case "delete":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->delete(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "purge":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         $force = 1;
                         // Only mark deletion for
                         if ($this->maybeDeleted() && $this->useDeletedToLockIfDynamic() && $this->isDynamic()) {
                             $force = 0;
                         }
                         if ($this->delete(array("id" => $key), $force)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "restore":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'd')) {
                         if ($this->restore(array("id" => $key))) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "update":
             $searchopt = Search::getCleanedOptions($input["itemtype"], 'w');
             if (isset($searchopt[$input["id_field"]])) {
                 /// Infocoms case
                 if (!isPluginItemType($input["itemtype"]) && Search::isInfocomOption($input["itemtype"], $input["id_field"])) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$input["id_field"]]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
                             $link_entity_type = $ent->fields["entities_id"];
                         }
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:commondbtm.class.php

示例6: Infocom

 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']));
             }
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:28,代码来源:software.class.php


注:本文中的Contract_Item::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。