ComputerVirtualMachine::showForVirtualMachine PHP Method

showForVirtualMachine() static public method

Show hosts for a virtualmachine
static public showForVirtualMachine ( Computer $comp ) : Nothing
$comp Computer Computer object that represents the virtual machine
return Nothing (call to classes members)
    static function showForVirtualMachine(Computer $comp)
    {
        global $DB;
        $ID = $comp->fields['id'];
        if (!$comp->getFromDB($ID) || !$comp->can($ID, READ)) {
            return false;
        }
        $canedit = $comp->canEdit($ID);
        echo "<div class='center'>";
        if (isset($comp->fields['uuid']) && $comp->fields['uuid'] != '') {
            $where = "LOWER(`uuid`)" . self::getUUIDRestrictRequest($comp->fields['uuid']);
            $hosts = getAllDatasFromTable('glpi_computervirtualmachines', $where);
            if (!empty($hosts)) {
                echo "<table class='tab_cadre_fixehov'>";
                echo "<tr class='noHover'><th colspan='2' >" . __('List of host machines') . "</th></tr>";
                $header = "<tr><th>" . __('Name') . "</th>";
                $header .= "<th>" . __('Entity') . "</th>";
                $header .= "</tr>";
                echo $header;
                $computer = new Computer();
                foreach ($hosts as $host) {
                    echo "<tr class='tab_bg_2'>";
                    echo "<td>";
                    if ($computer->can($host['computers_id'], READ)) {
                        echo "<a href='computer.form.php?id=" . $computer->fields['id'] . "'>";
                        echo $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>';
                        echo "&nbsp; " . Html::showToolTip($tooltip, array('display' => false));
                    } else {
                        echo $computer->fields['name'];
                    }
                    echo "</td>";
                    echo "<td>";
                    echo Dropdown::getDropdownName('glpi_entities', $computer->fields['entities_id']);
                    echo "</td></tr>";
                }
                echo $header;
                echo "</table>";
            }
        }
        echo "</div>";
        if (!empty($hosts)) {
            echo "<br>";
        }
    }

Usage Example

            case 10:
                showNotesForm($_POST['target'], 'Computer', $_POST["id"]);
                break;
            case 11:
                Reservation::showForItem('Computer', $_POST["id"]);
                break;
            case 12:
                Log::showForItem($computer);
                break;
            case 13:
                OcsLink::showForItem($computer);
                OcsServer::editLock($_POST['target'], $_POST["id"]);
                break;
            case 14:
                RegistryKey::showForComputer($_POST["id"]);
                break;
            case 20:
                ComputerDisk::showForComputer($computer);
                break;
            case 21:
                ComputerVirtualMachine::showForVirtualMachine($computer);
                ComputerVirtualMachine::showForComputer($computer);
                break;
            default:
                if (!Plugin::displayAction($computer, $_REQUEST['glpi_tab'])) {
                    Computer_Device::showForComputer($computer);
                }
        }
    }
}
ajaxFooter();