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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

### Fixed

- Restore inline editing functionality in items tab

## [2.11.3] - 2025-10-14

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion ajax/inputnumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
if (isset($_POST['name'])) {
$step = 1;
if (!isset($_REQUEST['force_integer'])) {
$step = PLUGIN_ORDER_NUMBER_STEP;
if (isset($_REQUEST['step'])) {
$step = (float)$_REQUEST['step'];
} else {
$step = PLUGIN_ORDER_NUMBER_STEP;
}
}

$class = "";
Expand Down
1 change: 1 addition & 0 deletions front/order.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
} else {
$price = isset($_POST['price_taxfree']) ? $_POST['price_taxfree'] : $_POST['old_price_taxfree'];

$price = number_format((float)$price, 6, '.', '');
$data = $pluginOrderOrder_Item->queryRef(
$_POST['plugin_order_orders_id'],
$_POST['old_plugin_order_references_id'],
Expand Down
57 changes: 47 additions & 10 deletions inc/order_item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -953,11 +953,11 @@ public function showFormDetail($plugin_order_orders_id)

public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $canedit, $reference, $reception, $table_ref)
{
/** @var array $CFG_GLPI */
/** @var \DBmysql $DB */
global $CFG_GLPI,$DB;
global $DB;

$config = new PluginOrderConfig();

$hidden_fields = [
'plugin_order_orders_id' => $plugin_order_orders_id,
'plugin_order_order_items_id' => $data_ref['IDD'],
Expand Down Expand Up @@ -1054,10 +1054,14 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
$entrie['manufacturer_reference'] = $this->getManufacturersReference($refID);

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

/* reduction */
$entrie['discount'] = Html::formatNumber($discount);
$entrie['discount'] = number_format((float)$discount, 2, '.', '');

// Add required fields for massive actions (even though disabled for summary)
$entrie['itemtype'] = 'PluginOrderOrder_Item';
$entrie['id'] = $data_ref['IDD'];

TemplateRenderer::getInstance()->display('@order/order_getitems.html.twig', [
'nopager' => true,
Expand All @@ -1072,13 +1076,26 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
'manufacturer' => 'raw_html',
'type' => 'raw_html',
'model' => 'raw_html',
'quantity' => 'editable_quantity',
'unit_price' => 'editable_price',
'discount' => 'editable_discount',
],
'columns_values' => [],
'entries' => [$entrie],
'total_number' => $numref,
'filtered_number' => $numref,
'showmassiveactions' => false,
'canedit' => $canedit,
'hidden_fields' => $hidden_fields,
'is_summary_table' => true,
'form_action' => Toolbox::getItemTypeFormURL('PluginOrderOrder'),
'summary_data' => [
'rand' => $data_ref['IDD'],
'quantity' => $quantity,
'price_taxfree' => number_format((float)$price_taxfree, 2, '.', ''),
'discount' => number_format((float)$discount, 2, '.', ''),
'ajax_url' => Plugin::getWebDir('order') . "/ajax/inputnumber.php"
],
]);

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

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

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

// Discount
$entry['discount'] = Html::formatNumber((float) $data["discount"]);
$entry['discount'] = number_format((float) $data["discount"], 2, '.', '');

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

// Price ATI
$entry['price_ati'] = Html::formatNumber((float) $data["price_ati"]);
$entry['price_ati'] = number_format((float) $data["price_ati"], 2, '.', '');

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

// Render the table using the template
// Prepare edit data for JavaScript
$edit_data = [];
if ($canedit && !empty($entries)) {
foreach ($entries as $entry) {
$edit_data[] = [
'id' => $entry['id'],
'price_taxfree' => strip_tags($entry['price_taxfree']),
'discount' => strip_tags($entry['discount']),
'quantity' => '1' // Default quantity for detail items
];
}
}

TemplateRenderer::getInstance()->display('@order/order_getitems.html.twig', [
'rand' => $rand,
'ID' => $plugin_order_orders_id,
Expand All @@ -1280,8 +1310,8 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
'id_showed' => 'raw_html',
'reference' => 'raw_html',
'vat' => 'raw_html',
'price_taxfree' => 'raw_html',
'discount' => 'raw_html',
'price_taxfree' => 'editable_price',
'discount' => 'editable_discount',
],
'entries' => $entries,
'canedit' => $canedit,
Expand All @@ -1290,13 +1320,20 @@ public function getItems($rand, $data_ref, $plugin_order_orders_id, $numref, $ca
'displayed_count' => $displayed_number,
'start' => $start,
'limit' => $limit,
'showmassiveactions' => true,
'massiveactionparams' => [
'container' => 'mass' . __CLASS__ . $rand,
'itemtype' => PluginOrderOrder_Item::class,
'specific_actions' => [
'purge' => _x('button', 'Delete permanently')
]
],
'is_detail_table' => true,
'edit_data' => $edit_data,
'ajax_url' => Plugin::getWebDir('order') . "/ajax/inputnumber.php",
'update_button_text' => _sx("button", "Update"),
'cancel_button_text' => _sx("button", "Cancel"),
'form_action' => Toolbox::getItemTypeFormURL('PluginOrderOrder'),
]);
}

Expand Down
Loading