r4150 renderDepot(): if no objects exist, display a generic message instead of an...
authorAaron Dummer <aaron@dummer.info>
Tue, 25 Jan 2011 02:22:24 +0000 (02:22 +0000)
committerAaron Dummer <aaron@dummer.info>
Tue, 25 Jan 2011 02:22:24 +0000 (02:22 +0000)
inc/interface.php

index 6d51cb9..f442404 100644 (file)
@@ -2060,31 +2060,36 @@ function renderDepot ()
 
        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>Barcode</th><th>Row/Rack</th></tr>';
-               $order = 'odd';
-               foreach ($objects as $obj)
+               if (count($objects) > 0)
                {
-                       if (isset ($_REQUEST['hl_object_id']) and $_REQUEST['hl_object_id'] == $obj['id'])
-                               $secondclass = 'tdleft port_highlight';
-                       else
-                               $secondclass = 'tdleft';
-                       echo "<tr class=row_${order} valign=top><td class='${secondclass}'><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 class='${secondclass}'>${obj['label']}</td>";
-                       echo "<td class='${secondclass}'>${obj['asset_no']}</td>";
-                       echo "<td class='${secondclass}'>${obj['barcode']}</td>";
-                       if ($obj['rack_id'])
-                               echo "<td class='${secondclass}'><a href='".makeHref(array('page'=>'row', 'row_id'=>$obj['row_id']))."'>${obj['Row_name']}</a>/<a href='".makeHref(array('page'=>'rack', 'rack_id'=>$obj['rack_id']))."'>${obj['Rack_name']}</a></td>";
-                       else
-                               echo "<td class='${secondclass}'>Unmounted</td>";
-                       echo '</tr>';
-                       $order = $nextorder[$order];
+                       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>Barcode</th><th>Row/Rack</th></tr>';
+                       $order = 'odd';
+                       foreach ($objects as $obj)
+                       {
+                               if (isset ($_REQUEST['hl_object_id']) and $_REQUEST['hl_object_id'] == $obj['id'])
+                                       $secondclass = 'tdleft port_highlight';
+                               else
+                                       $secondclass = 'tdleft';
+                               echo "<tr class=row_${order} valign=top><td class='${secondclass}'><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 class='${secondclass}'>${obj['label']}</td>";
+                               echo "<td class='${secondclass}'>${obj['asset_no']}</td>";
+                               echo "<td class='${secondclass}'>${obj['barcode']}</td>";
+                               if ($obj['rack_id'])
+                                       echo "<td class='${secondclass}'><a href='".makeHref(array('page'=>'row', 'row_id'=>$obj['row_id']))."'>${obj['Row_name']}</a>/<a href='".makeHref(array('page'=>'rack', 'rack_id'=>$obj['rack_id']))."'>${obj['Rack_name']}</a></td>";
+                               else
+                                       echo "<td class='${secondclass}'>Unmounted</td>";
+                               echo '</tr>';
+                               $order = $nextorder[$order];
+                       }
+                       echo '</table>';
+                       finishPortlet();
                }
-               echo '</table>';
-               finishPortlet();
+               else
+                       echo '<h2>No objects exist</h2>';
        }
 
        echo "</td><td class=pcright width='25%'>";