From 5e9fe6117695d6e9b825574ac2ffcd4b4680ee54 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Fri, 12 May 2023 21:09:57 -0300 Subject: [PATCH] Bug 8179: (follow-up) Fix currency change and remove datatables select Signed-off-by: Tomas Cohen Arazi --- .../lib/datatables/dataTables.select.min.js | 38 -------------- .../lib/datatables/select.dataTables.min.css | 1 - .../prog/en/includes/datatables.inc | 1 - .../prog/en/modules/acqui/orderreceive.tt | 50 +++++++++++++------ .../prog/en/modules/acqui/parcel.tt | 8 +-- 5 files changed, 36 insertions(+), 62 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js delete mode 100644 koha-tmpl/intranet-tmpl/lib/datatables/select.dataTables.min.css diff --git a/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js b/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js deleted file mode 100644 index 3765f6ce5d..0000000000 --- a/koha-tmpl/intranet-tmpl/lib/datatables/dataTables.select.min.js +++ /dev/null @@ -1,38 +0,0 @@ -/*! - Copyright 2015-2019 SpryMedia Ltd. - - This source file is free software, available under the following license: - MIT license - http://datatables.net/license/mit - - This source file 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 license files for details. - - For details please refer to: http://www.datatables.net/extensions/select - Select for DataTables 1.3.1 - 2015-2019 SpryMedia Ltd - datatables.net/license/mit -*/ -(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(k){return f(k,window,document)}):"object"===typeof exports?module.exports=function(k,p){k||(k=window);p&&p.fn.dataTable||(p=require("datatables.net")(k,p).$);return f(p,k,k.document)}:f(jQuery,window,document)})(function(f,k,p,h){function z(a,b,c){var d=function(c,b){if(c>b){var d=b;b=c;c=d}var e=!1;return a.columns(":visible").indexes().filter(function(a){a===c&&(e=!0);return a===b?(e=!1,!0):e})};var e= -function(c,b){var d=a.rows({search:"applied"}).indexes();if(d.indexOf(c)>d.indexOf(b)){var e=b;b=c;c=e}var f=!1;return d.filter(function(a){a===c&&(f=!0);return a===b?(f=!1,!0):f})};a.cells({selected:!0}).any()||c?(d=d(c.column,b.column),c=e(c.row,b.row)):(d=d(0,b.column),c=e(0,b.row));c=a.cells(c,d).flatten();a.cells(b,{selected:!0}).any()?a.cells(c).deselect():a.cells(c).select()}function v(a){var b=a.settings()[0]._select.selector;f(a.table().container()).off("mousedown.dtSelect",b).off("mouseup.dtSelect", -b).off("click.dtSelect",b);f("body").off("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"))}function A(a){var b=f(a.table().container()),c=a.settings()[0],d=c._select.selector,e;b.on("mousedown.dtSelect",d,function(a){if(a.shiftKey||a.metaKey||a.ctrlKey)b.css("-moz-user-select","none").one("selectstart.dtSelect",d,function(){return!1});k.getSelection&&(e=k.getSelection())}).on("mouseup.dtSelect",d,function(){b.css("-moz-user-select","")}).on("click.dtSelect",d,function(c){var b= -a.select.items();if(e){var d=k.getSelection();if((!d.anchorNode||f(d.anchorNode).closest("table")[0]===a.table().node())&&d!==e)return}d=a.settings()[0];var l=f.trim(a.settings()[0].oClasses.sWrapper).replace(/ +/g,".");if(f(c.target).closest("div."+l)[0]==a.table().container()&&(l=a.cell(f(c.target).closest("td, th")),l.any())){var g=f.Event("user-select.dt");m(a,g,[b,l,c]);g.isDefaultPrevented()||(g=l.index(),"row"===b?(b=g.row,w(c,a,d,"row",b)):"column"===b?(b=l.index().column,w(c,a,d,"column", -b)):"cell"===b&&(b=l.index(),w(c,a,d,"cell",b)),d._select_lastCell=g)}});f("body").on("click.dtSelect"+a.table().node().id.replace(/[^a-zA-Z0-9\-_]/g,"-"),function(b){!c._select.blurable||f(b.target).parents().filter(a.table().container()).length||0===f(b.target).parents("html").length||f(b.target).parents("div.DTE").length||r(c,!0)})}function m(a,b,c,d){if(!d||a.flatten().length)"string"===typeof b&&(b+=".dt"),c.unshift(a),f(a.table().node()).trigger(b,c)}function B(a){var b=a.settings()[0];if(b._select.info&& -b.aanFeatures.i&&"api"!==a.select.style()){var c=a.rows({selected:!0}).flatten().length,d=a.columns({selected:!0}).flatten().length,e=a.cells({selected:!0}).flatten().length,l=function(b,c,d){b.append(f('').append(a.i18n("select."+c+"s",{_:"%d "+c+"s selected",0:"",1:"1 "+c+" selected"},d)))};f.each(b.aanFeatures.i,function(b,a){a=f(a);b=f('');l(b,"row",c);l(b,"column",d);l(b,"cell",e);var g=a.children("span.select-info");g.length&&g.remove(); -""!==b.text()&&a.append(b)})}}function D(a){var b=new g.Api(a);a.aoRowCreatedCallback.push({fn:function(b,d,e){d=a.aoData[e];d._select_selected&&f(b).addClass(a._select.className);b=0;for(e=a.aoColumns.length;bg){var u=g;g=d;d=u}e.splice(g+1,e.length);e.splice(0,d)}else e.splice(f.inArray(c,e)+1,e.length);a[b](c,{selected:!0}).any()?(e.splice(f.inArray(c,e),1),a[b+"s"](e).deselect()):a[b+"s"](e).select()}function r(a,b){if(b||"single"===a._select.style)a=new g.Api(a),a.rows({selected:!0}).deselect(),a.columns({selected:!0}).deselect(),a.cells({selected:!0}).deselect()}function w(a,b,c,d,e){var f=b.select.style(),g=b.select.toggleable(),h=b[d](e,{selected:!0}).any();if(!h||g)"os"===f?a.ctrlKey|| -a.metaKey?b[d](e).select(!h):a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):(a=b[d+"s"]({selected:!0}),h&&1===a.flatten().length?b[d](e).deselect():(a.deselect(),b[d](e).select())):"multi+shift"==f?a.shiftKey?"cell"===d?z(b,e,c._select_lastCell||null):C(b,d,e,c._select_lastCell?c._select_lastCell[d]:null):b[d](e).select(!h):b[d](e).select(!h)}function t(a,b){return function(c){return c.i18n("buttons."+a,b)}}function x(a){a=a._eventNamespace; -return"draw.dt.DT"+a+" select.dt.DT"+a+" deselect.dt.DT"+a}function E(a,b){return-1!==f.inArray("rows",b.limitTo)&&a.rows({selected:!0}).any()||-1!==f.inArray("columns",b.limitTo)&&a.columns({selected:!0}).any()||-1!==f.inArray("cells",b.limitTo)&&a.cells({selected:!0}).any()?!0:!1}var g=f.fn.dataTable;g.select={};g.select.version="1.3.1";g.select.init=function(a){var b=a.settings()[0],c=b.oInit.select,d=g.defaults.select;c=c===h?d:c;d="row";var e="api",l=!1,u=!0,k=!0,m="td, th",p="selected",n=!1; -b._select={};!0===c?(e="os",n=!0):"string"===typeof c?(e=c,n=!0):f.isPlainObject(c)&&(c.blurable!==h&&(l=c.blurable),c.toggleable!==h&&(u=c.toggleable),c.info!==h&&(k=c.info),c.items!==h&&(d=c.items),e=c.style!==h?c.style:"os",n=!0,c.selector!==h&&(m=c.selector),c.className!==h&&(p=c.className));a.select.selector(m);a.select.items(d);a.select.style(e);a.select.blurable(l);a.select.toggleable(u);a.select.info(k);b._select.className=p;f.fn.dataTable.ext.order["select-checkbox"]=function(b,a){return this.api().column(a, -{order:"index"}).nodes().map(function(a){return"row"===b._select.items?f(a).parent().hasClass(b._select.className):"cell"===b._select.items?f(a).hasClass(b._select.className):!1})};!n&&f(a.table().node()).hasClass("selectable")&&a.select.style("os")};f.each([{type:"row",prop:"aoData"},{type:"column",prop:"aoColumns"}],function(a,b){g.ext.selector[b.type].push(function(a,d,e){d=d.selected;var c=[];if(!0!==d&&!1!==d)return e;for(var f=0,g=e.length;ftr.selected,table.dataTable tbody>tr>.selected{background-color:#B0BED9}table.dataTable.stripe tbody>tr.odd.selected,table.dataTable.stripe tbody>tr.odd>.selected,table.dataTable.display tbody>tr.odd.selected,table.dataTable.display tbody>tr.odd>.selected{background-color:#acbad4}table.dataTable.hover tbody>tr.selected:hover,table.dataTable.hover tbody>tr>.selected:hover,table.dataTable.display tbody>tr.selected:hover,table.dataTable.display tbody>tr>.selected:hover{background-color:#aab7d1}table.dataTable.order-column tbody>tr.selected>.sorting_1,table.dataTable.order-column tbody>tr.selected>.sorting_2,table.dataTable.order-column tbody>tr.selected>.sorting_3,table.dataTable.order-column tbody>tr>.selected,table.dataTable.display tbody>tr.selected>.sorting_1,table.dataTable.display tbody>tr.selected>.sorting_2,table.dataTable.display tbody>tr.selected>.sorting_3,table.dataTable.display tbody>tr>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody>tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody>tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody>tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody>tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody>tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody>tr.odd>.selected,table.dataTable.order-column.stripe tbody>tr.odd>.selected{background-color:#a6b4cd}table.dataTable.display tbody>tr.even>.selected,table.dataTable.order-column.stripe tbody>tr.even>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.selected:hover>.sorting_1,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody>tr.selected:hover>.sorting_2,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody>tr.selected:hover>.sorting_3,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_3{background-color:#a5b2cb}table.dataTable.display tbody>tr:hover>.selected,table.dataTable.display tbody>tr>.selected:hover,table.dataTable.order-column.hover tbody>tr:hover>.selected,table.dataTable.order-column.hover tbody>tr>.selected:hover{background-color:#a2aec7}table.dataTable tbody td.select-checkbox,table.dataTable tbody th.select-checkbox{position:relative}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody td.select-checkbox:after,table.dataTable tbody th.select-checkbox:before,table.dataTable tbody th.select-checkbox:after{display:block;position:absolute;top:1.2em;left:50%;width:12px;height:12px;box-sizing:border-box}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody th.select-checkbox:before{content:' ';margin-top:-6px;margin-left:-6px;border:1px solid black;border-radius:3px}table.dataTable tr.selected td.select-checkbox:after,table.dataTable tr.selected th.select-checkbox:after{content:'\2714';margin-top:-11px;margin-left:-4px;text-align:center;text-shadow:1px 1px #B0BED9, -1px -1px #B0BED9, 1px -1px #B0BED9, -1px 1px #B0BED9}div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0.5em}@media screen and (max-width: 640px){div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0;display:block}} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc index b411a7b60e..a545868ce7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc @@ -2,5 +2,4 @@ [% USE Asset %] [% INCLUDE 'format_price.inc' %] [% Asset.js("lib/datatables/datatables.min.js") | $raw %] -[% Asset.js("lib/datatables/dataTables.select.min.js") | $raw %] [% Asset.js("js/datatables.js") | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 297498ad5f..3548bc4aa6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -279,16 +279,18 @@ - + +
  • +
  • - - + + [% IF currencies.count %] - + [% FOR currency IN currencies %] - + [% END %] [% END %] @@ -656,6 +658,8 @@ return item.item_id; }) } + params['invoice_currency'] = row.invoice_currency; + params['invoice_unitprice'] = row.invoice_unit_price; return params; }; @@ -850,6 +854,8 @@ $("#order_edit").on("change", "input[name='change_currency']", function(){ if ( $(this).is(":checked") ) { $("#select_currency").show(); + if(!$("#invoice_unitprice").val()) + $("#invoice_unitprice").val($('#unitprice').val()); $("#unitprice").prop("readonly", "true"); } else { $("#select_currency").hide(); @@ -858,13 +864,17 @@ }); function _update_unitprice() { - var rate = Number($("select[name='currency'] option:selected").val()); - var unitprice = $("#unitprice_currency").val(); - var new_unitprice = Number( unitprice * rate ).toFixed(2); - $("#unitprice").val(new_unitprice).change(); + var row = $("#order_edit").data('row'); + var rate = Number($("select[name='invoice_currency'] option:selected").data('rate')); + var invoice_currency = $("select[name='invoice_currency'] option:selected").val(); + var invoice_unitprice = $("#invoice_unitprice").val(); + var unitprice = Number( invoice_unitprice * rate ).toFixed(2); + $("#unitprice").val(unitprice).change(); + row.invoice_currency = invoice_currency; + row.invoice_unit_price = invoice_unitprice; } - $("#order_edit").on("change", "select[name='currency']", _update_unitprice ); - $("#order_edit").on("change", "#unitprice_currency", _update_unitprice ); + $("#order_edit").on("change", "select[name='invoice_currency']", _update_unitprice ); + $("#order_edit").on("change", "#invoice_unitprice", _update_unitprice ); $("#order_edit").on("change", "#replacementprice", function() { var val = $(this).val(); @@ -1156,9 +1166,19 @@ $('#modal-order-main #items-panel').removeClass('show').addClass('hide'); } } - $("#select_currency").hide(); - $("#unitprice").prop("readonly", ""); - $("input[name='change_currency']").prop('checked', false); + if(row.invoice_unit_price) { + $("#select_currency").show(); + $("#unitprice").prop("readonly", true); + $("input[name='change_currency']").prop('checked', true); + $("#invoice_currency").val(row.invoice_currency); + $("#invoice_unitprice").val(row.invoice_unit_price); + } else { + $("#select_currency").hide(); + $("#unitprice").prop("readonly", ""); + $("input[name='change_currency']").prop('checked', false); + $("#invoice_currency").val(active_currency); + $("#invoice_unitprice").val(''); + } set_modal_buttons(); }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 5cd7291a4e..4b09a4d8f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -114,7 +114,7 @@ - + @@ -652,9 +652,6 @@ if (!ids.length) return; location.href = 'orderreceive.pl?multiple_orders=' + ids.join(',') + '&invoiceid=[% invoiceid | uri %]'; }).html(PENDING_MULTI_SELECTION.format('0')) - options.select = { - style: 'api' - }; options.order = [[1, 'asc']]; options.columns.unshift({ "data": function (row, type, val, meta) { @@ -673,16 +670,13 @@ var data = row.data(); $('.selOrder', row.node()).on('click', function (event) { if ($(this).prop('checked')) { - row.select(); selected_rows[data.order_id] = data; } else { - row.deselect(); delete selected_rows[data.order_id]; } $('#select_multiple').html(PENDING_MULTI_SELECTION.format(Object.keys(selected_rows).length)); }); if (selected_rows[data.order_id]) { - row.select(); $('.selOrder', row.node()).prop('checked', true); } }); -- 2.39.5
    Basket Basket group Order line