/** * @since version 0.85 * * @see CommonDBTM::getForbiddenStandardMassiveAction() **/ function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); if (count(static::getSpecificities()) == 0 && !InfoCom::canApplyOn($this)) { $forbidden[] = 'update'; } return $forbidden; }
/** * Is the search item related to infocoms * * @param $itemtype item type * @param $searchID ID of the element in $SEARCHOPTION * * @return boolean **/ static function isInfocomOption($itemtype, $searchID) { global $CFG_GLPI; return ($searchID >= 25 && $searchID <= 28 || $searchID >= 37 && $searchID <= 38 || $searchID >= 50 && $searchID <= 59 || $searchID >= 120 && $searchID <= 125) && InfoCom::canApplyOn($itemtype); }
/** * 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(); } } }
static function uninstall($type, $model_id, $tab_ids, $location) { global $UNINSTALL_DIRECT_CONNECTIONS_TYPE; //Get the model $model = new PluginUninstallModel(); $model->getConfig($model_id); //Then destroy all the connexions $transfer = new Transfer(); $transfer->getFromDB($model->fields["transfers_id"]); echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'><tr><th>" . __('Uninstall', 'uninstall') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>"; $count = 0; $tot = count($tab_ids[$type]); Html::createProgressBar(__('Please wait, uninstallation is running...', 'uninstall')); foreach ($tab_ids[$type] as $id => $value) { $count++; $item = new $type(); $item->getFromDB($id); //First clean object and change location and status if needed $entity = $item->fields["entities_id"]; $input = array(); $input["id"] = $id; $input["entities_id"] = $entity; $fields = array(); //Hook to perform actions before item is being uninstalled $item->fields['_uninstall_event'] = $model->getID(); $item->fields['_action'] = 'uninstall'; Plugin::doHook("plugin_uninstall_before", $item); //--------------------// //Direct connections // //------------------// if (in_array($type, $UNINSTALL_DIRECT_CONNECTIONS_TYPE)) { $conn = new Computer_Item(); $conn->deleteByCriteria(array('computers_id' => $id), true); } //--------------------// //-- Common fields --// //------------------// //RAZ contact and contactnumber if ($item->isField('contact') && $model->fields["raz_contact"] == 1) { $fields["contact"] = ''; if ($item->isField('contact_num')) { $fields["contact_num"] = ''; } } //RAZ user if ($model->fields["raz_user"] == 1 && $item->isField('users_id')) { $fields["users_id"] = 0; } //RAZ status if ($model->fields["states_id"] > 0 && $item->isField('states_id')) { $fields["states_id"] = $model->fields["states_id"]; } //RAZ machine's name if ($item->isField('name') && $model->fields["raz_name"] == 1) { $fields["name"] = ''; } if ($item->isField('locations_id')) { if ($location == '') { $location = 0; } switch ($location) { case -1: break; default: $fields["locations_id"] = $location; break; } } if ($item->isField('groups_id')) { $nbgroup = countElementsInTableForEntity("glpi_groups", $entity, "`id`='" . $item->fields['groups_id'] . "'"); if ($model->fields["groups_id"] > -1 && $nbgroup == 1) { // If a new group is defined and if the group is accessible in the object's entity $fields["groups_id"] = $model->fields["groups_id"]; } } //------------------------------// //-- Computer specific fields --// //------------------------------// if ($type == 'Computer') { //RAZ all OS related informations if ($model->fields["raz_os"] == 1) { $fields["operatingsystems_id"] = 0; $fields["operatingsystemversions_id"] = 0; $fields["operatingsystemservicepacks_id"] = 0; $fields["os_licenseid"] = ''; $fields["os_license_number"] = ''; $fields["autoupdatesystems_id"] = 0; } $plug = new Plugin(); if ($plug->isActivated('ocsinventoryng')) { if ($item->fields["is_dynamic"] && ($model->fields["remove_from_ocs"] || $model->fields["delete_ocs_link"])) { $input["is_dynamic"] = 0; } } if ($item->isField('domains_id') && $model->fields["raz_domain"]) { $fields["domains_id"] = 0; } //RAZ network if ($item->isField('networks_id') && $model->fields["raz_network"] == 1) { $fields["networks_id"] = 0; } } //RAZ IPs from all the network cards if ($model->fields["raz_ip"] == 1) { self::razPortInfos($type, $id); // For NetworkEquiment if ($item->isField('ip')) { $fields['ip'] = ''; } if ($item->isField('mac')) { $fields['mac'] = ''; } } foreach ($fields as $name => $value) { if (!($item->getField($name) != NOT_AVAILABLE) || $item->getField($name) != $value) { $input[$name] = $value; } } $item->dohistory = true; $item->update($input); if ($model->fields["raz_budget"] == 1) { $infocom_id = self::getInfocomPresentForDevice($type, $id); if ($infocom_id > 0) { $infocom = new InfoCom(); $tmp["id"] = $infocom_id; $tmp["budgets_id"] = 0; $infocom->dohistory = false; $infocom->update($tmp); } } //Delete machine from glpi_ocs_link if ($type == 'Computer') { //Delete computer's volumes self::purgeComputerVolumes($id); if ($model->fields["raz_history"] == 1) { //Delete history related to software self::deleteHistory($id, false); } else { if ($model->fields["raz_soft_history"] == 1) { //Delete history related to software self::deleteHistory($id, true); } } $plug = new Plugin(); if ($plug->isActivated('ocsinventoryng')) { //Delete computer from OCS if ($model->fields["remove_from_ocs"] == 1) { self::deleteComputerInOCSByGlpiID($id); } //Delete link in glpi_ocs_link if ($model->fields["delete_ocs_link"] || $model->fields["remove_from_ocs"]) { self::deleteOcsLink($id); } } //Should never happend that transfer_id = 0, but just in case if ($model->fields["transfers_id"] > 0) { $transfer->moveItems(array($type => array($id => $id)), $entity, $transfer->fields); } } if ($model->fields['raz_fusioninventory'] == 1) { self::deleteFusionInventoryLink($type, $id); } //Plugin hook after uninstall Plugin::doHook("plugin_uninstall_after", $item); Html::changeProgressBarPosition($count, $tot + 1); } //Add line in machine's history to say that machine was uninstalled self::addUninstallLog($type, $id); Html::changeProgressBarPosition($count, $tot, __('Uninstallation successful', 'uninstall')); echo "</td></tr>"; echo "</table></div>"; }
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 */ include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); if (!isset($_POST["itemtype"]) || !($item = getItemForItemtype($_POST['itemtype']))) { exit; } if (InfoCom::canApplyOn($_POST["itemtype"])) { Session::checkSeveralRightsOr(array($_POST["itemtype"] => UPDATE, "infocom" => UPDATE)); } else { $item->checkGlobal(UPDATE); } $inline = false; if (isset($_POST['inline']) && $_POST['inline']) { $inline = true; } $submitname = _sx('button', 'Post'); if (isset($_POST['submitname']) && $_POST['submitname']) { $submitname = stripslashes($_POST['submitname']); } if (isset($_POST["itemtype"]) && isset($_POST["id_field"]) && $_POST["id_field"]) { $search = Search::getOptions($_POST["itemtype"]); if (!isset($search[$_POST["id_field"]])) {
/** * @since version 0.85 * * @see CommonDBTM::getMassiveActionsForItemtype() **/ static function getMassiveActionsForItemtype(array &$actions, $itemtype, $is_deleted = 0, CommonDBTM $checkitem = NULL) { $action_name = __CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'activate'; if (InfoCom::canApplyOn($itemtype) && static::canCreate()) { $actions[$action_name] = __('Enable the financial and administrative information'); } }
/** * transfer an item to another item (may be the same) in the new entity * * @param $itemtype item type to transfer * @param $ID ID of the item to transfer * @param $newID new ID of the ite * * Transfer item to a new Item if $ID==$newID : only update entities_id field : * $ID!=$new ID -> copy datas (like template system) * @return nothing (diplays) **/ function transferItem($itemtype, $ID, $newID) { global $CFG_GLPI, $DB; if (!($item = getItemForItemtype($itemtype))) { return; } // Is already transfer ? if (!isset($this->already_transfer[$itemtype][$ID])) { // Check computer exists ? if ($item->getFromDB($newID)) { // Network connection ? keep connected / keep_disconnected / delete if (in_array($itemtype, array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'))) { $this->transferNetworkLink($itemtype, $ID, $newID); } // Device : keep / delete : network case : delete if net connection delete in import case if (in_array($itemtype, Item_Devices::getConcernedItems())) { $this->transferDevices($itemtype, $ID, $newID); } // Reservation : keep / delete if (in_array($itemtype, $CFG_GLPI["reservation_types"])) { $this->transferReservations($itemtype, $ID, $newID); } // History : keep / delete $this->transferHistory($itemtype, $ID, $newID); // Ticket : delete / keep and clean ref / keep and move $this->transferTickets($itemtype, $ID, $newID); // Infocoms : keep / delete if (InfoCom::canApplyOn($itemtype)) { $this->transferInfocoms($itemtype, $ID, $newID); } if ($itemtype == 'Software') { $this->transferSoftwareLicensesAndVersions($ID); } // Connected item is transfered if (in_array($itemtype, $CFG_GLPI["directconnect_types"])) { $this->manageConnectionComputer($itemtype, $ID); } // Computer Direct Connect : delete link if it is the initial transfer item (no recursion) if ($this->inittype == $itemtype && in_array($itemtype, array('Monitor', 'Phone', 'Peripheral', 'Printer'))) { $this->deleteDirectConnection($itemtype, $ID); } // Contract : keep / delete + clean unused / keep unused if (in_array($itemtype, $CFG_GLPI["contract_types"])) { $this->transferContracts($itemtype, $ID, $newID); } // Contact / Supplier : keep / delete + clean unused / keep unused if ($itemtype == 'Supplier') { $this->transferSupplierContacts($ID, $newID); } // Document : keep / delete + clean unused / keep unused if (Document::canApplyOn($itemtype)) { $this->transferDocuments($itemtype, $ID, $newID); } // Transfer compatible printers if ($itemtype == 'CartridgeItem') { $this->transferCompatiblePrinters($ID, $newID); } // Cartridges and cartridges items linked to printer if ($itemtype == 'Printer') { $this->transferPrinterCartridges($ID, $newID); } // Transfer Item $input = array('id' => $newID, 'entities_id' => $this->to); // Manage Location dropdown if (isset($item->fields['locations_id'])) { $input['locations_id'] = $this->transferDropdownLocation($item->fields['locations_id']); } if (in_array($itemtype, array('Ticket', 'Problem', 'Change'))) { $input2 = $this->transferHelpdeskAdditionalInformations($item->fields); $input = array_merge($input, $input2); $this->transferTaskCategory($itemtype, $ID, $newID); $this->transferLinkedSuppliers($itemtype, $ID, $newID); } $item->update($input); $this->addToAlreadyTransfer($itemtype, $ID, $newID); // Do it after item transfer for entity checks if ($itemtype == 'Computer') { // Monitor Direct Connect : keep / delete + clean unused / keep unused $this->transferDirectConnection($itemtype, $ID, 'Monitor'); // Peripheral Direct Connect : keep / delete + clean unused / keep unused $this->transferDirectConnection($itemtype, $ID, 'Peripheral'); // Phone Direct Connect : keep / delete + clean unused / keep unused $this->transferDirectConnection($itemtype, $ID, 'Phone'); // Printer Direct Connect : keep / delete + clean unused / keep unused $this->transferDirectConnection($itemtype, $ID, 'Printer'); // License / Software : keep / delete + clean unused / keep unused $this->transferComputerSoftwares($ID); // Computer Disks : delete them or not ? $this->transferComputerDisks($ID); } Plugin::doHook("item_transfer", array('type' => $itemtype, 'id' => $ID, 'newID' => $newID, 'entities_id' => $this->to)); } } }
/** * @see CommonDBTM::showMassiveActionsSubForm() **/ static function showMassiveActionsSubForm(MassiveAction $ma) { global $CFG_GLPI; switch ($ma->getAction()) { case 'update': if (!isset($ma->POST['id_field'])) { $itemtypes = array_keys($ma->items); $options_per_type = array(); $options_counts = array(); foreach ($itemtypes as $itemtype) { $options_per_type[$itemtype] = array(); $group = ''; $show_all = true; $show_infocoms = true; $itemtable = getTableForItemType($itemtype); if (InfoCom::canApplyOn($itemtype) && (!$itemtype::canUpdate() || !Infocom::canUpdate())) { $show_all = false; $show_infocoms = Infocom::canUpdate(); } foreach (Search::getCleanedOptions($itemtype, UPDATE) as $index => $option) { if (!is_array($option)) { $group = $option; $options_per_type[$itemtype][$group] = array(); } else { if ($option['field'] != 'id' && $index != 1 && ($option["linkfield"] != 'entities_id' || isset($option['massiveaction']) && $option['massiveaction'])) { if (!isset($option['massiveaction']) || $option['massiveaction']) { if ($show_all || ($show_infocoms && Search::isInfocomOption($itemtype, $index) || !$show_infocoms && !Search::isInfocomOption($itemtype, $index))) { $options_per_type[$itemtype][$group][$itemtype . ':' . $index] = $option['name']; if ($itemtable == $option['table']) { $field_key = 'MAIN:' . $option['field'] . ':' . $index; } else { $field_key = $option['table'] . ':' . $option['field'] . ':' . $index; } if (!isset($options_count[$field_key])) { $options_count[$field_key] = array(); } $options_count[$field_key][] = $itemtype . ':' . $index . ':' . $group; if (isset($option['MA_common_field'])) { if (!isset($options_count[$option['MA_common_field']])) { $options_count[$option['MA_common_field']] = array(); } $options_count[$option['MA_common_field']][] = $itemtype . ':' . $index . ':' . $group; } } } } } } } if (count($itemtypes) > 1) { $common_options = array(); foreach ($options_count as $field => $users) { if (count($users) > 1) { $labels = array(); foreach ($users as $user) { $user = explode(':', $user); $itemtype = $user[0]; $index = $itemtype . ':' . $user[1]; $group = implode(':', array_slice($user, 2)); if (isset($options_per_type[$itemtype][$group][$index])) { if (!in_array($options_per_type[$itemtype][$group][$index], $labels)) { $labels[] = $options_per_type[$itemtype][$group][$index]; } } $common_options[$field][] = $index; } $options[$group][$field] = implode('/', $labels); } } $choose_itemtype = true; $itemtype_choices = array(-1 => Dropdown::EMPTY_VALUE); foreach ($itemtypes as $itemtype) { $itemtype_choices[$itemtype] = $itemtype::getTypeName(Session::getPluralNumber()); } } else { $options = $options_per_type[$itemtypes[0]]; $common_options = false; $choose_itemtype = false; } $choose_field = count($options) > 1; // Beware: "class='tab_cadre_fixe'" induce side effects ... echo "<table width='100%'><tr>"; $colspan = 0; if ($choose_field) { $colspan++; echo "<td>"; if ($common_options) { echo __('Select the common field that you want to update'); } else { echo __('Select the field that you want to update'); } echo "</td>"; if ($choose_itemtype) { $colspan++; echo "<td rowspan='2'>" . __('or') . "</td>"; } } if ($choose_itemtype) { $colspan++; echo "<td>" . __('Select the type of the item on which applying this action') . "</td>"; } echo "</tr><tr>"; if ($choose_field) { echo "<td>"; $field_rand = Dropdown::showFromArray('id_field', $options, array('display_emptychoice' => true)); echo "</td>"; } if ($choose_itemtype) { echo "<td>"; $itemtype_rand = Dropdown::showFromArray('specialize_itemtype', $itemtype_choices); echo "</td>"; } $next_step_rand = mt_rand(); echo "</tr></table>"; echo "<span id='update_next_step{$next_step_rand}'> </span>"; if ($choose_field) { $params = $ma->POST; $params['id_field'] = '__VALUE__'; $params['common_options'] = $common_options; Ajax::updateItemOnSelectEvent("dropdown_id_field{$field_rand}", "update_next_step{$next_step_rand}", $_SERVER['REQUEST_URI'], $params); } if ($choose_itemtype) { $params = $ma->POST; $params['specialize_itemtype'] = '__VALUE__'; $params['common_options'] = $common_options; Ajax::updateItemOnSelectEvent("dropdown_specialize_itemtype{$itemtype_rand}", "update_next_step{$next_step_rand}", $_SERVER['REQUEST_URI'], $params); } // Only display the form for this stage exit; } if (!isset($ma->POST['common_options'])) { echo "<div class='center'><img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='" . __s('Warning') . "'><br><br>"; echo "<span class='b'>" . __('Implementation error !') . "</span><br>"; echo "</div>"; exit; } if ($ma->POST['common_options'] == 'false') { $search_options = array($ma->POST['id_field']); } else { if (isset($ma->POST['common_options'][$ma->POST['id_field']])) { $search_options = $ma->POST['common_options'][$ma->POST['id_field']]; } else { $search_options = array(); } } $items = array(); foreach ($search_options as $search_option) { $search_option = explode(':', $search_option); $itemtype = $search_option[0]; $index = $search_option[1]; if (!($item = getItemForItemtype($itemtype))) { continue; } if (InfoCom::canApplyOn($itemtype)) { Session::checkSeveralRightsOr(array($itemtype => UPDATE, "infocom" => UPDATE)); } else { $item->checkGlobal(UPDATE); } $search = Search::getOptions($itemtype); if (!isset($search[$index])) { exit; } $item->search = $search[$index]; $items[] = $item; } if (count($items) == 0) { exit; } // TODO: ensure that all items are equivalent ... $item = $items[0]; $search = $item->search; $plugdisplay = false; if (($plug = isPluginItemType($item->getType())) || ($plug = isPluginItemType(getItemTypeForTable($item->search['table'])))) { $plugdisplay = Plugin::doOneHook($plug['plugin'], 'MassiveActionsFieldsDisplay', array('itemtype' => $item->getType(), 'options' => $item->search)); } if (empty($search["linkfield"]) || $search['table'] == 'glpi_infocoms') { $fieldname = $search["field"]; } else { $fieldname = $search["linkfield"]; } if (!$plugdisplay) { $options = array(); $values = array(); // For ticket template or aditional options of massive actions if (isset($ma->POST['options'])) { $options = $ma->POST['options']; } if (isset($ma->POST['additionalvalues'])) { $values = $ma->POST['additionalvalues']; } $values[$search["field"]] = ''; echo $item->getValueToSelect($search, $fieldname, $values, $options); } $items_index = array(); foreach ($search_options as $search_option) { $search_option = explode(':', $search_option); $items_index[$search_option[0]] = $search_option[1]; } echo Html::hidden('search_options', array('value' => $items_index)); echo Html::hidden('field', array('value' => $fieldname)); echo "<br>\n"; $submitname = _sx('button', 'Post'); if (isset($ma->POST['submitname']) && $ma->POST['submitname']) { $submitname = stripslashes($ma->POST['submitname']); } echo Html::submit($submitname, array('name' => 'massiveaction')); return true; } return false; }
/** * Return Infocom for an object * * @param $protocol the commonication protocol used * @param $params array * * @return a hasdtable, fields of glpi_infocoms **/ static function methodgetItemInfocoms($params, $protocol) { if (isset($params['help'])) { $params = array('itemtype' => 'string, mandatory', 'id' => 'integer, mandatory', 'id2name' => 'bool,optional', 'help' => 'bool,optional'); } $check = self::checkStandardParameters($params, $protocol); if (!$check == 1) { exit; } if (!Session::haveRight("infocom", READ)) { return array(); } $infocom = new InfoCom(); $item = new $params['itemtype'](); $item->getTypeName(); if (!$infocom->getFromDBforDevice($params['itemtype'], $params['id']) || !$item->can($params['id'], READ)) { return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND); } $resp = $infocom->fields; $resp['warranty_expiration'] = Infocom::getWarrantyExpir($infocom->fields['buy_date'], $infocom->fields['warranty_duration']); if ($id2name) { // TODO : more dropdown value $resp['suppliers_name'] = Html::clean(Dropdown::getDropdownName('glpi_suppliers', $infocom->fields['suppliers_id'])); $resp['budgets_names'] = Html::ml_clean(Dropdown::getDropdownName('glpi_budgets', $infocom->fields['budgets_id'])); } return $resp; }
public function removeInfoComRelatedToOrder($itemtype, $items_id) { $infocom = new InfoCom(); $infocom->getFromDBforDevice($itemtype, $items_id); $input["id"] = $infocom->fields["id"]; $input["order_number"] = ""; $input["delivery_number"] = ""; $input["budgets_id"] = 0; $input["suppliers_id"] = 0; $input["bill"] = ""; $input["value"] = 0; $input["order_date"] = NULL; $input["delivery_date"] = NULL; $infocom->update($input); }
/** * 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 != ' ') { $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 != ' ') { $toadd[] = array('name' => __('Location'), 'value' => $tmp); } } if ($this->isField('users_id')) { $tmp = getUserName($this->getField('users_id')); if (strlen($tmp) != 0 && $tmp != ' ') { $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 != ' ') { $toadd[] = array('name' => __('Group'), 'value' => $tmp); } } if ($this->isField('users_id_tech')) { $tmp = getUserName($this->getField('users_id_tech')); if (strlen($tmp) != 0 && $tmp != ' ') { $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; }
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item) { global $DB; $ID = $item->getField('id'); $type = $item->getType(); $info = new InfoCom(); $comp = new Computer(); $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . __('Direct connections') . '</b>'); $query = "SELECT *\n FROM `glpi_computers_items`\n WHERE `items_id` = '" . $ID . "'\n AND `itemtype` = '" . $type . "'"; if ($result = $DB->query($query)) { $resultnum = $DB->numrows($result); if ($resultnum > 0) { for ($j = 0; $j < $resultnum; $j++) { $tID = $DB->result($result, $j, "computers_id"); $connID = $DB->result($result, $j, "id"); $comp->getFromDB($tID); $info->getFromDBforDevice('Computer', $tID) || $info->getEmpty(); $line1 = $comp->fields['name'] ? $comp->fields['name'] : "(" . $comp->fields['id'] . ")"; if ($comp->fields['serial']) { $line1 = sprintf(__('%1$s - %2$s'), $line1, sprintf(__('%1$s: %2$s'), __('Serial number'), $comp->fields['serial'])); } $line1 = sprintf(__('%1$s - %2$s'), $line1, Html::clean(Dropdown::getDropdownName("glpi_states", $comp->fields['states_id']))); $line2 = ""; if ($comp->fields['otherserial']) { $line2 = sprintf(__('%1$s: %2$s'), __('Inventory number'), $item->getField("otherserial")); } if ($info->fields['immo_number']) { $line2 = sprintf(__('%1$s - %2$s'), $line2, sprintf(__('%1$s: %2$s'), __('Immobilization number'), $info->fields["immo_number"])); } if ($line2) { $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Computer') . '/b>', $line1 . "\n" . $line2), 2); } else { $pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Computer') . '/b>', $line1), 1); } } // each device of current type } else { // No row $pdf->displayLine(__('Not connected.')); } // No row } // Result $pdf->displaySpace(); }