Advertisement
Guest User

renderDepot modification

a guest
Mar 6th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. function renderDepot ()
  2. {
  3.     global $pageno, $nextorder;
  4.     $cellfilter = getCellFilter();
  5.     $objects = array();
  6.     $objects_count = getEntitiesCount ('object');
  7.  
  8.     echo "<table border=0 class=objectview>\n";
  9.     echo "<tr><td class=pcleft>";
  10.  
  11.     if ($objects_count == 0)
  12.         echo '<h2>No objects exist</h2>';
  13.     // 1st attempt: do not fetch all objects if cellfilter is empty and rendering empty result is enabled
  14.     elseif (! ($cellfilter['is_empty'] && renderEmptyResults ($cellfilter, 'objects', $objects_count)))
  15.     {
  16.         $objects = filterCellList (listCells ('object'), $cellfilter['expression']);
  17.         // 2st attempt: do not render all fetched objects if rendering empty result is enabled
  18.         if (! renderEmptyResults ($cellfilter, 'objects', count($objects)))
  19.         {
  20.             startPortlet ('Objects (' . count ($objects) . ')');
  21.             echo '<br><br><table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
  22.             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>';
  23.             $order = 'odd';
  24.             # gather IDs of all objects and fetch rackspace info in one pass
  25.             $idlist = array();
  26.             foreach ($objects as $obj)
  27.                 $idlist[] = $obj['id'];
  28.             $mountinfo = getMountInfo ($idlist);
  29.             $containerinfo = getContainerInfo ($idlist);
  30.             foreach ($objects as $obj)
  31.             {
  32.                 echo "<tr class='row_${order} tdleft' valign=top><td>" . mkA ("<strong>${obj['dname']}</strong>", 'object', $obj['id']);
  33.                 if (count ($obj['etags']))
  34.                     echo '<br><small>' . serializeTags ($obj['etags'], makeHref(array('page'=>$pageno, 'tab'=>'default')) . '&') . '</small>';
  35.                 echo "</td><td>${obj['label']}</td>";
  36.                 echo "<td>${obj['asset_no']}</td>";
  37.                 $values = @getAttrValues($obj['id']);
  38.                 echo "<td>".@$values['1']['value']."</td>"; // OEM S/N 1
  39.                 $places = array();
  40.                 if (array_key_exists ($obj['id'], $containerinfo))
  41.                     foreach ($containerinfo[$obj['id']] as $ci)
  42.                         $places[] = mkA ($ci['container_name'], 'object', $ci['container_id']);
  43.                 if (array_key_exists ($obj['id'], $mountinfo))
  44.                     foreach ($mountinfo[$obj['id']] as $mi)
  45.                         $places[] = mkA ($mi['row_name'], 'row', $mi['row_id']) . '/' . mkA ($mi['rack_name'], 'rack', $mi['rack_id']);
  46.                 if (! count ($places))
  47.                     $places[] = 'Unmounted';
  48.                 echo "<td>" . implode (', ', $places) . '</td>';
  49.                 echo '</tr>';
  50.                 $order = $nextorder[$order];
  51.             }
  52.             echo '</table>';
  53.             finishPortlet();
  54.         }
  55.     }
  56.  
  57.     echo "</td><td class=pcright width='25%'>";
  58.  
  59.     renderCellFilterPortlet ($cellfilter, 'object', $objects);
  60.     echo "</td></tr></table>\n";
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement