From 53dc0c4ddbe4b27deeb3a83dc4079bd4af1930f1 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 2 Jul 2026 11:48:28 +0200 Subject: [PATCH 1/4] Consumables : mass action link associated items --- inc/link.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inc/link.class.php b/inc/link.class.php index 8209d5ae94..0de5358b7f 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -633,7 +633,18 @@ public static function processMassiveActionsForOneItemtype( break; case 'createLink': - if (count($ids) > 1) { + // For consumables and cartridges, createLinkWithItem creates a new item + // (glpi_consumables/glpi_cartridges) for each selected detail line; + // therefore, multiple items can be linked to the same reference item at once + $reference = new PluginOrderReference(); + $reference->getFromDB($ma->POST["plugin_order_references_id"]); + $allow_multiple_link = in_array( + $reference->fields["itemtype"] ?? '', + ['ConsumableItem', 'CartridgeItem'], + true, + ); + + if (!$allow_multiple_link && count($ids) > 1) { $ma->addMessage(__s("Cannot link several items to one detail line", "order")); foreach ($ids as $id) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); From 5677a60454a23415dd9fed0d7a23febc97e0b643 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 2 Jul 2026 11:51:16 +0200 Subject: [PATCH 2/4] CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27e7fc1c76..795800c7ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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] + +### Added +- Add grouped actions to link consumables and related items + ## [2.12.8] - 2026-06-24 ### Added From cc3c6219f74a9c7b4904e94c3611bcb3fdd15c20 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 2 Jul 2026 14:07:11 +0200 Subject: [PATCH 3/4] phpSTAN --- inc/order.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/order.class.php b/inc/order.class.php index c3fafe8757..15f6e1be35 100644 --- a/inc/order.class.php +++ b/inc/order.class.php @@ -1825,7 +1825,6 @@ public function generateOrder($params) $this->getFromDB($ID); if (file_exists(PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php")) { - // @phpstan-ignore-next-line: custom.php is not a file or it does not exist. include_once(PLUGIN_ORDER_TEMPLATE_CUSTOM_DIR . "custom.php"); } From e4a69883bb69a194e3f7d7235a4703581a8f3894 Mon Sep 17 00:00:00 2001 From: Herafia Date: Thu, 2 Jul 2026 17:33:42 +0200 Subject: [PATCH 4/4] fix --- inc/link.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/inc/link.class.php b/inc/link.class.php index 0de5358b7f..5468350fb4 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -636,10 +636,9 @@ public static function processMassiveActionsForOneItemtype( // For consumables and cartridges, createLinkWithItem creates a new item // (glpi_consumables/glpi_cartridges) for each selected detail line; // therefore, multiple items can be linked to the same reference item at once - $reference = new PluginOrderReference(); - $reference->getFromDB($ma->POST["plugin_order_references_id"]); - $allow_multiple_link = in_array( - $reference->fields["itemtype"] ?? '', + $first_item_data = reset($ma->POST['add_items']); + $allow_multiple_link = is_array($first_item_data) && in_array( + $first_item_data['itemtype'] ?? '', ['ConsumableItem', 'CartridgeItem'], true, );