Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>';
- // 1st attempt: do not fetch all objects if cellfilter is empty and rendering empty result is enabled
- elseif (! ($cellfilter['is_empty'] && renderEmptyResults ($cellfilter, 'objects', $objects_count)))
- {
- $objects = filterCellList (listCells ('object'), $cellfilter['expression']);
- // 2st 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>S/N</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)
- {
- echo "<tr class='row_${order} tdleft' 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>";
- $values = @getAttrValues($obj['id']);
- echo "<td>".@$values['1']['value']."</td>"; // OEM S/N 1
- $places = array();
- if (array_key_exists ($obj['id'], $containerinfo))
- foreach ($containerinfo[$obj['id']] as $ci)
- $places[] = mkA ($ci['container_name'], '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";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement