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


PHP Infocom::getFromDBforDevice方法代码示例

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


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

示例1: pdfForItem

 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $CFG_GLPI;
     $ID = $item->getField('id');
     if (!Session::haveRight("infocom", "r")) {
         return false;
     }
     $ic = new Infocom();
     $pdf->setColumnsSize(100);
     if ($ic->getFromDBforDevice(get_class($item), $ID)) {
         $pdf->displayTitle("<b>" . __('Financial and administrative information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Supplier') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Budget') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_budgets", $ic->fields["budgets_id"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Order number') . "</i></b>", $ic->fields["order_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Order date') . "</i></b>", Html::convDate($ic->fields["order_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Immobilization number') . "</i></b>", $ic->fields["immo_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Date of purchase') . "</i></b>", Html::convDate($ic->fields["buy_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Invoice number') . "</i></b>", $ic->fields["bill"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery date') . "</i></b>", Html::convDate($ic->fields["delivery_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery form') . "</i></b>", $ic->fields["delivery_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Startup date') . "</i></b>", Html::convDate($ic->fields["use_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), _('Date of last physical inventory') . "</i></b>", Html::convDate($ic->fields["inventory_date"])));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty extension value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["warranty_value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization duration') . "</i></b>", sprintf(__('%1$s (%2$s)'), sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]), Infocom::getAmortTypeName($ic->fields["sink_type"]))));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Account net value') . "</i></b>", Infocom::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $CFG_GLPI['date_tax'], "n")), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization coefficient') . "</i></b>", $ic->fields["sink_coeff"]));
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('TCO (value + tracking cost)') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Monthly TCO') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]))));
         PluginPdfCommon::mainLine($pdf, $ic, 'comment');
         $pdf->setColumnsSize(100);
         $pdf->displayTitle("<b>" . __('Warranty information') . "</b>");
         $pdf->setColumnsSize(50, 50);
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Start date of warranty') . "</i></b>", Html::convDate($ic->fields["warranty_date"])), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty duration') . "</i></b>", sprintf(__('%1$s - %2$s'), sprintf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]), sprintf(__('Valid to %s'), Infocom::getWarrantyExpir($ic->fields["buy_date"], $ic->fields["warranty_duration"])))));
         $col1 = "<b><i>" . __('Alarms on financial and administrative information') . "</i></b>";
         if ($ic->fields["alert"] == 0) {
             $col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
         } else {
             if ($ic->fields["alert"] == 4) {
                 $col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
             }
         }
         $pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty information') . "</i></b>", $ic->fields["warranty_info"]), $col1);
     } else {
         $pdf->displayTitle("<b>" . __('No financial information', 'pdf') . "</b>");
     }
     $pdf->displaySpace();
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:40,代码来源:infocom.class.php

示例2: switch

}
if (isset($_POST['action'])) {
    // Retrieve configuration for generate assets feature
    $order_item = new PluginOrderOrder_Item();
    switch ($_POST['chooseAction']) {
        case 'bill':
        case 'state':
            if (isset($_POST["item"])) {
                foreach ($_POST["item"] as $key => $val) {
                    if ($val == 1) {
                        $tmp = $_POST;
                        $tmp['id'] = $key;
                        $order_item->update($tmp);
                        // Update infocom
                        $ic = new Infocom();
                        $ic->getFromDBforDevice($order_item->fields['itemtype'], $order_item->fields['items_id']);
                        $config = PluginOrderConfig::getConfig();
                        if ($config->canAddBillDetails()) {
                            if ($bill->getFromDB($_POST["plugin_order_bills_id"])) {
                                $fields['id'] = $ic->fields['id'];
                                $fields['bill'] = $bill->fields['number'];
                                $fields['warranty_date'] = $bill->fields['billdate'];
                            }
                        }
                        $ic->update($fields);
                    }
                }
            }
            break;
    }
    PluginOrderOrder::updateBillState($order_item->fields['plugin_order_orders_id']);
开发者ID:equinoxefr,项目名称:order,代码行数:31,代码来源:bill.form.php

示例3: transferInfocoms

 /**
  * Transfer infocoms of an item
  *
  * @param $itemtype type of the item to transfer
  * @param $ID original ID of the item
  * @param $newID new ID of the item
  **/
 function transferInfocoms($itemtype, $ID, $newID)
 {
     global $DB;
     $ic = new Infocom();
     if ($ic->getFromDBforDevice($itemtype, $ID)) {
         switch ($this->options['keep_infocom']) {
             // delete
             case 0:
                 // Same item -> delete
                 if ($ID == $newID) {
                     $query = "DELETE\n                            FROM `glpi_infocoms`\n                            WHERE `itemtype` = '{$itemtype}'\n                                  AND `items_id` = '{$ID}'";
                     $result = $DB->query($query);
                 }
                 // Copy : nothing to do
                 break;
                 // Keep
             // Keep
             default:
                 // Transfer enterprise
                 $suppliers_id = 0;
                 if ($ic->fields['suppliers_id'] > 0) {
                     $suppliers_id = $this->transferSingleSupplier($ic->fields['suppliers_id']);
                 }
                 // Copy : copy infocoms
                 if ($ID != $newID) {
                     // Copy items
                     $input = $ic->fields;
                     $input['items_id'] = $newID;
                     $input['suppliers_id'] = $suppliers_id;
                     unset($input['id']);
                     unset($ic->fields);
                     $ic->add($input);
                 } else {
                     // Same Item : manage only enterprise move
                     // Update enterprise
                     if ($suppliers_id > 0 && $suppliers_id != $ic->fields['suppliers_id']) {
                         $ic->update(array('id' => $ic->fields['id'], 'suppliers_id' => $suppliers_id));
                     }
                 }
                 break;
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:50,代码来源:transfer.class.php

示例4: showDebugInfo

 /**
  * to list infos in debug tab
  **/
 function showDebugInfo()
 {
     global $CFG_GLPI;
     $class = $this->getType();
     if (method_exists($class, 'showDebug')) {
         $this->showDebug();
     }
     if (InfoCom::canApplyOn($class)) {
         $infocom = new Infocom();
         if ($infocom->getFromDBforDevice($class, $this->fields['id'])) {
             $infocom->showDebug();
         }
     }
     if (in_array($class, $CFG_GLPI["reservation_types"])) {
         $resitem = new ReservationItem();
         if ($resitem->getFromDBbyItem($class, $this->fields['id'])) {
             $resitem->showDebugResa();
         }
     }
 }
开发者ID:korial29,项目名称:glpi,代码行数:23,代码来源:commonglpi.class.php

示例5: post_updateItem

 public function post_updateItem($history = 1)
 {
     global $DB;
     $config = PluginOrderConfig::getConfig();
     if ($config->fields['transmit_budget_change'] && in_array('budgets_id', $this->updates)) {
         $infocom = new Infocom();
         $query = "SELECT `items_id`, `itemtype`\n                   FROM `glpi_plugin_order_orders_items`\n                   WHERE `plugin_order_orders_id`='" . $this->getID() . "'";
         foreach ($DB->request($query) as $infos) {
             $infocom->getFromDBforDevice($infos['itemtype'], $infos['items_id']);
             $infocom->update(array('id' => $infocom->getID(), 'budgets_id' => $this->fields['budgets_id']));
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:13,代码来源:order.class.php

示例6: replace


//.........这里部分代码省略.........
         }
         $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);
                     }
                 }
             }
             // Update old reservation for attribute to new item
             $resa_old = new Reservation();
             $resa_old->getFromDB($olditem_id);
             if ($resa_old->is_reserved()) {
                 $resa_old = new ReservationItem();
                 $resa_old->getFromDBbyItem($type, $olditem_id);
                 if (count($resa_old->fields)) {
开发者ID:pluginsGLPI,项目名称:uninstall,代码行数:67,代码来源:replace.class.php

示例7: getItem


//.........这里部分代码省略.........
                             $query_netn = "SELECT\n                              GROUP_CONCAT(CONCAT(ipadr.`id`, '" . Search::SHORTSEP . "' , ipadr.`name`)\n                                           SEPARATOR '" . Search::LONGSEP . "') as ipadresses,\n                              netn.`id` as networknames_id,\n                              netn.`name` as networkname,\n                              netn.`fqdns_id`,\n                              fqdn.`name` as fqdn_name,\n                              fqdn.`fqdn`\n                           FROM `glpi_networknames` AS netn\n                           LEFT JOIN `glpi_ipaddresses` AS ipadr\n                              ON ipadr.`itemtype` = 'NetworkName' AND ipadr.`items_id` = netn.`id`\n                           LEFT JOIN `glpi_fqdns` AS fqdn\n                              ON fqdn.`id` = netn.`fqdns_id`\n                           LEFT JOIN `glpi_ipaddresses_ipnetworks` ipadnet\n                              ON ipadnet.`ipaddresses_id` = ipadr.`id`\n                           LEFT JOIN `glpi_ipnetworks` `ipnet`\n                              ON ipnet.`id` = ipadnet.`ipnetworks_id`\n                           WHERE netn.`itemtype` = 'NetworkPort'\n                             AND netn.`items_id` = " . $data['netport_id'] . "\n                           GROUP BY netn.`id`, netn.`name`, netn.fqdns_id, fqdn.name, fqdn.fqdn";
                             if ($result_netn = $DB->query($query_netn)) {
                                 $data_netn = $DB->fetch_assoc($result_netn);
                                 $raw_ipadresses = explode(Search::LONGSEP, $data_netn['ipadresses']);
                                 $ipadresses = array();
                                 foreach ($raw_ipadresses as $ipadress) {
                                     $ipadress = explode(Search::SHORTSEP, $ipadress);
                                     //find ip network attached to these ip
                                     $ipnetworks = array();
                                     $query_ipnet = "SELECT\n                                    ipnet.`id`,\n                                    ipnet.`completename`,\n                                    ipnet.`name`,\n                                    ipnet.`address`,\n                                    ipnet.`netmask`,\n                                    ipnet.`gateway`,\n                                    ipnet.`ipnetworks_id`,\n                                    ipnet.`comment`\n                                 FROM `glpi_ipnetworks` ipnet\n                                 INNER JOIN `glpi_ipaddresses_ipnetworks` ipadnet\n                                    ON ipnet.`id` = ipadnet.`ipnetworks_id`\n                                    AND ipadnet.`ipaddresses_id` = " . $ipadress[0];
                                     if ($result_ipnet = $DB->query($query_ipnet)) {
                                         while ($data_ipnet = $DB->fetch_assoc($result_ipnet)) {
                                             $ipnetworks[] = $data_ipnet;
                                         }
                                     }
                                     $ipadresses[] = array('id' => $ipadress[0], 'name' => $ipadress[1], 'IPNetwork' => $ipnetworks);
                                 }
                                 $data['NetworkName'] = array('id' => $data_netn['networknames_id'], 'name' => $data_netn['networkname'], 'fqdns_id' => $data_netn['fqdns_id'], 'FQDN' => array('id' => $data_netn['fqdns_id'], 'name' => $data_netn['fqdn_name'], 'fqdn' => $data_netn['fqdn']), 'IPAddress' => $ipadresses);
                             }
                         }
                         $fields['_networkports'][$networkport_type][] = $data;
                     }
                 }
             }
         }
     }
     // retrieve item infocoms
     if (isset($params['with_infocoms']) && $params['with_infocoms']) {
         $fields['_infocoms'] = array();
         if (!Infocom::canView()) {
             $fields['_infocoms'] = self::arrayRightError();
         } else {
             $ic = new Infocom();
             if ($ic->getFromDBforDevice($itemtype, $id)) {
                 $fields['_infocoms'] = $ic->fields;
             }
         }
     }
     // retrieve item contracts
     if (isset($params['with_contracts']) && $params['with_contracts']) {
         $fields['_contracts'] = array();
         if (!Contract::canView()) {
             $fields['_contracts'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_contracts_items`.*\n                     FROM `glpi_contracts_items`,\n                          `glpi_contracts`\n                     LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n                     WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n                           AND `glpi_contracts_items`.`items_id` = '{$id}'\n                           AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n                     ORDER BY `glpi_contracts`.`name`";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_contracts'][] = $data;
                 }
             }
         }
     }
     // retrieve item contracts
     if (isset($params['with_documents']) && $params['with_documents']) {
         $fields['_documents'] = array();
         if (!$itemtype != 'Ticket' && $itemtype != 'KnowbaseItem' && $itemtype != 'Reminder' && !Document::canView()) {
             $fields['_documents'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_documents_items`.`id` AS assocID,\n                             `glpi_documents_items`.`date_mod` AS assocdate,\n                             `glpi_entities`.`id` AS entityID,\n                             `glpi_entities`.`completename` AS entity,\n                             `glpi_documentcategories`.`completename` AS headings,\n                             `glpi_documents`.*\n                      FROM `glpi_documents_items`\n                      LEFT JOIN `glpi_documents`\n                                ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n                      LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n                      LEFT JOIN `glpi_documentcategories`\n                              ON (`glpi_documents`.`documentcategories_id`=`glpi_documentcategories`.`id`)\n                      WHERE `glpi_documents_items`.`items_id` = '{$id}'\n                            AND `glpi_documents_items`.`itemtype` = '{$itemtype}' ";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_documents'][] = $data;
                 }
             }
         }
     }
开发者ID:glpi-project,项目名称:glpi,代码行数:67,代码来源:api.class.php

示例8: processMassiveActionsForOneItemtype


//.........这里部分代码省略.........
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'update':
             if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
                 return false;
             }
             $index = $ma->POST['search_options'][$item->getType()];
             $searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
             $input = $ma->POST;
             if (isset($searchopt[$index])) {
                 /// Infocoms case
                 if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
                     $ic = new Infocom();
                     $link_entity_type = -1;
                     /// Specific entity item
                     if ($searchopt[$index]["table"] == "glpi_suppliers") {
                         $ent = new Supplier();
                         if ($ent->getFromDB($input[$input["field"]])) {
                             $link_entity_type = $ent->fields["entities_id"];
                         }
                     }
                     foreach ($ids as $key) {
                         if ($item->getFromDB($key)) {
                             if ($link_entity_type < 0 || $link_entity_type == $item->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $item->getEntityID()))) {
                                 $input2["items_id"] = $key;
                                 $input2["itemtype"] = $item->getType();
                                 if ($ic->can(-1, CREATE, $input2)) {
                                     // Add infocom if not exists
                                     if (!$ic->getFromDBforDevice($item->getType(), $key)) {
                                         $input2["items_id"] = $key;
                                         $input2["itemtype"] = $item->getType();
                                         unset($ic->fields);
                                         $ic->add($input2);
                                         $ic->getFromDBforDevice($item->getType(), $key);
                                     }
                                     $id = $ic->fields["id"];
                                     unset($ic->fields);
                                     if ($ic->update(array('id' => $id, $input["field"] => $input[$input["field"]]))) {
                                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                                     } else {
                                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                                     }
                                 } else {
                                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                                 }
                             } else {
                                 $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                         }
                     }
                 } else {
                     /// Not infocoms
                     $link_entity_type = array();
                     /// Specific entity item
                     $itemtable = getTableForItemType($item->getType());
开发者ID:kipman,项目名称:glpi,代码行数:67,代码来源:massiveaction.class.php

示例9: Infocom

 function post_addItem()
 {
     global $DB;
     // Manage add from template
     if (isset($this->input["_oldID"])) {
         // ADD Infocoms
         $ic = new Infocom();
         if ($this->canUseInfocoms() && $ic->getFromDBforDevice($this->type, $this->input["_oldID"])) {
             $ic->fields["items_id"] = $this->fields['id'];
             unset($ic->fields["id"]);
             if (isset($ic->fields["immo_number"])) {
                 $ic->fields["immo_number"] = autoName($ic->fields["immo_number"], "immo_number", 1, 'Infocom', $this->input['entities_id']);
             }
             if (empty($ic->fields['use_date'])) {
                 unset($ic->fields['use_date']);
             }
             if (empty($ic->fields['buy_date'])) {
                 unset($ic->fields['buy_date']);
             }
             $ic->addToDB();
         }
         foreach (array('Document_Item' => 'documents_id', 'Contract_Item' => 'contracts_id') as $type => $fk) {
             $item = new $type();
             foreach ($item->find("items_id='" . $this->input["_oldID"] . "'\n                                 AND itemtype='" . $this->type . "'") as $tmpid => $data) {
                 $tmp = array();
                 $tmp['items_id'] = $this->input["_oldID"];
                 $tmp['itemtype'] = $type;
                 $tmp[$fk] = $data[$fk];
                 $item->add($tmp);
             }
         }
         if ($this->canUseNetworkPorts()) {
             // ADD Ports
             $query = "SELECT `id`\n                       FROM `glpi_networkports`\n                       WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                          AND `itemtype` = '" . get_called_class() . "';";
             $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']);
                     }
                 }
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:54,代码来源:object.class.php

示例10: generateInfoComRelatedToOrder

 public function generateInfoComRelatedToOrder($entity, $detailID, $itemtype, $items_id, $templateID = 0)
 {
     global $CFG_GLPI;
     //Do not try to generate infocoms if itemtype doesn't support it (ie contracts...)
     if (in_array($itemtype, $CFG_GLPI["infocom_types"])) {
         // Retrieve configuration for generate assets feature
         $config = PluginOrderConfig::getConfig();
         $fields = array();
         //Create empty infocom, in order to forward entities_id and is_recursive
         $ic = new Infocom();
         $infocomID = !$ic->getFromDBforDevice($itemtype, $items_id) ? false : $ic->fields["id"];
         $detail = new PluginOrderOrder_Item();
         $detail->getFromDB($detailID);
         $order = new PluginOrderOrder();
         $order->getFromDB($detail->fields["plugin_order_orders_id"]);
         $order_supplier = new PluginOrderOrder_Supplier();
         $order_supplier->getFromDBByOrder($detail->fields["plugin_order_orders_id"]);
         if ($templateID) {
             if ($ic->getFromDBforDevice($itemtype, $templateID)) {
                 $fields = $ic->fields;
                 unset($fields["id"]);
                 if (isset($fields["immo_number"])) {
                     $fields["immo_number"] = autoName($fields["immo_number"], "immo_number", 1, 'Infocom', $entity);
                 }
                 if (empty($fields['buy_date'])) {
                     unset($fields['buy_date']);
                 }
             }
         }
         $fields["entities_id"] = $entity;
         $fields["itemtype"] = $itemtype;
         $fields["items_id"] = $items_id;
         $fields["order_number"] = $order->fields["num_order"];
         $fields["delivery_number"] = $detail->fields["delivery_number"];
         $fields["budgets_id"] = $order->fields["budgets_id"];
         $fields["suppliers_id"] = $order->fields["suppliers_id"];
         $fields["value"] = $detail->fields["price_discounted"];
         $fields["order_date"] = $order->fields["order_date"];
         if (!is_null($detail->fields["delivery_date"])) {
             $fields["delivery_date"] = $detail->fields["delivery_date"];
         }
         // Get bill data
         if ($config->canAddBillDetails()) {
             $bill = new PluginOrderBill();
             if ($bill->getFromDB($detail->fields["plugin_order_bills_id"])) {
                 $fields['bill'] = $bill->fields['number'];
                 $fields['warranty_date'] = $bill->fields['billdate'];
             }
         }
         foreach (array('warranty_date', 'buy_date', 'inventory_date') as $date) {
             if (!isset($fields[$date])) {
                 $fields[$date] = 'NULL';
             }
         }
         $fields['_no_warning'] = true;
         if ($infocomID) {
             $fields['id'] = $infocomID;
             $ic->update($fields);
         } else {
             $ic->add($fields);
         }
     }
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:63,代码来源:link.class.php

示例11: foreach

     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":
     $ic = new Infocom();
     if ($ic->canCreate()) {
         foreach ($_POST["item"] as $key => $val) {
             $input = array('itemtype' => $_POST['itemtype'], 'items_id' => $key);
             if (!$ic->getFromDBforDevice($_POST['itemtype'], $key)) {
                 $ic->add($input);
             }
         }
     }
     break;
 case "change_authtype":
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $ids[] = $key;
         }
     }
     User::changeAuthMethod($ids, $_POST["authtype"], $_POST["auths_id"]);
     break;
 case "unlock_ocsng_field":
     $fields = OcsServer::getLockableFields();
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php

示例12: canDeleteItem

 /**
  * Have I the right to "delete" the Object
  *
  * Default is calling canCreateItem
  * May be overloaded if needed
  *
  * @return booleen
  * @see canCreate
  **/
 function canDeleteItem()
 {
     global $CFG_GLPI;
     if (!$this->canCreateItem()) {
         return false;
     }
     // Can delete an object with Infocom only if can delete Infocom
     if (in_array($this->getType(), $CFG_GLPI['infocom_types'])) {
         $infocom = new Infocom();
         if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
             return $infocom->canDelete();
         }
     }
     return true;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:24,代码来源:commondbtm.class.php

示例13: getComments

 /**
  * Get comments of the Object
  *
  * @return String: comments of the object in the current language (HTML)
  **/
 function getComments()
 {
     $comment = "";
     $toadd = array();
     if ($this->isField('completename')) {
         $toadd[] = array('name' => __('Complete name'), 'value' => nl2br($this->getField('completename')));
     }
     if ($this->isField('serial')) {
         $toadd[] = array('name' => __('Serial number'), 'value' => nl2br($this->getField('serial')));
     }
     if ($this->isField('otherserial')) {
         $toadd[] = array('name' => __('Inventory number'), 'value' => nl2br($this->getField('otherserial')));
     }
     if ($this->isField('states_id') && $this->getType() != 'State') {
         $tmp = Dropdown::getDropdownName('glpi_states', $this->getField('states_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $toadd[] = array('name' => __('Status'), 'value' => $tmp);
         }
     }
     if ($this->isField('locations_id') && $this->getType() != 'Location') {
         $tmp = Dropdown::getDropdownName("glpi_locations", $this->getField('locations_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $toadd[] = array('name' => __('Location'), 'value' => $tmp);
         }
     }
     if ($this->isField('users_id')) {
         $tmp = getUserName($this->getField('users_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $toadd[] = array('name' => __('User'), 'value' => $tmp);
         }
     }
     if ($this->isField('groups_id') && $this->getType() != 'Group') {
         $tmp = Dropdown::getDropdownName("glpi_groups", $this->getField('groups_id'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $toadd[] = array('name' => __('Group'), 'value' => $tmp);
         }
     }
     if ($this->isField('users_id_tech')) {
         $tmp = getUserName($this->getField('users_id_tech'));
         if (strlen($tmp) != 0 && $tmp != '&nbsp;') {
             $toadd[] = array('name' => __('Technician in charge of the hardware'), 'value' => $tmp);
         }
     }
     if ($this->isField('contact')) {
         $toadd[] = array('name' => __('Alternate username'), 'value' => nl2br($this->getField('contact')));
     }
     if ($this->isField('contact_num')) {
         $toadd[] = array('name' => __('Alternate username number'), 'value' => nl2br($this->getField('contact_num')));
     }
     if (InfoCom::canApplyOn($this)) {
         $infocom = new Infocom();
         if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
             $toadd[] = array('name' => __('Warranty expiration date'), 'value' => Infocom::getWarrantyExpir($infocom->fields["warranty_date"], $infocom->fields["warranty_duration"], 0, true));
         }
     }
     if ($this instanceof CommonDropdown && $this->isField('comment')) {
         $toadd[] = array('name' => __('Comments'), 'value' => nl2br($this->getField('comment')));
     }
     if (count($toadd)) {
         foreach ($toadd as $data) {
             // Do not use SPAN here
             $comment .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $data['name'], "</strong>" . $data['value']);
         }
     }
     if (!empty($comment)) {
         return Html::showToolTip($comment, array('display' => false));
     }
     return $comment;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:74,代码来源:commondbtm.class.php

示例14: doMassiveActions


//.........这里部分代码省略.........
                         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"];
                         }
                     }
                     foreach ($input["item"] as $key => $val) {
                         if ($val == 1) {
                             if ($this->getFromDB($key)) {
                                 if ($link_entity_type < 0 || $link_entity_type == $this->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $this->getEntityID()))) {
                                     $input2["items_id"] = $key;
                                     $input2["itemtype"] = $input["itemtype"];
                                     if ($ic->can(-1, 'w', $input2)) {
                                         // Add infocom if not exists
                                         if (!$ic->getFromDBforDevice($input["itemtype"], $key)) {
                                             $input2["items_id"] = $key;
                                             $input2["itemtype"] = $input["itemtype"];
                                             unset($ic->fields);
                                             $ic->add($input2);
                                             $ic->getFromDBforDevice($input["itemtype"], $key);
                                         }
                                         $id = $ic->fields["id"];
                                         unset($ic->fields);
                                         if ($ic->update(array('id' => $id, $input["field"] => $input[$input["field"]]))) {
                                             $res['ok']++;
                                         } else {
                                             $res['ko']++;
                                         }
                                     } else {
                                         $res['noright']++;
                                     }
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         }
                     }
                 } else {
                     /// Not infocoms
                     $link_entity_type = array();
                     /// Specific entity item
                     $itemtable = getTableForItemType($input["itemtype"]);
                     $itemtype2 = getItemTypeForTable($searchopt[$input["id_field"]]["table"]);
                     if ($item2 = getItemForItemtype($itemtype2)) {
                         if ($input["id_field"] != 80 && $searchopt[$input["id_field"]]["table"] != $itemtable && $item2->isEntityAssign() && $this->isEntityAssign()) {
开发者ID:gaforeror,项目名称:glpi,代码行数:67,代码来源:commondbtm.class.php

示例15: getItem


//.........这里部分代码省略.........
             if ($connect_item->canView()) {
                 $query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n                         `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n                         `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n                         `glpi_computers_items`.`items_id` AS assoc_items_id,\n                         `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n                         " . getTableForItemType($connect_type) . ".*\n                         FROM `glpi_computers_items`\n                         LEFT JOIN `" . getTableForItemType($connect_type) . "`\n                           ON (`" . getTableForItemType($connect_type) . "`.`id`\n                                 = `glpi_computers_items`.`items_id`)\n                         WHERE `computers_id` = '{$id}'\n                               AND `itemtype` = '" . $connect_type . "'\n                               AND `glpi_computers_items`.`is_deleted` = '0'";
                 if ($result = $DB->query($query)) {
                     while ($data = $DB->fetch_assoc($result)) {
                         $fields['_connections'][$connect_type][] = $data;
                     }
                 }
             }
         }
     }
     // retrieve item networkports
     if (isset($params['with_networkports']) && $params['with_networkports']) {
         $fields['_networkports'] = array();
         if (!NetworkEquipment::canView()) {
             $fields['_networkports'] = self::arrayRightError();
         } else {
             foreach (NetworkPort::getNetworkPortInstantiations() as $networkport_type) {
                 $query = "SELECT\n                           netp.`entities_id`,\n                           netp.`is_recursive`,\n                           netp.`logical_number`,\n                           netp.`name`,\n                           netp.`mac`,\n                           netp.`comment`,\n                           netp.`is_dynamic`,\n                           netp_subtable.*\n                         FROM glpi_networkports AS netp\n                         LEFT JOIN " . $networkport_type::getTable() . " AS netp_subtable\n                           ON netp_subtable.`networkports_id` = netp.`id`\n                         WHERE netp.`instantiation_type` = '{$networkport_type}'\n                               AND netp.`items_id` = '{$id}'\n                               AND netp.`itemtype` = '{$itemtype}'\n                               AND netp.`is_deleted` = '0'";
                 if ($result = $DB->query($query)) {
                     while ($data = $DB->fetch_assoc($result)) {
                         $fields['_networkports'][$networkport_type][] = $data;
                     }
                 }
             }
         }
     }
     // retrieve item infocoms
     if (isset($params['with_infocoms']) && $params['with_infocoms']) {
         $fields['_infocoms'] = array();
         if (!Infocom::canView()) {
             $fields['_infocoms'] = self::arrayRightError();
         } else {
             $ic = new Infocom();
             if ($ic->getFromDBforDevice($itemtype, $id)) {
                 $fields['_infocoms'] = $ic->fields;
             }
         }
     }
     // retrieve item contracts
     if (isset($params['with_contracts']) && $params['with_contracts']) {
         $fields['_contracts'] = array();
         if (!Contract::canView()) {
             $fields['_contracts'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_contracts_items`.*\n                     FROM `glpi_contracts_items`,\n                          `glpi_contracts`\n                     LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n                     WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n                           AND `glpi_contracts_items`.`items_id` = '{$id}'\n                           AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n                     ORDER BY `glpi_contracts`.`name`";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_contracts'][] = $data;
                 }
             }
         }
     }
     // retrieve item contracts
     if (isset($params['with_documents']) && $params['with_documents']) {
         $fields['_documents'] = array();
         if (!$itemtype != 'Ticket' && $itemtype != 'KnowbaseItem' && $itemtype != 'Reminder' && !Document::canView()) {
             $fields['_documents'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_documents_items`.`id` AS assocID,\n                             `glpi_documents_items`.`date_mod` AS assocdate,\n                             `glpi_entities`.`id` AS entityID,\n                             `glpi_entities`.`completename` AS entity,\n                             `glpi_documentcategories`.`completename` AS headings,\n                             `glpi_documents`.*\n                      FROM `glpi_documents_items`\n                      LEFT JOIN `glpi_documents`\n                                ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n                      LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n                      LEFT JOIN `glpi_documentcategories`\n                              ON (`glpi_documents`.`documentcategories_id`=`glpi_documentcategories`.`id`)\n                      WHERE `glpi_documents_items`.`items_id` = '{$id}'\n                            AND `glpi_documents_items`.`itemtype` = '{$itemtype}' ";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_documents'][] = $data;
                 }
             }
         }
     }
开发者ID:stweil,项目名称:glpi,代码行数:67,代码来源:api.class.php


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