/** * 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, "r")) { return false; } $canedit = $comp->can($ID, "w"); echo "<div class='spaced center'>"; $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}' AND `is_deleted` = '0'"); echo "<table class='tab_cadre_fixe'>"; 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><th colspan='10'>" . __('List of virtual machines') . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Plugin::haveImport()) { echo "<th>" . __('Automatic inventory') . "</th>"; } echo "<th>" . __('Virtualization system') . "</th>"; echo "<th>" . __('Virtualization model') . "</th>"; echo "<th>" . __('State of the virtual machine') . "</th>"; echo "<th>" . __('UUID') . "</th>"; echo "<th>" . _x('quantity', 'Processors number') . "</th>"; echo "<th>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</th>"; echo "<th>" . __('Machine') . "</th>"; echo "</tr>"; $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>"; echo Dropdown::getYesNo($vm->isDynamic()); echo "</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'] . "</a></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, 'r')) { $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']); } } if ($canedit) { echo "<tr class='tab_bg_1'><td colspan='8' class='center'>"; echo "<a class='vsubmit' href='computervirtualmachine.form.php?computers_id={$ID}'>" . __('Add a virtual machine') . "</a></td></tr>"; } echo "</table>"; echo "</div>"; }