Bug 41563: Tidy kohaTable - acqui/parcel.tt

See bug 41324 comment 6
1. Variable serialization
2. Use of permissions and sysprefs

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2026-01-06 16:48:33 +01:00 committed by Lucas Gass
parent bb40a690d2
commit bd66dff065
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 32 additions and 17 deletions

View File

@ -355,6 +355,26 @@
margin-bottom: 20px;
}
</style>
<script>
addPrefs({
marcflavour: "[% Koha.Preference('marcflavour') | html %]",
});
let summary_fields = "biblio.title:biblio.author:biblio.isbn:biblio.publisher:me.internal_note:me.vendor_note";
if (prefs.marcflavour == 'UNIMARC'){
summary_fields += ":biblio.ean";
}
const vendor_id = [% booksellerid | html %];
const invoice_id = [% invoiceid | html %];
let table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'parcel', 'pending_orders', 'json' ) | $raw %];
const interface = "[% interface | html %]";
const theme = "[% theme | html %]";
const i18n = {
order: "[%tp("noun", "Order") | html %]",
};
</script>
<script>
dt_overwrite_html_sorting_localeCompare();
var PENDING_MULTI_SELECTION = _("Receive selected (%s)");
@ -443,9 +463,7 @@
}
},
{
[% SET summary_fields = "biblio.title:biblio.author:biblio.isbn:biblio.publisher:me.internal_note:me.vendor_note" %]
[% IF Koha.Preference('marcflavour')=='UNIMARC' %][% SET summary_fields = summary_fields _ ":biblio.ean" %][% END %]
data: "[% summary_fields | html %]",
data: summary_fields,
render: function(data, type, row, meta) {
var result = '';
if ( row && row.biblio_id != null ) {
@ -454,10 +472,9 @@
result += _(" by ") + escape_str(row.biblio.author);
if ( row.biblio.isbn != null )
result += " &ndash; " + escape_str(row.biblio.isbn);
[% IF Koha.Preference('marcflavour')=='UNIMARC' %]
if ( row.biblio.ean != null )
if (prefs.marcflavour == 'UNIMARC' && row.biblio.ean != null ) {
result += " &ndash; EAN:" + escape_str(row.biblio.ean);
[% END %]
}
if ( row.biblio.publisher != null ) {
result += "<br/>" + _("Publisher: ") + escape_str(row.biblio.publisher);
if ( row.biblio.publication_year != null ) {
@ -497,12 +514,12 @@
+ _("Internal note: ")
+ '</strong>' + escape_str(internal_note)
+ ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=' + invoice_id'
+ '&type=internal">' + _("Change internal note") + '</a>]</p>';
}
else {
result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=' + invoice_id
+ '&type=internal">' + _("Add internal note") + '</a>]';
}
@ -514,7 +531,7 @@
}
else {
result += ' [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber='
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid | uri %]'
+ encodeURIComponent(row.order_id) + '&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=' + invoice_id
+ '&type=vendor">' + _("Add vendor note") + '</a>]';
}
@ -531,7 +548,7 @@
result += '<button type="button" class="btn btn-default btn-xs dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false"><span class="visually-hidden">Toggle dropdown</span></button>';
result += '<ul class="dropdown-menu" aria-labelledby="view' + row.order_id + '">';
result += '<li><a class="dropdown-item previewData" href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '">[% tp("noun", "Order") | html %]</a></li>';
result += '<li><a class="dropdown-item previewData" href="/cgi-bin/koha/acqui/showorder.pl?ordernumber=' + encodeURIComponent(row.order_id) + '">' + i18n.order + '</a></li>';
result += '<li><a class="dropdown-item previewData" href="/cgi-bin/koha/catalogue/showmarc.pl?id=' + encodeURIComponent(row.biblio_id) + '">' + _("MARC") + '</a></li>';
result += '<li><a class="dropdown-item previewData" href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=' + encodeURIComponent(row.biblio_id) + '">' + _("Card") + '</a></li>';
result += '</ul>';
@ -576,7 +593,7 @@
data: "",
render: function(data, type, row, meta) {
return '<a href="orderreceive.pl?multiple_orders='
+ encodeURIComponent(row.order_id) + '&amp;invoiceid=[% invoiceid | uri %]' + '">'
+ encodeURIComponent(row.order_id) + '&amp;invoiceid=' + invoice_id + '">'
+ _("Receive") + '</a><br/>'
+ '<a href="#" onclick="transfer_order_popup(' + escape_str(row.order_id) + '); return false;">'
+ _("Transfer") + '</a>';
@ -598,7 +615,7 @@
result += '<a href="/cgi-bin/koha/acqui/cancelorder.pl?ordernumber='
+ encodeURIComponent(row.order_id)
+ '&biblionumber=' + encodeURIComponent(row.biblio_id)
+ '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">'
+ '&referrer=/cgi-bin/koha/acqui/parcel.pl?invoiceid=' + invoice_id
+ _("Cancel order") + '</a><br/>';
}
@ -654,7 +671,7 @@
$('#select_multiple').click(function () {
var ids = Object.keys(selected_rows);
if (!ids.length) return;
location.href = 'orderreceive.pl?multiple_orders=' + ids.join(',') + '&invoiceid=[% invoiceid | uri %]';
location.href = 'orderreceive.pl?multiple_orders=' + ids.join(',') + '&invoiceid=' + invoiceid
}).html(PENDING_MULTI_SELECTION.format('0'))
options.order = [[1, 'asc']];
options.columns.unshift({
@ -665,9 +682,7 @@
orderable: false
});
let table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'parcel', 'pending_orders', 'json' ) | $raw %];
var pending_orders_table = $("#pending_orders").kohaTable(options, table_settings, 1, { "basket.vendor_id": [% booksellerid | html %] });
var pending_orders_table = $("#pending_orders").kohaTable(options, table_settings, 1, { "basket.vendor_id": vendor_id });
var api = pending_orders_table.api();
api.on('draw', function () {
@ -690,7 +705,7 @@
$("#dataPreview").on("hidden.bs.modal", function(){
$("#dataPreviewLabel").html("");
$("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
$("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"" + interface + "/" + theme + "/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
});
$("body").on("click", ".previewData", function(e){