diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b72ab2723..7be77e6419 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [UNRELEASED] + +- Fix error during generate associated material action + ## [2.12.5] - 2026-01-08 ### Fixed diff --git a/ajax/linkactions.php b/ajax/linkactions.php index ab395277a3..a35526b951 100644 --- a/ajax/linkactions.php +++ b/ajax/linkactions.php @@ -95,10 +95,22 @@ break; case "show_group_by_entity": + + if (isset($_POST['multiple']) && $_POST['multiple']) { + if (isset($_POST['value']) && !is_array($_POST['value'])) { + $_POST['value'] = [$_POST['value']]; + } + + if (!isset($_POST['value'])) { + $_POST['value'] = []; + } + } + Group::dropdown(['name' => "id[" . $_POST['id'] . "][groups_id]", 'entity' => $_POST['entities'], 'value' => $_POST['value'] ?? 0, - 'condition' => ['is_assign' => 1], + 'condition' => ['is_itemgroup' => 1], + 'multiple' => $_POST['multiple'] ?? false, ]); if (isset($_POST['massaction'])) { diff --git a/inc/link.class.php b/inc/link.class.php index 92a8c491c6..a7b7953b1e 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -29,6 +29,7 @@ */ use Glpi\Application\View\TemplateRenderer; +use Glpi\Features\AssignableItem; class PluginOrderLink extends CommonDBChild { @@ -95,6 +96,7 @@ public function showItemGenerationForm($params) $i = 0; $item_rows = []; $found = false; + $itemtype = ''; $order_web_dir = $CFG_GLPI['root_doc'] . '/plugins/order'; foreach ($params["items"][self::class] as $key => $val) { @@ -122,6 +124,7 @@ public function showItemGenerationForm($params) : $order->fields["entities_id"], 'condition' => self::getCondition($itemtype), 'itemtype' => $itemtype, + 'assignableitem' => false, ]; if ($templateID) { @@ -132,15 +135,20 @@ public function showItemGenerationForm($params) $row['otherserial'] = $item->fields["otherserial"] ?? ""; $row['states_id'] = $item->fields["states_id"] ?? ""; $row['locations_id'] = $item->fields["locations_id"] ?? ""; - $row['groups_id'] = $item->fields["groups_id"] ?? ""; + $row['groups_id'] = $item->fields["groups_id"] ?? []; $row['immo_number'] = $item->fields["immo_number"] ?? ""; $row['template_name'] = $reference->getTemplateName($itemtype, $templateID); + + if (Toolbox::hasTrait($itemtype, AssignableItem::class)) { + $row['assignableitem'] = true; + } + } else { $row['name'] = false; $row['otherserial'] = false; $row['states_id'] = false; $row['locations_id'] = false; - $row['groups_id'] = false; + $row['groups_id'] = []; $row['immo_number'] = false; $row['template_name'] = ""; } @@ -164,6 +172,7 @@ public function showItemGenerationForm($params) 'active_entities' => $_SESSION['glpiactiveentities'] ?? [], 'item_rows' => $item_rows, 'order_web_dir' => $order_web_dir, + 'assignableitem' => Toolbox::hasTrait($itemtype, AssignableItem::class), ]); return null; } diff --git a/templates/generate_item.html.twig b/templates/generate_item.html.twig index 882f6e572e..52c80bb57c 100644 --- a/templates/generate_item.html.twig +++ b/templates/generate_item.html.twig @@ -99,13 +99,20 @@