2929 */
3030
3131use Glpi \Application \View \TemplateRenderer ;
32+ use Glpi \Features \AssignableItem ;
3233
3334class PluginOrderLink extends CommonDBChild
3435{
@@ -95,6 +96,7 @@ public function showItemGenerationForm($params)
9596 $ i = 0 ;
9697 $ item_rows = [];
9798 $ found = false ;
99+ $ itemtype = '' ;
98100 $ order_web_dir = $ CFG_GLPI ['root_doc ' ] . '/plugins/order ' ;
99101
100102 foreach ($ params ["items " ][self ::class] as $ key => $ val ) {
@@ -122,6 +124,7 @@ public function showItemGenerationForm($params)
122124 : $ order ->fields ["entities_id " ],
123125 'condition ' => self ::getCondition ($ itemtype ),
124126 'itemtype ' => $ itemtype ,
127+ 'assignableitem ' => false ,
125128 ];
126129
127130 if ($ templateID ) {
@@ -132,15 +135,20 @@ public function showItemGenerationForm($params)
132135 $ row ['otherserial ' ] = $ item ->fields ["otherserial " ] ?? "" ;
133136 $ row ['states_id ' ] = $ item ->fields ["states_id " ] ?? "" ;
134137 $ row ['locations_id ' ] = $ item ->fields ["locations_id " ] ?? "" ;
135- $ row ['groups_id ' ] = $ item ->fields ["groups_id " ] ?? "" ;
138+ $ row ['groups_id ' ] = $ item ->fields ["groups_id " ] ?? [] ;
136139 $ row ['immo_number ' ] = $ item ->fields ["immo_number " ] ?? "" ;
137140 $ row ['template_name ' ] = $ reference ->getTemplateName ($ itemtype , $ templateID );
141+
142+ if (Toolbox::hasTrait ($ itemtype , AssignableItem::class)) {
143+ $ row ['assignableitem ' ] = true ;
144+ }
145+
138146 } else {
139147 $ row ['name ' ] = false ;
140148 $ row ['otherserial ' ] = false ;
141149 $ row ['states_id ' ] = false ;
142150 $ row ['locations_id ' ] = false ;
143- $ row ['groups_id ' ] = false ;
151+ $ row ['groups_id ' ] = [] ;
144152 $ row ['immo_number ' ] = false ;
145153 $ row ['template_name ' ] = "" ;
146154 }
@@ -164,6 +172,7 @@ public function showItemGenerationForm($params)
164172 'active_entities ' => $ _SESSION ['glpiactiveentities ' ] ?? [],
165173 'item_rows ' => $ item_rows ,
166174 'order_web_dir ' => $ order_web_dir ,
175+ 'assignableitem ' => Toolbox::hasTrait ($ itemtype , AssignableItem::class),
167176 ]);
168177 return null ;
169178 }
0 commit comments