Exemple #1
0
function renderDepot()
{
    global $pageno, $nextorder;
    $cellfilter = getCellFilter();
    $objects = array();
    $objects_count = getEntitiesCount('object');
    echo "<table border=0 class=objectview>\n";
    echo "<tr><td class=pcleft>";
    if ($objects_count == 0) {
        echo '<h2>No objects exist</h2>';
    } elseif (!($cellfilter['is_empty'] && renderEmptyResults($cellfilter, 'objects', $objects_count))) {
        $objects = applyCellFilter('object', $cellfilter);
        // 2nd attempt: do not render all fetched objects if rendering empty result is enabled
        if (!renderEmptyResults($cellfilter, 'objects', count($objects))) {
            startPortlet('Objects (' . count($objects) . ')');
            echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
            echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Row/Rack or Container</th></tr>';
            $order = 'odd';
            # gather IDs of all objects and fetch rackspace info in one pass
            $idlist = array();
            foreach ($objects as $obj) {
                $idlist[] = $obj['id'];
            }
            $mountinfo = getMountInfo($idlist);
            $containerinfo = getContainerInfo($idlist);
            foreach ($objects as $obj) {
                $problem = $obj['has_problems'] == 'yes' ? 'has_problems' : '';
                echo "<tr class='row_{$order} tdleft {$problem}' valign=top><td>" . mkA("<strong>{$obj['dname']}</strong>", 'object', $obj['id']);
                if (count($obj['etags'])) {
                    echo '<br><small>' . serializeTags($obj['etags'], makeHref(array('page' => $pageno, 'tab' => 'default')) . '&') . '</small>';
                }
                echo "</td><td>{$obj['label']}</td>";
                echo "<td>{$obj['asset_no']}</td>";
                $places = array();
                if (array_key_exists($obj['id'], $containerinfo)) {
                    foreach ($containerinfo[$obj['id']] as $ci) {
                        $places[] = mkA($ci['container_dname'], 'object', $ci['container_id']);
                    }
                }
                if (array_key_exists($obj['id'], $mountinfo)) {
                    foreach ($mountinfo[$obj['id']] as $mi) {
                        $places[] = mkA($mi['row_name'], 'row', $mi['row_id']) . '/' . mkA($mi['rack_name'], 'rack', $mi['rack_id']);
                    }
                }
                if (!count($places)) {
                    $places[] = 'Unmounted';
                }
                echo "<td>" . implode(', ', $places) . '</td>';
                echo '</tr>';
                $order = $nextorder[$order];
            }
            echo '</table>';
            finishPortlet();
        }
    }
    echo "</td><td class=pcright width='25%'>";
    renderCellFilterPortlet($cellfilter, 'object', $objects);
    echo "</td></tr></table>\n";
}
Exemple #2
0
function renderDepot()
{
    global $pageno, $nextorder;
    $cellfilter = getCellFilter();
    $objects = filterCellList(listCells('object'), $cellfilter['expression']);
    echo "<table border=0 class=objectview>\n";
    echo "<tr><td class=pcleft>";
    if (!renderEmptyResults($cellfilter, 'objects', count($objects))) {
        if (count($objects) > 0) {
            startPortlet('Objects (' . count($objects) . ')');
            echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
            echo '<tr><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Row/Rack or Container</th></tr>';
            $order = 'odd';
            # gather IDs of all objects and fetch rackspace info in one pass
            $idlist = array();
            foreach ($objects as $obj) {
                $idlist[] = $obj['id'];
            }
            $mountinfo = getMountInfo($idlist);
            foreach ($objects as $obj) {
                echo "<tr class='row_{$order} tdleft' valign=top><td><a href='" . makeHref(array('page' => 'object', 'object_id' => $obj['id'])) . "'><strong>{$obj['dname']}</strong></a>";
                if (count($obj['etags'])) {
                    echo '<br><small>' . serializeTags($obj['etags'], makeHref(array('page' => $pageno, 'tab' => 'default')) . '&') . '</small>';
                }
                echo "</td><td>{$obj['label']}</td>";
                echo "<td>{$obj['asset_no']}</td>";
                $places = array();
                if ($obj['container_id']) {
                    $places[] = mkA($obj['container_name'], 'object', $obj['container_id']);
                } elseif (!array_key_exists($obj['id'], $mountinfo)) {
                    $places[] = 'Unmounted';
                } else {
                    foreach ($mountinfo[$obj['id']] as $mi) {
                        $places[] = mkA($mi['row_name'], 'row', $mi['row_id']) . '/' . mkA($mi['rack_name'], 'rack', $mi['rack_id']);
                    }
                }
                echo "<td>" . implode(', ', $places) . '</td>';
                echo '</tr>';
                $order = $nextorder[$order];
            }
            echo '</table>';
            finishPortlet();
        } else {
            echo '<h2>No objects exist</h2>';
        }
    }
    echo "</td><td class=pcright width='25%'>";
    renderCellFilterPortlet($cellfilter, 'object', $objects);
    echo "</td></tr></table>\n";
}