diff --git a/CHANGELOG.md b/CHANGELOG.md index 738978cb0d..ee4dc0cdbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + +- Make the plugin compatible with the Content Security Policy (requires the GLPI release with CSP support) + ### Fixed - Faster order form, reception, bills and budget tabs on large volumes (missing indexes, budget check and prices read in one query) diff --git a/ajax/linkactions.php b/ajax/linkactions.php index 2cee4d4a9a..8f844e19b7 100644 --- a/ajax/linkactions.php +++ b/ajax/linkactions.php @@ -156,7 +156,6 @@ case "update_entity": Entity::dropdown(['name' => "id[" . $_POST['id'] . "][entities_id]", 'value' => $_POST['value'], - 'on_change' => "plugin_order_adaptOnSelectedEntity(" . $_POST['id'] . ", this.value);", ]); $order_web_dir = $CFG_GLPI['root_doc'] . '/plugins/order'; diff --git a/inc/bill.class.php b/inc/bill.class.php index 773f982e62..3f5ac4aa3c 100644 --- a/inc/bill.class.php +++ b/inc/bill.class.php @@ -360,8 +360,7 @@ public static function showOrder($data_ref, $result_ref, $canedit, $order, $refe $itemtype = $data_ref["itemtype"]; $item = getItemForItemtype($itemtype); echo ""; @@ -479,12 +478,12 @@ public static function showOrder($data_ref, $result_ref, $canedit, $order, $refe echo "
"; echo ""; echo ""; + echo sprintf("", $rand) + . __s("Check all") . ""; echo ""; echo ""; @@ -1881,12 +1880,12 @@ public function showBillsItemsDetail($data_ref, $result_ref, $canedit, $order, $ echo "
"; echo "
"; - echo sprintf("" . __s("Check all") . "/"; - echo sprintf("" . __s("Uncheck all") . ""; + echo sprintf("", $rand) + . __s("Uncheck all") . ""; echo ""; echo Html::hidden('plugin_order_orders_id', ['value' => $order->getID()]); $order_item->dropdownBillItemsActions($order->getID()); diff --git a/inc/order.class.php b/inc/order.class.php index 56a30ff073..26627e5daf 100644 --- a/inc/order.class.php +++ b/inc/order.class.php @@ -1696,9 +1696,9 @@ public function showValidationForm($orders_id) $link = ""; if ($this->canCancelOrder()) { - echo ""; + . "\" name='cancel_order' value=\"" . __s("Cancel order", "order") . "\" class='submit'>"; $link = "

"; } @@ -1709,9 +1709,9 @@ public function showValidationForm($orders_id) } if ($this->canCancelValidationRequest()) { - echo $link . ""; $link = "

"; } @@ -1723,9 +1723,9 @@ public function showValidationForm($orders_id) } if ($this->canUndoValidation()) { - echo $link . ""; $link = "

"; } diff --git a/inc/order_item.class.php b/inc/order_item.class.php index b92d826404..b067051f28 100644 --- a/inc/order_item.class.php +++ b/inc/order_item.class.php @@ -657,7 +657,7 @@ public function showAddForm($plugin_order_orders_id) } };"); - echo ""; + echo ""; echo "
"; echo ""; + echo sprintf("", $rand) + . __s("Check all") . ""; echo ""; echo sprintf("", $arrow); echo ""; + echo sprintf("", htmlescape($formname)) . __s('Check all') . ""; echo ""; echo ""; + echo sprintf("", htmlescape($formname)) . __s('Uncheck all') . ""; echo ""; @@ -507,7 +506,7 @@ public function showOrderReceptionItem($data_ref, $numref, $canedit, $reference, 'rand' => $rand, ], ); - echo " "; + echo sprintf(" "; echo ""; } @@ -625,7 +624,7 @@ public function showOrderReceptionItem($data_ref, $numref, $canedit, $reference, 'rand' => $rand, ], ); - echo " "; + echo sprintf(" "; echo ""; } @@ -685,7 +684,8 @@ private function displayBulkReceptionForm($order_order, $orders_id, $references_ if ($order_order->canDeliver() && $this->checkItemStatus($orders_id, $references_id, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED) && $typeRef != 'SoftwareLicense') { $bulk_rand = mt_rand(); - $button = "

"); + $button_id = 'massreception_button' . $suffix . $orders_id . $bulk_rand; + $button = sprintf("

", $button_id, htmlescape('viewmassreception' . $suffix . $orders_id . $bulk_rand)); $button .= __s("Take item delivery (bulk)", "order") . "

"; echo ""; diff --git a/inc/reference_supplier.class.php b/inc/reference_supplier.class.php index 7cecf6dced..620b5c7172 100644 --- a/inc/reference_supplier.class.php +++ b/inc/reference_supplier.class.php @@ -350,11 +350,11 @@ public function showReferenceManufacturers($ID) echo "
"; echo "
"; - echo sprintf("" . __s("Check all") . "/"; - echo sprintf("" . __s("Uncheck all") . ""; + echo sprintf("", $rand) + . __s("Uncheck all") . ""; echo ""; echo Html::hidden('plugin_order_orders_id', ['value' => $order->getID()]); $this->dropdownBillItemsActions($order->getID()); diff --git a/inc/order_supplier.class.php b/inc/order_supplier.class.php index a0c8c5fb1e..c6a298c948 100644 --- a/inc/order_supplier.class.php +++ b/inc/order_supplier.class.php @@ -276,10 +276,10 @@ public static function showOrderSupplierInfos($ID) echo "
"; - echo sprintf("", $formname) . __s('Check all') . "/"; - echo sprintf("", $formname) . __s('Uncheck all') . ""; echo "
"; echo ""; - echo sprintf(""; + echo sprintf(""; - echo sprintf(""; echo ""; echo "
" . __s("Check all") . "", $rand) + . __s("Check all") . "/" . __s("Uncheck all") . ""; + echo sprintf("/", $rand) + . __s("Uncheck all") . ""; echo ""; echo ""; diff --git a/inc/surveysupplier.class.php b/inc/surveysupplier.class.php index c92d9d366a..3d4957b04d 100644 --- a/inc/surveysupplier.class.php +++ b/inc/surveysupplier.class.php @@ -30,6 +30,8 @@ use Glpi\DBAL\QueryExpression; +use function Safe\json_encode; + class PluginOrderSurveySupplier extends CommonDBChild { public static $rightname = 'plugin_order_order'; @@ -96,20 +98,21 @@ public function addNotation($field, $value) } echo ""; - echo sprintf("
", $rand); + $rateit_options = [ + 'value' => $value, + 'min' => 0, + 'max' => 5, + 'step' => 1, + 'backingfld' => sprintf('#%s%d', $field, $rand), + 'ispreset' => true, + 'resetable' => false, + ]; + echo sprintf("
", $rand, htmlescape(json_encode($rateit_options))); echo "
"; - echo ""; + echo Html::script('/plugins/order/js/order_items.js', [], false); } @@ -474,10 +477,10 @@ public static function showOrderSupplierSurvey($ID) echo ""; echo sprintf("", $arrow); echo ""; - echo sprintf("", $formname) . __s('Check all') . ""; + echo sprintf("", htmlescape($formname)) . __s('Check all') . ""; echo "/"; echo ""; - echo sprintf("", $formname) . __s('Uncheck all') . ""; + echo sprintf("", htmlescape($formname)) . __s('Uncheck all') . ""; echo ""; echo ". + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2009-2023 by Order plugin team. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://github.com/pluginsGLPI/order + * ------------------------------------------------------------------------- + */ + +$(document).on('click', '[data-order-mark-checkboxes]', function (e) { + if (markCheckboxes($(this).attr('data-order-mark-checkboxes'))) { + e.preventDefault(); + } +}); + +$(document).on('click', '[data-order-unmark-checkboxes]', function (e) { + if (unMarkCheckboxes($(this).attr('data-order-unmark-checkboxes'))) { + e.preventDefault(); + } +}); + +$(document).on('click', '[data-order-show-div]', function (e) { + const root_doc = CFG_GLPI.root_doc; + showHideDiv( + $(this).attr('data-order-show-div'), + $(this).attr('data-order-show-img'), + root_doc + '/pics/plus.png', + root_doc + '/pics/moins.png' + ); + e.preventDefault(); +}); + +$(document).on('click', '[data-order-select-container]', function () { + selectNItems( + $(this).attr('data-order-select-container'), + $(this).attr('data-order-select-target') + ); +}); + +document.addEventListener('click', (e) => { + const element = e.target.closest('[data-order-confirm]'); + if (element && !window.confirm(element.dataset.orderConfirm)) { + e.preventDefault(); + e.stopImmediatePropagation(); + } +}, true); + +$(document).on('click', '[data-order-reload-tab]', function (e) { + e.preventDefault(); + reloadTab($(this).attr('data-order-reload-tab')); +}); + +$(document).on('click', '[data-order-check-all]', function () { + checkAsCheckboxes(this, $(this).attr('data-order-check-all'), '.massive_action_checkbox'); +}); + +function selectNItems(container_id, select_id) { + var selectElement = document.getElementById(select_id); + if (!selectElement) { + console.error("Select element not found:", select_id); + return; + } + var n = parseInt(selectElement.value); + if (isNaN(n) || n <= 0) { + console.error("Invalid number selected:", selectElement.value); + return; + } + var checked = 0; + var selector = "#" + container_id + " input[type='checkbox'][name^='item[PluginOrderLink]']"; + var checkboxes = document.querySelectorAll(selector); + checkboxes.forEach(function(checkbox) { + checkbox.checked = false; + }); + checkboxes.forEach(function(checkbox) { + if (checked < n) { + checkbox.checked = true; + checked++; + } + }); +} + +$(document).on('click', '[data-order-add-reference]', function () { + plugin_order_checkboxAction(); +}); + +$(document).on('click', '[data-order-bulk-reception]', function (e) { + e.preventDefault(); + window[$(this).attr('data-order-bulk-reception')](); +}); + +$(document).on('click', '[data-order-toggle-table]', function () { + const toggle = $(this); + const div_table = $('[name="' + toggle.attr('data-order-toggle-table') + '"]'); + const icon = toggle.find('i'); + const textSpan = icon.next('span'); + const container_name = toggle.attr('data-order-toggle-container'); + const countainer = $('#' + container_name); + + let isVisible = !div_table.is(':hidden'); + + if (!isVisible) { + div_table.show(); + icon.removeClass('ti-sort-descending').addClass('ti-sort-ascending'); + textSpan.text(toggle.attr('data-order-collapse-label')); + countainer.val('true'); + isVisible = true; + } else { + div_table.hide(); + icon.removeClass('ti-sort-ascending').addClass('ti-sort-descending'); + textSpan.text(toggle.attr('data-order-expand-label')); + countainer.val('false'); + isVisible = false; + } + + // Update all reloadTab buttons to reflect the new visibility state + $('[data-order-reload-tab]').each(function () { + let params = $(this).attr('data-order-reload-tab'); + + let paramsObj = {}; + params.split('&').forEach(function (param) { + let [key, value] = param.split('='); + paramsObj[key] = value; + }); + + paramsObj[container_name + 'visible'] = isVisible ? '1' : '0'; + + let newParams = Object.entries(paramsObj).map(([key, value]) => `${key}=${value}`).join('&'); + $(this).attr('data-order-reload-tab', newParams); + }); +}); + +$(document).on('click', '[data-order-inline-edit]', function () { + const trigger = $(this); + trigger.hide(); + $('#' + trigger.attr('data-order-inline-form')).show(); + $.ajax({ + url: trigger.attr('data-order-inline-url'), + method: 'POST', + data: JSON.parse(trigger.attr('data-order-inline-params')), + success: function (data) { + $('#' + trigger.attr('data-order-inline-view')).html(data).show(); + } + }); +}); + +$(document).on('click', '[data-order-inline-cancel]', function () { + const form_id = $(this).attr('data-order-inline-cancel'); + $('[data-order-inline-form="' + form_id + '"]').each(function () { + $(this).show(); + $('#' + $(this).attr('data-order-inline-view') + ' input').remove(); + }); + $('#' + form_id).hide(); +}); diff --git a/public/js/order_generate_item.js b/public/js/order_generate_item.js new file mode 100644 index 0000000000..7c148c6854 --- /dev/null +++ b/public/js/order_generate_item.js @@ -0,0 +1,289 @@ +/** + * ------------------------------------------------------------------------- + * Order plugin for GLPI + * ------------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of Order. + * + * Order is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Order is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Order. If not, see . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2009-2023 by Order plugin team. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://github.com/pluginsGLPI/order + * ------------------------------------------------------------------------- + */ + +function plugin_order_config() { + return JSON.parse($("[data-order-generate-config]").first().attr("data-order-generate-config")); +} + + function plugin_order_adaptOnSelectedEntity(id, value) { + // Make AJAX call + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': value, + 'action': 'show_location_by_entity', + 'id': id + }, + success: function(response) { + // This part is missing - updating the target element with response + $('#show_location_by_entity_id_' + id).html(response); + } + }); + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': value, + 'action': 'show_group_by_entity', + 'multiple': plugin_order_config().multiple, + 'id': id + }, + success: function(response) { + $('#show_group_by_entity_id_' + id).html(response); + } + }); + + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': value, + 'action': 'show_state_by_entity', + 'id': id, + }, + success: function(response) { + $('#show_state_by_entity_id_' + id).html(response); + } + }); + } + + function plugin_order_setAllEntities(value) { + var elements = document.querySelectorAll('[id^="show_entity"]'); + plugin_order_adaptOnSelectedEntity('mass', value); + for (var i = 0; i < elements.length; i++) { + (function(index) { + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': 0, + 'action': 'update_entity', + 'id': index, + 'value': value + }, + success: function(response) { + $('#show_entity_id_' + index).html(response); + plugin_order_adaptOnSelectedEntity(index, value); + } + }); + })(i); + } + } + + function plugin_order_setAllLocations(value) { + var elements = document.querySelectorAll('[id^="show_location_by"]'); + for (var i = 0; i < elements.length; i++) { + (function(index) { + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': 0, + 'action': 'show_location_by_entity', + 'id': index, + 'value': value + }, + success: function(response) { + $('#show_location_by_entity_id_' + index).html(response); + } + }); + })(i); + } + } + + 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) { + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': 0, + 'action': 'show_group_by_entity', + 'id': index, + 'value': values, + 'multiple': plugin_order_config().multiple + }, + success: function(response) { + $('#show_group_by_entity_id_' + index).html(response); + } + }); + })(i); + } + } + + function plugin_order_setAllStates(value) { + var elements = document.querySelectorAll('[id^="show_state_by"]'); + for (var i = 0; i < elements.length; i++) { + (function(index) { + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'entities': 0, + 'action': 'show_state_by_entity', + 'id': index, + 'value': value + }, + success: function(response) { + $('#show_state_by_entity_id_' + index).html(response); + } + }); + })(i); + } + } + + function plugin_order_setFieldsFromTextarea(value, type) { + var lines = value.split(/\r?\n/); + var nameFields = document.querySelectorAll('input[name$="[' + type + ']"]'); + + for (var i = 0; i < nameFields.length; i++) { + var field = nameFields[i]; + if (i < lines.length) { + field.value = lines[i].trim(); + } else { + field.value = ''; + } + var event = new Event('change', { bubbles: true }); + field.dispatchEvent(event); + $(field).trigger('change'); + } + } + + $(function() { + // Namespaced off().on(): this script is re-executed each time the form is rendered + $('#mass_name_insertion').off('input.order_generate').on('input.order_generate', function() { + plugin_order_setFieldsFromTextarea(this.value, 'name'); + }); + + $('#mass_serial_insertion').off('input.order_generate').on('input.order_generate', function() { + plugin_order_setFieldsFromTextarea(this.value, 'serial'); + }); + + $('#mass_otherserial_insertion').off('input.order_generate').on('input.order_generate', function() { + plugin_order_setFieldsFromTextarea(this.value, 'otherserial'); + }); + + if (plugin_order_config().can_immo) { + $('#mass_immo_number_insertion').off('input.order_generate').on('input.order_generate', function() { + plugin_order_setFieldsFromTextarea(this.value, 'immo_number'); + }); + } + + // Mass dropdowns: replaces the former inline on_change attributes + $(document).off('change.order_generate') + .on('change.order_generate', 'select[name="mass[entities_id]"]', function() { + plugin_order_setAllEntities(this.value); + }) + .on('change.order_generate', 'select[name="mass[locations_id]"]', function() { + plugin_order_setAllLocations(this.value); + }) + .on('change.order_generate', 'select[name="mass[groups_id]"]', function() { + plugin_order_setAllGroups(this); + }) + .on('change.order_generate', 'select[name="mass[states_id]"]', function() { + plugin_order_setAllStates(this.value); + }) + .on('change.order_generate', 'select[name^="id["][name$="[entities_id]"]', function() { + plugin_order_adaptOnSelectedEntity(parseInt(this.name.match(/^id\[(\d+)\]/)[1], 10), this.value); + }); + }); + + function sendFieldUpdateToServer(field, fieldType) { + // Get field value + var fieldValue = field.value; + + // If field is empty, just remove validation states and return + if (fieldValue.trim() === '') { + $(field).removeClass('is-invalid'); + $(field).removeAttr('required'); + $(field).next('.invalid-feedback').remove(); + return; + } + + // Extract item ID from field name using regex + var namePattern = /id\[(\d+)\]\[/; + var matches = field.name.match(namePattern); + var itemId = matches ? matches[1] : 0; + + // Find itemtype - this should be passed from your PHP controller or set globally + var itemtype = $('input[name="id[' + itemId + '][itemtype]"]').val(); + + // Make AJAX call + $.ajax({ + url: CFG_GLPI.root_doc + '/plugins/order/ajax/linkactions.php', + type: 'POST', + data: { + 'action': 'check_unicity', + 'field': fieldType, + 'field_value': fieldValue, + 'itemtype': itemtype + }, + success: function(response) { + if (response.trim() == 'false') { + if ($(field).hasClass('is-invalid')) { + return; + } + + $(field).addClass('is-invalid'); + // Create field type label for the message + let fieldTypeLabel = ''; + if (fieldType === 'name') fieldTypeLabel = plugin_order_config().name_label; + if (fieldType === 'serial') fieldTypeLabel = plugin_order_config().serial_label; + + // Add error message after the input + $(field).after('
' + plugin_order_config().unicity_error + '
'); + + // Add required attribute for visual indication + $(field).attr('required', 'required'); + } else { + $(field).removeClass('is-invalid'); + $(field).removeAttr('required'); + $(field).next('.invalid-feedback').remove(); + } + } + }); + } + + $(function() { + // Namespaced off().on(): this script is re-executed each time the form is rendered + $('input[name^="id["][name$="[name]"]').off('input.order_generate change.order_generate').on('input.order_generate change.order_generate', function() { + sendFieldUpdateToServer(this, 'name'); + }); + + $('input[name^="id["][name$="[serial]"]').off('input.order_generate change.order_generate').on('input.order_generate change.order_generate', function() { + sendFieldUpdateToServer(this, 'serial'); + }); + }); diff --git a/public/js/order_items.js b/public/js/order_items.js new file mode 100644 index 0000000000..ad8ac2d151 --- /dev/null +++ b/public/js/order_items.js @@ -0,0 +1,46 @@ +/** + * ------------------------------------------------------------------------- + * Order plugin for GLPI + * ------------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of Order. + * + * Order is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Order is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Order. If not, see . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2009-2023 by Order plugin team. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://github.com/pluginsGLPI/order + * ------------------------------------------------------------------------- + */ + +// Init of the order items tables, run each time a table is rendered +(function () { + $('.filter-select-multiple:not(.select2-hidden-accessible)').select2(); + + $('[data-order-rateit]:not([data-order-ready])').each(function () { + $(this).attr('data-order-ready', ''); + $(this).rateit(JSON.parse($(this).attr('data-order-rateit'))); + }); + + $('[data-order-old-name]:not([data-order-ready])').each(function () { + $(this).attr('data-order-ready', ''); + $('body').append($('', { + type: 'hidden', + name: $(this).attr('data-order-old-name'), + value: $(this).attr('data-order-old-value') + })); + }); +})(); diff --git a/setup.php b/setup.php index 2c13e36ec6..bef3124b4d 100644 --- a/setup.php +++ b/setup.php @@ -196,6 +196,7 @@ function plugin_init_order() /*if glpi is loaded */ if (Session::getLoginUserID()) { $PLUGIN_HOOKS['add_css']['order'][] = 'css/order.css'; + $PLUGIN_HOOKS['add_javascript']['order'][] = 'js/order.js'; /* link to the config page in plugins menu */ if (Session::haveRight("config", UPDATE)) { @@ -231,6 +232,7 @@ function plugin_version_order() 'author' => 'The plugin order team', 'homepage' => 'https://github.com/pluginsGLPI/order', 'license' => 'GPLv2+', + 'csp_compliant' => true, 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_ORDER_MIN_GLPI, diff --git a/templates/generate_item.html.twig b/templates/generate_item.html.twig index 52c80bb57c..e499271b43 100644 --- a/templates/generate_item.html.twig +++ b/templates/generate_item.html.twig @@ -82,7 +82,7 @@ "mass[entities_id]", 0, "", - fields_option|merge({'on_change': 'plugin_order_setAllEntities(this.value)'}) + fields_option ) }} {% endif %} @@ -93,7 +93,7 @@ "mass[locations_id]", 0, "", - fields_option|merge({'on_change': 'plugin_order_setAllLocations(this.value)'}) + fields_option ) }} @@ -108,8 +108,7 @@ fields_option|merge({ 'entity': -1, 'condition': {'is_itemgroup': 1}, - 'multiple': assignableitem ? true : false, - 'on_change': 'plugin_order_setAllGroups(this)' + 'multiple': assignableitem ? true : false }) ) }} @@ -122,7 +121,7 @@ "mass[states_id]", 0, "", - fields_option|merge({'on_change': 'plugin_order_setAllStates(this.value)'}) + fields_option ) }} @@ -213,7 +212,7 @@ "id[" ~ item.i ~ "][entities_id]", item.order_entity_id, "", - fields_option|merge({'on_change': 'plugin_order_adaptOnSelectedEntity(' ~ item.i ~ ', this.value)'}) + fields_option ) }} @@ -268,244 +267,11 @@
- + +{{ call('Html::script', ['/plugins/order/js/order_generate_item.js', {}, false])|raw }} diff --git a/templates/order_getitems.html.twig b/templates/order_getitems.html.twig index 5c8ab6d274..f7bd818c88 100644 --- a/templates/order_getitems.html.twig +++ b/templates/order_getitems.html.twig @@ -46,7 +46,7 @@ {% set nosort = nosort|default(false) %} {% if hide_and_show is defined and hide_and_show %} -
  • - +
  • {% set current_page = (start / limit)|round(0, 'floor') + 1 %} @@ -435,21 +435,21 @@ {% for i in start_page..end_page %}
  • - +
  • {% endfor %}
  • - +
  • - +
  • {% endif %} @@ -458,11 +458,6 @@ {% endif %} - {# Inline editing functionality #} {% if canedit %} @@ -471,88 +466,10 @@ - {% endif %} {# Detail table editing #} @@ -560,75 +477,10 @@ - {% endif %} {% endif %} @@ -640,55 +492,5 @@ {% endif %} {% if hide_and_show is defined and hide_and_show %} - {% endif %} +{{ call('Html::script', ['/plugins/order/js/order_items.js', {}, false])|raw }} diff --git a/templates/order_link_item.html.twig b/templates/order_link_item.html.twig index d0bf17d867..3c42f0d8c2 100644 --- a/templates/order_link_item.html.twig +++ b/templates/order_link_item.html.twig @@ -57,7 +57,7 @@ {% if hide_and_show %} - - {% endif %} @@ -131,7 +105,7 @@
    + data-order-check-all="{{ massiveactionparams['container'] }}" />
    {% endif %} @@ -145,11 +119,11 @@ {% set new_order = (order == 'ASC' ? 'DESC' : 'ASC') %} {% endif %} - {% set sort_href = "javascript:reloadTab('start=" ~ start ~ "&" ~ countainer_name ~ "sort=" ~ colkey ~ "&" ~ countainer_name ~ "order=" ~ new_order ~ "&" ~ countainer_name ~ "visible=" ~ true ~ "');" %} + {% set sort_params = "start=" ~ start ~ "&" ~ countainer_name ~ "sort=" ~ colkey ~ "&" ~ countainer_name ~ "order=" ~ new_order ~ "&" ~ countainer_name ~ "visible=" ~ true %}
    {% if not nosort and not (column is array and column['nosort'] is defined) %} - + {% endif %} {{ raw_header ? column_label|raw : column_label }} @@ -242,14 +216,14 @@ {% if nb_pages > 1 %} {% endif %} @@ -281,58 +255,9 @@ {% endif %} - {% endif %} {% if hide_and_show %} - {% endif %} {% endif %} +{{ call('Html::script', ['/plugins/order/js/order_items.js', {}, false])|raw }}