/** * Print the computers disks * * @param $comp Computer object * @param $withtemplate boolean Template or basic item (default '') * * @return Nothing (call to classes members) **/ static function showForComputer(Computer $comp, $withtemplate = '') { global $DB; $ID = $comp->fields['id']; if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) { return false; } $canedit = $comp->canEdit($ID); if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) { echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computerdisk.form.php?computers_id={$ID}&withtemplate=" . $withtemplate . "'>"; _e('Add a volume'); echo "</a></div>\n"; } echo "<div class='center'>"; $query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$ID}'\n AND `is_deleted` = '0'"; if ($result = $DB->query($query)) { echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; $colspan = 7; if (Plugin::haveImport()) { $colspan++; } echo "<tr class='noHover'><th colspan='{$colspan}'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>"; if ($DB->numrows($result)) { $header = "<tr><th>" . __('Name') . "</th>"; if (Plugin::haveImport()) { $header .= "<th>" . __('Automatic inventory') . "</th>"; } $header .= "<th>" . __('Partition') . "</th>"; $header .= "<th>" . __('Mount point') . "</th>"; $header .= "<th>" . __('File system') . "</th>"; $header .= "<th>" . __('Global size') . "</th>"; $header .= "<th>" . __('Free size') . "</th>"; $header .= "<th>" . __('Free percentage') . "</th>"; $header .= "</tr>"; echo $header; Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName())); $disk = new self(); while ($data = $DB->fetch_assoc($result)) { $disk->getFromDB($data['id']); echo "<tr class='tab_bg_2'>"; echo "<td>" . $disk->getLink() . "</td>"; if (Plugin::haveImport()) { echo "<td>" . Dropdown::getYesNo($data['is_dynamic']) . "</td>"; } echo "<td>" . $data['device'] . "</td>"; echo "<td>" . $data['mountpoint'] . "</td>"; echo "<td>" . $data['fsname'] . "</td>"; //TRANS: %s is a size $tmp = sprintf(__('%s Mio'), Html::formatNumber($data['totalsize'], false, 0)); echo "<td class='right'>{$tmp}<span class='small_space'></span></td>"; $tmp = sprintf(__('%s Mio'), Html::formatNumber($data['freesize'], false, 0)); echo "<td class='right'>{$tmp}<span class='small_space'></span></td>"; echo "<td>"; $percent = 0; if ($data['totalsize'] > 0) { $percent = round(100 * $data['freesize'] / $data['totalsize']); } Html::displayProgressBar('100', $percent, array('simple' => true, 'forcepadding' => false)); echo "</td>"; echo "</tr>"; Session::addToNavigateListItems(__CLASS__, $data['id']); } echo $header; } else { echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>" . __('No item found') . "</th></tr>"; } echo "</table>"; } echo "</div><br>"; }
/** * Print the computers disks * * @param $comp Computer object * * @return Nothing (call to classes members) **/ static function showForComputer(Computer $comp) { global $DB; $ID = $comp->fields['id']; if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) { return false; } $canedit = $comp->canEdit($ID); if ($canedit) { echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computervirtualmachine.form.php?computers_id={$ID}'>"; _e('Add a virtual machine'); echo "</a></div>\n"; } echo "<div class='center'>"; $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}' AND `is_deleted` = '0'"); echo "<table class='tab_cadre_fixehov'>"; Session::initNavigateListItems('ComputerVirtualMachine', sprintf(__('%1$s = %2$s'), __('Computer'), empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name'])); if (empty($virtualmachines)) { echo "<tr><th>" . __('No virtual machine associated with the computer') . "</th></tr>"; } else { echo "<tr class='noHover'><th colspan='10'>" . __('List of virtual machines') . "</th></tr>"; $header = "<tr><th>" . __('Name') . "</th>"; if (Plugin::haveImport()) { $header .= "<th>" . __('Automatic inventory') . "</th>"; } $header .= "<th>" . __('Virtualization system') . "</th>"; $header .= "<th>" . __('Virtualization model') . "</th>"; $header .= "<th>" . __('State of the virtual machine') . "</th>"; $header .= "<th>" . __('UUID') . "</th>"; $header .= "<th>" . _x('quantity', 'Processors number') . "</th>"; $header .= "<th>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</th>"; $header .= "<th>" . __('Machine') . "</th>"; $header .= "</tr>"; echo $header; $vm = new self(); foreach ($virtualmachines as $virtualmachine) { $vm->getFromDB($virtualmachine['id']); echo "<tr class='tab_bg_2'>"; echo "<td>" . $vm->getLink() . "</td>"; if (Plugin::haveImport()) { echo "<td>" . Dropdown::getYesNo($vm->isDynamic()) . "</td>"; } echo "<td>"; echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']); echo "</td>"; echo "<td>" . $virtualmachine['uuid'] . "</td>"; echo "<td>" . $virtualmachine['vcpu'] . "</td>"; echo "<td>" . $virtualmachine['ram'] . "</td>"; echo "<td>"; if ($link_computer = self::findVirtualMachine($virtualmachine)) { $computer = new Computer(); if ($computer->can($link_computer, READ)) { $url = "<a href='computer.form.php?id=" . $link_computer . "'>"; $url .= $computer->fields["name"] . "</a>"; $tooltip = "<table><tr><td>" . __('Name') . "</td><td>" . $computer->fields['name'] . '</td></tr>'; $tooltip .= "<tr><td>" . __('Serial number') . "</td><td>" . $computer->fields['serial'] . '</td></tr>'; $tooltip .= "<tr><td>" . __('Comments') . "</td><td>" . $computer->fields['comment'] . '</td></tr></table>'; $url .= " " . Html::showToolTip($tooltip, array('display' => false)); } else { $url = $computer->fields['name']; } echo $url; } echo "</td>"; echo "</tr>"; Session::addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']); } echo $header; } echo "</table>"; echo "</div>"; }
/** * Print the computers antiviruses * * @param $comp Computer object * @param $withtemplate boolean Template or basic item (default '') * * @return Nothing (call to classes members) **/ static function showForComputer(Computer $comp, $withtemplate = '') { global $DB; $ID = $comp->fields['id']; if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) { return false; } $canedit = $comp->canEdit($ID); if ($canedit && !(!empty($withtemplate) && $withtemplate == 2)) { echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='computerantivirus.form.php?computers_id={$ID}&withtemplate=" . $withtemplate . "'>"; _e('Add an antivirus'); echo "</a></div>\n"; } echo "<div class='spaced center'>"; if ($result = $DB->request('glpi_computerantiviruses', array('computers_id' => $ID, 'is_deleted' => 0))) { echo "<table class='tab_cadre_fixehov'>"; $colspan = 7; if (Plugin::haveImport()) { $colspan++; } echo "<tr class='noHover'><th colspan='{$colspan}'>" . self::getTypeName($result->numrows()) . "</th></tr>"; if ($result->numrows() != 0) { $header = "<tr><th>" . __('Name') . "</th>"; if (Plugin::haveImport()) { $header .= "<th>" . __('Automatic inventory') . "</th>"; } $header .= "<th>" . __('Manufacturer') . "</th>"; $header .= "<th>" . __('Antivirus version') . "</th>"; $header .= "<th>" . __('Signature database version') . "</th>"; $header .= "<th>" . __('Active') . "</th>"; $header .= "<th>" . __('Up to date') . "</th>"; $header .= "<th>" . __('Expiration date') . "</th>"; $header .= "</tr>"; echo $header; Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName())); $antivirus = new self(); foreach ($result as $data) { $antivirus->getFromDB($data['id']); echo "<tr class='tab_bg_2'>"; echo "<td>" . $antivirus->getLink() . "</td>"; if (Plugin::haveImport()) { echo "<td>" . Dropdown::getYesNo($data['is_dynamic']) . "</td>"; } echo "<td>"; if ($data['manufacturers_id']) { echo Dropdown::getDropdownName('glpi_manufacturers', $data['manufacturers_id']) . "</td>"; } else { echo "</td>"; } echo "<td>" . $data['antivirus_version'] . "</td>"; echo "<td>" . $data['signature_version'] . "</td>"; echo "<td>" . Dropdown::getYesNo($data['is_active']) . "</td>"; echo "<td>" . Dropdown::getYesNo($data['is_uptodate']) . "</td>"; echo "<td>" . Html::convDate($data['date_expiration']) . "</td>"; echo "</tr>"; Session::addToNavigateListItems(__CLASS__, $data['id']); } echo $header; } else { echo "<tr class='tab_bg_2'><th colspan='{$colspan}'>" . __('No item found') . "</th></tr>"; } echo "</table>"; } echo "</div>"; }
/** * * Print the form for computers or templates connections to printers, screens or peripherals * * @param $comp Computer object * @param $withtemplate boolean Template or basic item (default '') * * @return Nothing (call to classes members) **/ static function showForComputer(Computer $comp, $withtemplate = '') { global $DB, $CFG_GLPI; $ID = $comp->fields['id']; $canedit = $comp->canEdit($ID); $rand = mt_rand(); $datas = array(); $used = array(); foreach ($CFG_GLPI["directconnect_types"] as $itemtype) { $item = new $itemtype(); if ($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($itemtype) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($itemtype) . "`\n ON (`" . getTableForItemType($itemtype) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$ID}'\n AND `itemtype` = '" . $itemtype . "'\n AND `glpi_computers_items`.`is_deleted` = '0'"; if ($item->maybetemplate()) { $query .= " AND NOT `" . getTableForItemType($itemtype) . "`.`is_template` "; } if ($result = $DB->query($query)) { while ($data = $DB->fetch_assoc($result)) { $datas[] = $data; $used[$itemtype][] = $data['assoc_items_id']; } } } } $number = count($datas); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='computeritem_form{$rand}' id='computeritem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Connect an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; if (!empty($withtemplate)) { echo "<input type='hidden' name='_no_history' value='1'>"; } self::dropdownAllConnect('Computer', "items_id", $comp->fields["entities_id"], $withtemplate, $used); echo "</td><td class='center' width='20%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Connect') . "\" class='submit'>"; echo "<input type='hidden' name='computers_id' value='" . $comp->fields['id'] . "'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } if ($number) { echo "<div class='spaced'>"; if ($canedit) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Disconnect')), 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Name') . "</th>"; if (Plugin::haveImport()) { $header_end .= "<th>" . __('Automatic inventory') . "</th>"; } $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Serial number') . "</th>"; $header_end .= "<th>" . __('Inventory number') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; foreach ($datas as $data) { $linkname = $data["name"]; $itemtype = $data['assoc_itemtype']; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]); } $link = Toolbox::getItemTypeFormURL($itemtype); $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["assoc_id"]); echo "</td>"; } echo "<td class='center'>" . $data['assoc_itemtype']::getTypeName(1) . "</td>"; echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; if (Plugin::haveImport()) { echo "<td>" . Dropdown::getYesNo($data['assoc_is_dynamic']) . "</td>"; } echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']); echo "</td>"; echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; } }