@@ -390,15 +390,19 @@ function showItems() {
390390 global $ DB , $ CFG_GLPI ;
391391
392392 $ locations_id = $ this ->fields ['id ' ];
393- $ itemtype = Session::getSavedOption (__CLASS__ , 'criterion ' , '' );
393+ $ current_itemtype = Session::getSavedOption (__CLASS__ , 'criterion ' , '' );
394394
395395 if (!$ this ->can ($ locations_id , READ )) {
396396 return false ;
397397 }
398398
399399 $ queries = [];
400- $ itemtypes = $ itemtype ? [$ itemtype ] : $ CFG_GLPI ['location_types ' ];
400+ $ itemtypes = $ current_itemtype ? [$ current_itemtype ] : $ CFG_GLPI ['location_types ' ];
401401 foreach ($ itemtypes as $ itemtype ) {
402+ $ item = new $ itemtype ();
403+ if (!$ item ->maybeLocated ()) {
404+ continue ;
405+ }
402406 $ table = getTableForItemType ($ itemtype );
403407 $ itemtype_criteria = [
404408 'SELECT ' => [
@@ -410,7 +414,6 @@ function showItems() {
410414 "$ table.locations_id " => $ locations_id ,
411415 ] + getEntitiesRestrictCriteria ($ table , 'entities_id ' )
412416 ];
413- $ item = new $ itemtype ();
414417 if ($ item ->maybeDeleted ()) {
415418 $ itemtype_criteria ['WHERE ' ]['is_deleted ' ] = 0 ;
416419 }
@@ -437,9 +440,13 @@ function showItems() {
437440 echo "<tr class='tab_bg_1'><th colspan='2'> " .__ ('Type ' )."</th></tr> " ;
438441 echo "<tr class='tab_bg_1'><td class='center'> " ;
439442 echo __ ('Type ' )." " ;
440- Dropdown::showItemType ($ CFG_GLPI ['location_types ' ],
441- ['value ' => $ itemtype ,
442- 'on_change ' => 'reloadTab("start=0&criterion="+this.value) ' ]);
443+ $ all_types = array_merge (['0 ' => '--- ' ], $ CFG_GLPI ['location_types ' ]);
444+ Dropdown::showItemType (
445+ $ all_types , [
446+ 'value ' => $ current_itemtype ,
447+ 'on_change ' => 'reloadTab("start=0&criterion="+this.value) '
448+ ]
449+ );
443450 echo "</td></tr></table> " ;
444451
445452 if ($ number ) {
0 commit comments