From b92d8987a0c89fcf4f1110a571a2f32c67805f65 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Mon, 15 Jun 2026 11:19:22 +0200 Subject: [PATCH 1/7] Fix(SoftwareLincense): fix reception and cancel --- inc/link.class.php | 34 +++++++++++++++++++++++++++++----- inc/reception.class.php | 3 +++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/inc/link.class.php b/inc/link.class.php index 6d8b2831ae..17b063ff30 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -689,14 +689,14 @@ public static function processMassiveActionsForOneItemtype( case 'cancelReceipt': foreach ($ma->getItems()[self::class] as $key => $val) { $order_item = new PluginOrderOrder_Item(); - $order_item->getFromDB($val); + $order_item->getFromDB($key); if ($order_item->fields["items_id"] != 0) { $ma->addMessage(__s("Unable to cancel reception when items are already linked, please unlink them before trying again.", "order")); $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } elseif (!$link->cancelReception($key)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } else { - $ma->itemDone($item->getType(), $val, MassiveAction::ACTION_OK); + $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } } @@ -711,10 +711,34 @@ public function cancelReception($id) $order_item = new PluginOrderOrder_Item(); $order_item->getFromDB($id); + if ($order_item->fields['itemtype'] === 'SoftwareLicense') { + $iterator = $order_item->queryRef( + $order_item->fields['plugin_order_orders_id'], + $order_item->fields['plugin_order_references_id'], + $order_item->fields['price_taxfree'], + $order_item->fields['discount'], + PluginOrderOrder::ORDER_DEVICE_DELIVRED, + ); + $success = true; + foreach ($iterator as $data) { + $success = $order_item->update([ + 'id' => $data['id'], + 'states_id' => PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED, + 'delivery_date' => null, + 'delivery_number' => '', + 'plugin_order_deliverystates_id' => 0, + ]) && $success; + } + + return $success; + } + return $order_item->update([ - 'id' => $id, - 'states_id' => PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED, - 'delivery_date' => null, + 'id' => $id, + 'states_id' => PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED, + 'delivery_date' => null, + 'delivery_number' => '', + 'plugin_order_deliverystates_id' => 0, ]); } diff --git a/inc/reception.class.php b/inc/reception.class.php index 081b8acb6f..70fed233f0 100644 --- a/inc/reception.class.php +++ b/inc/reception.class.php @@ -1041,6 +1041,9 @@ public function updateReceptionStatus($params) $params2['POST']["plugin_order_deliverystates_id"], ); $plugin_order_orders_id = $params2['POST']["plugin_order_orders_id"]; + if ($ma !== false) { + $ma->itemDone(self::class, $key, MassiveAction::ACTION_OK); + } } elseif ($detail->getFromDB($key)) { if (!$plugin_order_orders_id) { $plugin_order_orders_id = $detail->fields["plugin_order_orders_id"]; From 60437a6a4ebc2f7de62ab2f3b3f065bdfe995057 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Mon, 15 Jun 2026 11:21:16 +0200 Subject: [PATCH 2/7] adapt CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a5795236..836a53d745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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] + +### Fixed + +- Fix `Take item delivery` and `Cancel reception` action for `Software License` + ## [2.12.9] - 2026-08-04 ### Added @@ -15,7 +21,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add an `Orderable` capacity for GLPI 11 custom asset definitions. - ## [2.12.7] - 2026-06-03 ### Fixed From 241920391d056eabcb60f1395006a6654708d203 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Fri, 19 Jun 2026 10:52:05 +0200 Subject: [PATCH 3/7] fix --- inc/link.class.php | 60 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/inc/link.class.php b/inc/link.class.php index 17b063ff30..15bb98ceec 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -623,7 +623,10 @@ public static function processMassiveActionsForOneItemtype( case 'generation': $newIDs = $link->generateNewItem($ma->POST); foreach ($ma->getItems()[self::class] as $key => $val) { - if (isset($newIDs[$key]) && $newIDs[$key]) { + $itemtype = $ma->POST['add_items'][$key]['itemtype'] ?? ''; + if (in_array($itemtype, self::getTypesThanCannotBeGenerated())) { + $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); + } elseif (isset($newIDs[$key]) && $newIDs[$key]) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); @@ -1166,6 +1169,10 @@ public function generateNewItem($params) { $newIDs = []; + if (empty($params["id"])) { + return $newIDs; + } + // Retrieve plugin configuration $config = new PluginOrderConfig(); $reference = new PluginOrderReference(); @@ -1186,6 +1193,57 @@ public function generateNewItem($params) //If itemtype cannot be generated, go to the new occurence if (in_array($add_item['itemtype'], self::getTypesThanCannotBeGenerated())) { + if ($add_item['itemtype'] === 'SoftwareLicense') { + $entity = $values["entities_id"]; + $templateID = $reference->checkIfTemplateExistsInEntity( + $values["id"], + 'SoftwareLicense', + $entity, + ); + $order = new PluginOrderOrder(); + $order->getFromDB($params["plugin_order_orders_id"]); + $reference->getFromDB($add_item["plugin_order_references_id"]); + + $lic = new SoftwareLicense(); + $input = []; + if ($templateID) { + $lic->getFromDB($templateID); + foreach ($lic->fields as $field_name => $field_val) { + if ($field_val !== '') { + $input[$field_name] = $field_val; + } + } + unset($input['id'], $input['is_template'], $input['template_name'], $input['date_mod'], $input['date_creation']); + $input['name'] = $lic->fields['name'] + ? autoName($lic->fields['name'], 'name', $templateID, 'SoftwareLicense', $entity) + : $values['name']; + } else { + $input['name'] = $values['name']; + } + $input['entities_id'] = $entity; + $input['number'] = 0; + + $newID = $lic->add($input); + if ($newID) { + $newIDs[$values["id"]] = $newID; + $this->createLinkWithItem( + $values["id"], + $newID, + 'SoftwareLicense', + $params["plugin_order_orders_id"], + $entity, + $templateID, + false, + false, + ); + $new_value = __s("Item generated by using order", "order") . ' : ' . $order->fields["name"]; + $order->addHistory('SoftwareLicense', '', $new_value, $newID); + $new_value = __s("Item generated by using order", "order") . ' : ' + . $lic->getTypeName() . ' -> ' . $lic->getField("name"); + $order->addHistory('PluginOrderOrder', '', $new_value, $params["plugin_order_orders_id"]); + Session::addMessageAfterRedirect(__s("Item successfully selected", "order"), true); + } + } continue; } From 6443e34dbefe22c0339c344044613da8e12b28b6 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Fri, 19 Jun 2026 10:56:17 +0200 Subject: [PATCH 4/7] remove uselss message --- inc/link.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/link.class.php b/inc/link.class.php index 15bb98ceec..b7edaa5a32 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -1241,7 +1241,6 @@ public function generateNewItem($params) $new_value = __s("Item generated by using order", "order") . ' : ' . $lic->getTypeName() . ' -> ' . $lic->getField("name"); $order->addHistory('PluginOrderOrder', '', $new_value, $params["plugin_order_orders_id"]); - Session::addMessageAfterRedirect(__s("Item successfully selected", "order"), true); } } continue; From b4a2276effde16ca439699548460f0c0ce5e2472 Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Mon, 22 Jun 2026 17:29:27 +0200 Subject: [PATCH 5/7] fix rector --- inc/link.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inc/link.class.php b/inc/link.class.php index b7edaa5a32..9d8e00efb2 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -1213,6 +1213,7 @@ public function generateNewItem($params) $input[$field_name] = $field_val; } } + unset($input['id'], $input['is_template'], $input['template_name'], $input['date_mod'], $input['date_creation']); $input['name'] = $lic->fields['name'] ? autoName($lic->fields['name'], 'name', $templateID, 'SoftwareLicense', $entity) @@ -1220,6 +1221,7 @@ public function generateNewItem($params) } else { $input['name'] = $values['name']; } + $input['entities_id'] = $entity; $input['number'] = 0; @@ -1243,6 +1245,7 @@ public function generateNewItem($params) $order->addHistory('PluginOrderOrder', '', $new_value, $params["plugin_order_orders_id"]); } } + continue; } From 47b348cbeeda68f064bc037d04f8ea045b0f67ce Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Mon, 17 Aug 2026 10:12:37 +0200 Subject: [PATCH 6/7] remove useless empty space --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 836a53d745..9ee8a97de3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- Fix `Take item delivery` and `Cancel reception` action for `Software License` +- Fix `Take item delivery` and `Cancel reception` action for `Software License` ## [2.12.9] - 2026-08-04 From a5ffbc1ef2df6892456500bee888ea664260c91e Mon Sep 17 00:00:00 2001 From: Stanislas Kita <7335054+stonebuzz@users.noreply.github.com> Date: Mon, 17 Aug 2026 11:24:57 +0200 Subject: [PATCH 7/7] review --- inc/link.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inc/link.class.php b/inc/link.class.php index 9d8e00efb2..e66b6a16d9 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -624,7 +624,7 @@ public static function processMassiveActionsForOneItemtype( $newIDs = $link->generateNewItem($ma->POST); foreach ($ma->getItems()[self::class] as $key => $val) { $itemtype = $ma->POST['add_items'][$key]['itemtype'] ?? ''; - if (in_array($itemtype, self::getTypesThanCannotBeGenerated())) { + if (in_array($itemtype, self::getTypesThanCannotBeGenerated()) && $itemtype !== 'SoftwareLicense') { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } elseif (isset($newIDs[$key]) && $newIDs[$key]) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); @@ -724,6 +724,11 @@ public function cancelReception($id) ); $success = true; foreach ($iterator as $data) { + if ($data['items_id'] != 0) { + $success = false; + continue; + } + $success = $order_item->update([ 'id' => $data['id'], 'states_id' => PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED,