Bugzilla – Attachment 191298 Details for
Bug 41563
Tidy kohaTable block - acqui
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41563: Tidy kohaTable - acqui/orderreceive.tt
Bug-41563-Tidy-kohaTable---acquiorderreceivett.patch (text/plain), 10.84 KB, created by
Owen Leonard
on 2026-01-12 16:55:47 UTC
(
hide
)
Description:
Bug 41563: Tidy kohaTable - acqui/orderreceive.tt
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2026-01-12 16:55:47 UTC
Size:
10.84 KB
patch
obsolete
>From 257665e44ba6a0fd71ec53c5ab854aaa7697234a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 6 Jan 2026 16:40:36 +0100 >Subject: [PATCH] Bug 41563: Tidy kohaTable - acqui/orderreceive.tt > >See bug 41324 comment 6 >1. Variable serialization >2. Use of permissions and sysprefs > >We also removed 'UniqueItemFields' from the controller. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > acqui/orderreceive.pl | 19 +++-- > .../prog/en/modules/acqui/orderreceive.tt | 69 +++++++++++-------- > 2 files changed, 48 insertions(+), 40 deletions(-) > >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index ebfd813ba90..b55e8a200e1 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -166,16 +166,15 @@ unless ($acq_fw) { > my @gst_values = map { option => $_ + 0.0 }, split( '\|', C4::Context->preference("TaxRates") ); > > $template->param( >- freight => $freight, >- name => $bookseller->name, >- active_currency => $active_currency, >- currencies => $currencies->search( { rate => { '!=' => 1 } } ), >- invoiceincgst => $bookseller->invoiceincgst, >- invoiceid => $invoice->{invoiceid}, >- invoice => $invoice->{invoicenumber}, >- gst_values => \@gst_values, >- vendor => $bookseller, >- UniqueItemFields => C4::Context->preference('UniqueItemFields'), >+ freight => $freight, >+ name => $bookseller->name, >+ active_currency => $active_currency, >+ currencies => $currencies->search( { rate => { '!=' => 1 } } ), >+ invoiceincgst => $bookseller->invoiceincgst, >+ invoiceid => $invoice->{invoiceid}, >+ invoice => $invoice->{invoicenumber}, >+ gst_values => \@gst_values, >+ vendor => $bookseller, > ); > > my $patron = Koha::Patrons->find($loggedinuser)->unblessed; >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 96844943c94..e215c034e21 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -453,6 +453,22 @@ > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'js-date-format.inc' %] > [% INCLUDE 'format_price.inc' %] >+ <script> >+ var edit_mode = "[% edit | html %]"; >+ var invoiceincgst = "[% invoiceincgst | html %]"; >+ var active_currency = "[% active_currency.currency | html %]"; >+ var invoice_id = "[% invoiceid | html %]"; >+ const multiple_orders = "[% multiple_orders | html %]"; >+ const only_one_order = [% only_one_order ? 1 : 0 | html %]; >+ addPrefs({ >+ AcqCreateItem: [% Koha.Preference('AcqCreateItem') ? 1 : 0 | html %], >+ UniqueItemFields: [% Koha.Preference('UniqueItemFields') ? 1 : 0 | html %], >+ }); >+ addPermissions({ >+ CAN_user_acquisition: [% CAN_user_acquisition ? 1 : 0 | html %], >+ }); >+ </script> >+ > <script> > function display_string(key, strings, fallback) { > if ( strings.hasOwnProperty(key) ) { >@@ -538,18 +554,10 @@ > var SAVE_WARNING_TITLE = _("Warning"); > var SAVE_ERROR_TITLE = _("Error"); > >- >- var CAN_user_acquisition = "[% CAN_user_acquisition | html %]"; >- var AcqCreateItem = "[% Koha.Preference('AcqCreateItem') | html %]"; >- var edit_mode = "[% edit | html %]"; >- var invoiceincgst = "[% invoiceincgst | html %]"; >- var active_currency = "[% active_currency.currency | html %]"; >- var invoice_id = "[% invoiceid | html %]"; >- > $(document).ready(function(){ > // keep a copy for re-rendering > var $funds_tree = $('#bookfund').html(); >- var base_query = { "order_id": {"-in": [[% multiple_orders | html %]]}}; >+ var base_query = { "order_id": {"-in": multiple_orders.split(',')}}; > var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1"; > var options = { > ajax: { >@@ -640,11 +648,12 @@ > } > } > ], >- [% IF only_one_order %] >+ ...(only_one_order? >+ { > drawCallback: function( settings ) { > $("#order_edit").modal("show"); > }, >- [% END %] >+ } : {}), > }; > var orders_table = $("#multiple_orders").kohaTable(options); > var api = orders_table.api(); >@@ -669,11 +678,11 @@ > } > }); > >- [% IF only_one_order %] >- $("#quantity").on('change', function() { >- $('.modal-save').prop('disabled', $(this).val() < 1 ); >- }); >- [% END %] >+ if (only_one_order){ >+ $("#quantity").on('change', function() { >+ $('.modal-save').prop('disabled', $(this).val() < 1 ); >+ }); >+ } > > var _doSave = function(params) { > params.data.csrf_token = $('meta[name="csrf-token"]').attr('content'); >@@ -705,7 +714,7 @@ > params['quantity'] = row.quantity; > params['quantityrec'] = row.quantity_received; > params['origquantityrec'] = origrec; >- var effective_create_items = row.basket.create_items || AcqCreateItem; >+ var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; > params['tax_rate'] = (effective_create_items == 'receiving')?row.tax_rate_on_receiving:row.tax_rate_on_ordering; > params['replacementprice'] = row.replacement_price; > params['unitprice'] = ( invoiceincgst=="1" ) ? ( row.unit_price_tax_included || row.ecost_tax_included ) : ( row.unit_price_tax_excluded || row.ecost_tax_excluded ); >@@ -894,9 +903,9 @@ > $("#quantity").val(qty); > var row = $("#order_edit").data('row'); > row.quantity_received = qty; >- [% IF only_one_order %] >- $('.modal-save').prop('disabled', qty < 1 ); >- [% END %] >+ if (only_one_order){ >+ $('.modal-save').prop('disabled', qty < 1 ); >+ } > }) > > $("#order_edit").on("change", "#tax_rate", function() { >@@ -904,7 +913,7 @@ > if(val === null) $(this).val($('option:first-child', this).attr('value')); > val = $(this).val(); > var row = $("#order_edit").data('row'); >- var effective_create_items = row.basket.create_items || AcqCreateItem; >+ var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; > if(effective_create_items == 'receiving') { > row.tax_rate_on_receiving = val; > } else { >@@ -1032,7 +1041,7 @@ > orderable: false, > data: function(row, type, val, meta) { > if(row.invoice) { >- if(CAN_user_acquisition) { >+ if(permissions.CAN_user_acquisition) { > return '<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid='+row.invoice_id+'" title="Invoice detail page">'+row.invoice.invoice_number+"</a>"; > } > return row.invoice.invoice_number; >@@ -1104,7 +1113,7 @@ > var set_editor = function() { > var modal = $("#order_edit"); > var row = modal.data('row'); >- var effective_create_items = row.basket.create_items || AcqCreateItem; >+ var effective_create_items = row.basket.create_items || prefs.AcqCreateItem; > var origrec = $("#order_edit").data('origrec')||{}; > if(!origrec.hasOwnProperty(row.order_id)) { > origrec[row.order_id] = row.quantity_received; >@@ -1188,9 +1197,9 @@ > } > $("#quantity").val( row.quantity_received ) > .prop('readonly', !row.subscription_id && effective_create_items == 'receiving'); >- [% IF only_one_order %] >+ if (only_one_order){ > $(".modal-save").prop('disabled', $("#quantity").val() == 0); >- [% END %] >+ } > $('#qtyrecerror').hide(); > var tax_rate = row.tax_rate_on_receiving || row.tax_rate_on_ordering; > $("#tax_rate").val(tax_rate).change(); >@@ -1234,7 +1243,7 @@ > $("#acq-create-ordering").hide(); > if(row.items && row.items.length) { > row.items.forEach(function(item, index) { >- cloneItemBlock(index, '[% UniqueItemFields | html %]', function(block_id) { >+ cloneItemBlock(index, prefs.UniqueItemFields, function(block_id) { > var block = $('#'+block_id).hide(); > Object.keys(item).forEach(function(key) { > block >@@ -1243,14 +1252,14 @@ > .find('*[name=field_value]') > .val(item[key].field_value); > }); >- addItemInList(block_id, '[% UniqueItemFields | html %]'); >+ addItemInList(block_id, prefs.UniqueItemFields); > block.find("input[name='buttonPlus']").val( (window.MSG_ADDITEM_JS_UPDATEITEM ) ); > block.find("input[name='buttonPlusMulti']").remove(); > block.find("input[name='multiValue']").remove(); > }); > }); > } >- cloneItemBlock((row.items && row.items.length) || 0, '[% UniqueItemFields | html %]'); >+ cloneItemBlock((row.items && row.items.length) || 0, prefs.UniqueItemFields); > } else if (effective_create_items == 'ordering') { > $("#acq-create-receiving").hide(); > $("#acq-create-ordering").show(); >@@ -1361,9 +1370,9 @@ > var saved_rows = save_row(); > if(Object.keys(saved_rows).length) $('.save').prop('disabled', false); > $("#order_edit").modal('hide'); >- [% IF only_one_order %] >+ if (only_one_order){ > $(".save").click(); >- [% END %] >+ } > }) > > $("#order_edit").on("show.bs.modal", function (event) { >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41563
:
191069
|
191070
|
191071
|
191072
|
191073
|
191074
|
191075
|
191076
|
191077
|
191078
|
191079
|
191080
|
191290
|
191291
|
191292
|
191293
|
191294
|
191295
|
191296
|
191297
| 191298 |
191299
|
191300
|
191301
|
191302
|
191303