ComputerDisk::showForComputer PHP Method

showForComputer() static public method

Print the computers disks
static public showForComputer ( Computer $comp, $withtemplate = '' ) : Nothing
$comp Computer Computer object
$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}&amp;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'>";
            $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 = Toolbox::getSize($data['totalsize'] * 1024 * 1024);
                    echo "<td class='right'>{$tmp}<span class='small_space'></span></td>";
                    $tmp = Toolbox::getSize($data['freesize'] * 1024 * 1024);
                    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>";
    }

Usage Example

Esempio n. 1
0
            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();