Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [UNRELEASED]

- Fix SQL query error when displaying deliveries
- Fix error during generate associated material action

## [2.12.5] - 2026-01-08

Expand Down
14 changes: 13 additions & 1 deletion ajax/linkactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
13 changes: 11 additions & 2 deletions inc/link.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

use Glpi\Application\View\TemplateRenderer;
use Glpi\Features\AssignableItem;

class PluginOrderLink extends CommonDBChild
{
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -122,6 +124,7 @@ public function showItemGenerationForm($params)
: $order->fields["entities_id"],
'condition' => self::getCondition($itemtype),
'itemtype' => $itemtype,
'assignableitem' => false,
];

if ($templateID) {
Expand All @@ -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'] = "";
}
Expand All @@ -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;
}
Expand Down
30 changes: 24 additions & 6 deletions templates/generate_item.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,20 @@
</td>
<td>
<span id='show_group_by_entity_id_mass'>

{{ fields.dropdownField(
'Group',
"mass[groups_id]",
0,
"mass[groups_id]",
assignableitem ? [] : 0,
"",
fields_option|merge({'on_change': 'plugin_order_setAllGroups(this.value)'})
fields_option|merge({
'entity': -1,
'condition': {'is_itemgroup': 1},
'multiple': assignableitem ? true : false,
'on_change': 'plugin_order_setAllGroups(this)'
})
) }}

</span>
</td>
<td>
Expand Down Expand Up @@ -233,7 +240,11 @@
"id[" ~ item.i ~ "][groups_id]",
item.groups_id,
"",
fields_option
fields_option|merge({
'entity': -1,
'condition': {'is_itemgroup': 1},
'multiple': item.assignableitem ? true : false
})
) }}
</span>
</td>
Expand Down Expand Up @@ -279,6 +290,7 @@
data: {
'entities': value,
'action': 'show_group_by_entity',
'multiple': {{ assignableitem ? 'true' : 'false' }},
'id': id
},
success: function(response) {
Expand Down Expand Up @@ -344,7 +356,12 @@
}
}

function plugin_order_setAllGroups(value) {
function plugin_order_setAllGroups(dom_select) {

const values = Array.from(dom_select.selectedOptions).map(
option => option.value
);

var elements = document.querySelectorAll('[id^="show_group_by"]');
for (var i = 0; i < elements.length; i++) {
(function(index) {
Expand All @@ -355,7 +372,8 @@
'entities': 0,
'action': 'show_group_by_entity',
'id': index,
'value': value
'value': values,
'multiple': {{ assignableitem ? 'true' : 'false' }}
},
success: function(response) {
$('#show_group_by_entity_id_' + index).html(response);
Expand Down