Skip to content

Commit e5e92d1

Browse files
authored
Fix - Restore inline editing functionality in items tab (#488)
* Fix - Restore inline editing functionality in items tab * Apply suggestions * Apply suggestions * Update CHANGELOG & optimize style
1 parent 97dae6b commit e5e92d1

File tree

5 files changed

+286
-14
lines changed

5 files changed

+286
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [UNRELEASED]
99

10+
### Fixed
11+
12+
- Restore inline editing functionality in items tab
13+
1014
## [2.11.3] - 2025-10-14
1115

1216
### Fixed

ajax/inputnumber.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
if (isset($_POST['name'])) {
4444
$step = 1;
4545
if (!isset($_REQUEST['force_integer'])) {
46-
$step = PLUGIN_ORDER_NUMBER_STEP;
46+
if (isset($_REQUEST['step'])) {
47+
$step = (float)$_REQUEST['step'];
48+
} else {
49+
$step = PLUGIN_ORDER_NUMBER_STEP;
50+
}
4751
}
4852

4953
$class = "";

front/order.form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@
411411
} else {
412412
$price = isset($_POST['price_taxfree']) ? $_POST['price_taxfree'] : $_POST['old_price_taxfree'];
413413

414+
$price = number_format((float)$price, 6, '.', '');
414415
$data = $pluginOrderOrder_Item->queryRef(
415416
$_POST['plugin_order_orders_id'],
416417
$_POST['old_plugin_order_references_id'],

inc/order_item.class.php

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,11 @@ public function showFormDetail($plugin_order_orders_id)
953953

954954
public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $canedit, $reference, $reception, $table_ref)
955955
{
956-
/** @var array $CFG_GLPI */
957956
/** @var \DBmysql $DB */
958-
global $CFG_GLPI,$DB;
957+
global $DB;
959958

960959
$config = new PluginOrderConfig();
960+
961961
$hidden_fields = [
962962
'plugin_order_orders_id' => $plugin_order_orders_id,
963963
'plugin_order_order_items_id' => $data_ref['IDD'],
@@ -1054,10 +1054,14 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
10541054
$entrie['manufacturer_reference'] = $this->getManufacturersReference($refID);
10551055

10561056
/* unit price */
1057-
$entrie['unit_price'] = Html::formatNumber($price_taxfree);
1057+
$entrie['unit_price'] = number_format((float)$price_taxfree, 2, '.', '');
10581058

10591059
/* reduction */
1060-
$entrie['discount'] = Html::formatNumber($discount);
1060+
$entrie['discount'] = number_format((float)$discount, 2, '.', '');
1061+
1062+
// Add required fields for massive actions (even though disabled for summary)
1063+
$entrie['itemtype'] = 'PluginOrderOrder_Item';
1064+
$entrie['id'] = $data_ref['IDD'];
10611065

10621066
TemplateRenderer::getInstance()->display('@order/order_getitems.html.twig', [
10631067
'nopager' => true,
@@ -1072,13 +1076,26 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
10721076
'manufacturer' => 'raw_html',
10731077
'type' => 'raw_html',
10741078
'model' => 'raw_html',
1079+
'quantity' => 'editable_quantity',
1080+
'unit_price' => 'editable_price',
1081+
'discount' => 'editable_discount',
10751082
],
10761083
'columns_values' => [],
10771084
'entries' => [$entrie],
10781085
'total_number' => $numref,
10791086
'filtered_number' => $numref,
10801087
'showmassiveactions' => false,
1088+
'canedit' => $canedit,
10811089
'hidden_fields' => $hidden_fields,
1090+
'is_summary_table' => true,
1091+
'form_action' => Toolbox::getItemTypeFormURL('PluginOrderOrder'),
1092+
'summary_data' => [
1093+
'rand' => $data_ref['IDD'],
1094+
'quantity' => $quantity,
1095+
'price_taxfree' => number_format((float)$price_taxfree, 2, '.', ''),
1096+
'discount' => number_format((float)$discount, 2, '.', ''),
1097+
'ajax_url' => Plugin::getWebDir('order') . "/ajax/inputnumber.php"
1098+
],
10821099
]);
10831100

10841101
// Initialize columns array based on needed headers
@@ -1200,7 +1217,7 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
12001217
}
12011218

12021219
// Price tax free
1203-
$entry['price_taxfree'] = Html::formatNumber((float) $data["price_taxfree"]);
1220+
$entry['price_taxfree'] = number_format((float) $data["price_taxfree"], 2, '.', '');
12041221

12051222
// VAT
12061223
$entry['vat'] = Dropdown::getDropdownName(
@@ -1209,13 +1226,13 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
12091226
);
12101227

12111228
// Discount
1212-
$entry['discount'] = Html::formatNumber((float) $data["discount"]);
1229+
$entry['discount'] = number_format((float) $data["discount"], 2, '.', '');
12131230

12141231
// Price with reduction
1215-
$entry['price_discounted'] = Html::formatNumber((float) $data["price_discounted"]);
1232+
$entry['price_discounted'] = number_format((float) $data["price_discounted"], 2, '.', '');
12161233

12171234
// Price ATI
1218-
$entry['price_ati'] = Html::formatNumber((float) $data["price_ati"]);
1235+
$entry['price_ati'] = number_format((float) $data["price_ati"], 2, '.', '');
12191236

12201237
// Status
12211238
$entry['status'] = $reception->getReceptionStatus($data["IDD"]);
@@ -1263,6 +1280,19 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
12631280
}
12641281

12651282
// Render the table using the template
1283+
// Prepare edit data for JavaScript
1284+
$edit_data = [];
1285+
if ($canedit && !empty($entries)) {
1286+
foreach ($entries as $entry) {
1287+
$edit_data[] = [
1288+
'id' => $entry['id'],
1289+
'price_taxfree' => strip_tags($entry['price_taxfree']),
1290+
'discount' => strip_tags($entry['discount']),
1291+
'quantity' => '1' // Default quantity for detail items
1292+
];
1293+
}
1294+
}
1295+
12661296
TemplateRenderer::getInstance()->display('@order/order_getitems.html.twig', [
12671297
'rand' => $rand,
12681298
'ID' => $plugin_order_orders_id,
@@ -1280,8 +1310,8 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
12801310
'id_showed' => 'raw_html',
12811311
'reference' => 'raw_html',
12821312
'vat' => 'raw_html',
1283-
'price_taxfree' => 'raw_html',
1284-
'discount' => 'raw_html',
1313+
'price_taxfree' => 'editable_price',
1314+
'discount' => 'editable_discount',
12851315
],
12861316
'entries' => $entries,
12871317
'canedit' => $canedit,
@@ -1290,13 +1320,20 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
12901320
'displayed_count' => $displayed_number,
12911321
'start' => $start,
12921322
'limit' => $limit,
1323+
'showmassiveactions' => true,
12931324
'massiveactionparams' => [
12941325
'container' => 'mass' . __CLASS__ . $rand,
12951326
'itemtype' => PluginOrderOrder_Item::class,
12961327
'specific_actions' => [
12971328
'purge' => _x('button', 'Delete permanently')
12981329
]
12991330
],
1331+
'is_detail_table' => true,
1332+
'edit_data' => $edit_data,
1333+
'ajax_url' => Plugin::getWebDir('order') . "/ajax/inputnumber.php",
1334+
'update_button_text' => _sx("button", "Update"),
1335+
'cancel_button_text' => _sx("button", "Cancel"),
1336+
'form_action' => Toolbox::getItemTypeFormURL('PluginOrderOrder'),
13001337
]);
13011338
}
13021339

0 commit comments

Comments
 (0)