From 1c7a5bcf11ba6f7f5333cffae73d0e627ac5114c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 23 Jan 2024 16:04:32 +0100 Subject: [PATCH] Bug 35506: Move the checkouts table load delay logic out of document ready == Test plan == 0. Have Selenium running ktd --selenium up 1. prove t/db_dependent/selenium/regressions.t 2. It should still work Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 934 ++++++++++--------- 1 file changed, 468 insertions(+), 466 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index c215c09340..3ab2ec6592 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -1,9 +1,474 @@ /* global __ */ -$(document).ready(function() { - var loadIssuesTableDelayTimeoutId; - var barcodefield = $("#barcode"); +function RefreshIssuesTable() { + var table = $('#issues-table').DataTable(); + var renewchecked = $('input[name=renew]:checked').map(function(){ + return this.value; + }).get(); + var checkinchecked = $('input[name=checkin]:checked').map(function(){ + return this.value; + }).get(); + table.ajax.reload( function() { + $('#RenewChecked, #CheckinChecked').prop('disabled' , true ); + if ( renewchecked.length ) { + $('#RenewChecked').prop('disabled' , false ); + renewchecked.forEach( function(checked) { + $('.renew[value="'+checked+'"]').prop('checked' , true ); + }); + } + if ( checkinchecked.length ) { + $('#CheckinChecked').prop('disabled' , false ); + checkinchecked.forEach( function(checked) { + $('.checkin[value="'+checked+'"]').prop('checked' , true ); + }); + } + var checkout_count = table.page.info().recordsTotal; + $('.checkout_count').text(checkout_count); + }); +} + +function LoadIssuesTable() { + $('#issues-table-loading-message').hide(); + $('#issues-table').show(); + $('#issues-table-actions').show(); + var msg_loading = __('Loading... you may continue scanning.'); + issuesTable = KohaTable("issues-table", { + "language": { + "emptyTable": msg_loading, + "processing": msg_loading, + }, + "autoWidth": false, + "dom": '<"table_controls"B>rt', + "columns": [ + { + "data": function( oObj ) { + return oObj.sort_order; + } + }, + { + "data": function( oObj ) { + if ( oObj.issued_today ) { + return "" + __("Today's checkouts") + ""; + } else { + return "" + __("Previous checkouts") + ""; + } + } + }, + { + "data": "date_due", + "visible": false, + }, + { + "orderData": 2, // Sort on hidden unformatted date due column + "data": function( oObj ) { + let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true }); + var due = oObj.date_due_overdue + ? "" + date_due_formatted + "" + : date_due_formatted; + + due = "" + due + ""; + + if ( oObj.lost && oObj.claims_returned ) { + due += "" + oObj.lost.escapeHtml() + ""; + } else if ( oObj.lost ) { + due += "" + oObj.lost.escapeHtml() + ""; + } + + if ( oObj.damaged ) { + due += "" + oObj.damaged.escapeHtml() + ""; + } + + var patron_note = " "; + due +="
" + patron_note; + + return due; + } + }, + { + "data": function ( oObj ) { + let title = "" + + (oObj.title ? oObj.title.escapeHtml() : '' ); + + $.each(oObj.subtitle, function( index, value ) { + title += " " + value.escapeHtml(); + }); + + title += " " + oObj.part_number + " " + oObj.part_name; + + if ( oObj.enumchron ) { + title += " (" + oObj.enumchron.escapeHtml() + ")"; + } + + title += ""; + + if ( oObj.author ) { + title += " " + __("by _AUTHOR_").replace( "_AUTHOR_", " " + oObj.author.escapeHtml() ); + } + + if ( oObj.itemnotes ) { + var span_class = "text-muted"; + if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ + span_class = "circ-hlt"; + } + title += " - " + oObj.itemnotes.escapeHtml() + ""; + } + + if ( oObj.itemnotes_nonpublic ) { + var span_class = "text-danger"; + if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ + span_class = "circ-hlt"; + } + title += " - " + oObj.itemnotes_nonpublic.escapeHtml() + ""; + } + + var onsite_checkout = ''; + if ( oObj.onsite_checkout == 1 ) { + onsite_checkout += " (" + __("On-site checkout") + ")"; + } + + if ( oObj.recalled == 1 ) { + title += " - " + __("This item has been recalled and the due date updated") + "."; + } + + title += " " + + "" + + (oObj.barcode ? oObj.barcode.escapeHtml() : "") + + "" + + onsite_checkout + + return title; + }, + "type": "anti-the" + }, + { + "data": function ( oObj ) { + return oObj.recordtype_description.escapeHtml(); + } + }, + { + "data": function ( oObj ) { + return oObj.itemtype_description.escapeHtml(); + } + }, + { + "data": function ( oObj ) { + return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); + } + }, + { + "data": function ( oObj ) { + return ( oObj.location ? oObj.location.escapeHtml() : '' ); + } + }, + { + "data": function ( oObj ) { + return (oObj.homebranch ? oObj.homebranch.escapeHtml() : '' ); + } + }, + { + "data": "issuedate", + "visible": false, + }, + { + "orderData": 10, // Sort on hidden unformatted issuedate column + "data": function( oObj ) { + return $datetime(oObj.issuedate, { no_tz_adjust: true }); + } + }, + { + "data": function ( oObj ) { + return (oObj.branchname ? oObj.branchname.escapeHtml() : '' ); + } + }, + { + "data": function ( oObj ) { + return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' ); + } + }, + { + "data": function ( oObj ) { + return ( oObj.copynumber ? oObj.copynumber.escapeHtml() : '' ); + } + }, + { + "data": function ( oObj ) { + if ( ! oObj.charge ) oObj.charge = 0; + return '' + parseFloat(oObj.charge).format_price() + ''; + }, + "className": "nowrap" + }, + { + "data": function ( oObj ) { + if ( ! oObj.fine ) oObj.fine = 0; + return '' + parseFloat(oObj.fine).format_price() + ''; + }, + "className": "nowrap" + }, + { + "data": function ( oObj ) { + if ( ! oObj.price ) oObj.price = 0; + return '' + parseFloat(oObj.price).format_price() + ''; + }, + "className": "nowrap" + }, + { + "orderable": false, + "visible": AllowCirculate ? true : false, + "data": function ( oObj ) { + var content = ""; + var msg = ""; + var span_style = ""; + var span_class = ""; + + if ( oObj.can_renew ) { + // Do nothing + } else if ( oObj.can_renew_error == "recalled" ) { + msg += "" + + "" + __("Recalled") + "" + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed-recalled"; + } else if ( oObj.can_renew_error == "on_reserve" ) { + msg += "" + +"" + __("On hold") + "" + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed-on_reserve"; + } else if ( oObj.can_renew_error == "too_many" ) { + msg += "" + + __("Not renewable") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "too_unseen" ) { + msg += "" + + __("Must be renewed at the library") + + ""; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "restriction" ) { + msg += "" + + __("Not allowed: patron restricted") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "overdue" ) { + msg += "" + + __("Not allowed: overdue") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "too_soon" ) { + msg += "" + + __("No renewal before %s").format(oObj.can_renew_date) + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "auto_too_late" ) { + msg += "" + + __("Can no longer be auto-renewed - number of checkout days exceeded") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { + msg += "" + + __("Automatic renewal failed, patron has unpaid fines") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "auto_account_expired" ) { + msg += "" + + __("Automatic renewal failed, account expired") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "onsite_checkout" ) { + // Don't display something if it's an onsite checkout + } else if ( oObj.can_renew_error == "item_denied_renewal" ) { + content += "" + + __("Renewal denied by syspref") + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else { + msg += "" + + oObj.can_renew_error + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } + + var can_force_renew = ( oObj.onsite_checkout == 0 ) && + ( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride)) + ? true : false; + var can_renew = ( oObj.renewals_remaining > 0 && ( !oObj.can_renew_error || oObj.can_renew_error == "too_unseen" )); + content += ""; + if ( can_renew || can_force_renew ) { + content += "" + oObj.renewals_count + ""; + content += "" + + "" + + ""; + } + content += msg; + if ( can_renew || can_force_renew ) { + content += "("; + content += __("%s of %s renewals remaining").format(oObj.renewals_remaining, oObj.renewals_allowed); + if (UnseenRenewals && oObj.unseen_allowed) { + content += __(" and %s of %s unseen renewals remaining").format(oObj.unseen_remaining, oObj.unseen_allowed); + } + content += ")"; + } + if(oObj.auto_renew){ + content += "("; + content += __("Scheduled for automatic renewal"); + content += ")"; + } + + return content; + } + }, + { + "orderable": false, + "visible": AllowCirculate ? true : false, + "data": function ( oObj ) { + if ( oObj.can_renew_error == "recalled" ) { + return "" + __("Recalled") + ""; + } else if ( oObj.can_renew_error == "on_reserve" ) { + return "" + __("On hold") + ""; + } else if ( oObj.materials ) { + return ""; + } else { + return ""; + } + } + }, + { + "visible": ClaimReturnedLostValue ? true : false, + "orderable": false, + "data": function ( oObj ) { + let content = ""; + + if ( oObj.return_claim_id ) { + content = '' + oObj.return_claim_created_on_formatted + ''; + } else if ( ClaimReturnedLostValue ) { + content = ' ' + __("Claim returned") + ''; + } else { + content = ' ' + __("Claim returned") + ''; + } + return content; + } + }, + { + "visible": exports_enabled == 1 ? true : false, + "orderable": false, + "data": function ( oObj ) { + var s = ""; + + s += ""; + return s; + } + } + ], + "footerCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { + var total_charge = 0; + var total_fine = 0; + var total_price = 0; + for ( var i=0; i < aaData.length; i++ ) { + total_charge += aaData[i]['charge'] * 1; + total_fine += aaData[i]['fine'] * 1; + total_price += aaData[i]['price'] * 1; + } + $("#totaldue").html(total_charge.format_price() ); + $("#totalfine").html(total_fine.format_price() ); + $("#totalprice").html(total_price.format_price() ); + }, + "paging": false, + "processing": true, + "serverSide": false, + "sAjaxSource": '/cgi-bin/koha/svc/checkouts', + "fnServerData": function ( sSource, aoData, fnCallback ) { + aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); + + $.getJSON( sSource, aoData, function (json) { + fnCallback(json) + } ); + }, + "rowGroup":{ + "dataSrc": "issued_today", + "startRender": function ( rows, group ) { + if ( group ) { + return __("Today's checkouts"); + } else { + return __("Previous checkouts"); + } + } + }, + "initComplete": function(oSettings, json) { + // Build a summary of checkouts grouped by itemtype + var checkoutsByItype = json.aaData.reduce(function (obj, row) { + obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1; + return obj; + }, {}); + var ul = $('
    '); + Object.keys(checkoutsByItype).sort().forEach(function (itype) { + var li = $('
  • ') + .append($('').html(itype || __("No itemtype"))) + .append(': ' + checkoutsByItype[itype]); + ul.append(li); + }) + $('
    ') + .addClass('checkouts-by-itemtype') + .append($('').html( __("Number of checkouts by item type") )) + .append(ul) + .insertBefore(oSettings.nTableWrapper) + }, + }, table_settings_issues_table); + + if ( $("#issues-table").length ) { + $("#issues-table_processing").position({ + of: $( "#issues-table" ), + collision: "none" + }); + } +} + +var loadIssuesTableDelayTimeoutId; +var barcodefield = $("#barcode"); + +$('#issues-table-load-now-button').click(function(){ + if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); + LoadIssuesTable(); + barcodefield.focus(); + return false; +}); + +$(document).ready(function() { var onHoldDueDateSet = false; @@ -271,12 +736,6 @@ $(document).ready(function() { } barcodefield.focus(); }); - $('#issues-table-load-now-button').click(function(){ - if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); - LoadIssuesTable(); - barcodefield.focus(); - return false; - }); if ( Cookies.get("issues-table-load-immediately-" + script) == "true" ) { if ( LoadCheckoutsTableDelay ) { @@ -292,463 +751,6 @@ $(document).ready(function() { Cookies.set("issues-table-load-immediately-" + script, $(this).is(':checked'), { expires: 365, sameSite: 'Lax' }); }); - function RefreshIssuesTable() { - var table = $('#issues-table').DataTable(); - var renewchecked = $('input[name=renew]:checked').map(function(){ - return this.value; - }).get(); - var checkinchecked = $('input[name=checkin]:checked').map(function(){ - return this.value; - }).get(); - table.ajax.reload( function() { - $('#RenewChecked, #CheckinChecked').prop('disabled' , true ); - if ( renewchecked.length ) { - $('#RenewChecked').prop('disabled' , false ); - renewchecked.forEach( function(checked) { - $('.renew[value="'+checked+'"]').prop('checked' , true ); - }); - } - if ( checkinchecked.length ) { - $('#CheckinChecked').prop('disabled' , false ); - checkinchecked.forEach( function(checked) { - $('.checkin[value="'+checked+'"]').prop('checked' , true ); - }); - } - var checkout_count = table.page.info().recordsTotal; - $('.checkout_count').text(checkout_count); - }); - } - - function LoadIssuesTable() { - $('#issues-table-loading-message').hide(); - $('#issues-table').show(); - $('#issues-table-actions').show(); - var msg_loading = __('Loading... you may continue scanning.'); - issuesTable = KohaTable("issues-table", { - "language": { - "emptyTable": msg_loading, - "processing": msg_loading, - }, - "autoWidth": false, - "dom": '<"table_controls"B>rt', - "columns": [ - { - "data": function( oObj ) { - return oObj.sort_order; - } - }, - { - "data": function( oObj ) { - if ( oObj.issued_today ) { - return "" + __("Today's checkouts") + ""; - } else { - return "" + __("Previous checkouts") + ""; - } - } - }, - { - "data": "date_due", - "visible": false, - }, - { - "orderData": 2, // Sort on hidden unformatted date due column - "data": function( oObj ) { - let date_due_formatted = $datetime(oObj.date_due, { as_due_date: true, no_tz_adjust: true }); - var due = oObj.date_due_overdue - ? "" + date_due_formatted + "" - : date_due_formatted; - - due = "" + due + ""; - - if ( oObj.lost && oObj.claims_returned ) { - due += "" + oObj.lost.escapeHtml() + ""; - } else if ( oObj.lost ) { - due += "" + oObj.lost.escapeHtml() + ""; - } - - if ( oObj.damaged ) { - due += "" + oObj.damaged.escapeHtml() + ""; - } - - var patron_note = " "; - due +="
    " + patron_note; - - return due; - } - }, - { - "data": function ( oObj ) { - let title = "" - + (oObj.title ? oObj.title.escapeHtml() : '' ); - - $.each(oObj.subtitle, function( index, value ) { - title += " " + value.escapeHtml(); - }); - - title += " " + oObj.part_number + " " + oObj.part_name; - - if ( oObj.enumchron ) { - title += " (" + oObj.enumchron.escapeHtml() + ")"; - } - - title += ""; - - if ( oObj.author ) { - title += " " + __("by _AUTHOR_").replace( "_AUTHOR_", " " + oObj.author.escapeHtml() ); - } - - if ( oObj.itemnotes ) { - var span_class = "text-muted"; - if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes.escapeHtml() + ""; - } - - if ( oObj.itemnotes_nonpublic ) { - var span_class = "text-danger"; - if ( flatpickr.formatDate( new Date(oObj.issuedate), "Y-m-d" ) == ymd ){ - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes_nonpublic.escapeHtml() + ""; - } - - var onsite_checkout = ''; - if ( oObj.onsite_checkout == 1 ) { - onsite_checkout += " (" + __("On-site checkout") + ")"; - } - - if ( oObj.recalled == 1 ) { - title += " - " + __("This item has been recalled and the due date updated") + "."; - } - - title += " " - + "" - + (oObj.barcode ? oObj.barcode.escapeHtml() : "") - + "" - + onsite_checkout - - return title; - }, - "type": "anti-the" - }, - { - "data": function ( oObj ) { - return oObj.recordtype_description.escapeHtml(); - } - }, - { - "data": function ( oObj ) { - return oObj.itemtype_description.escapeHtml(); - } - }, - { - "data": function ( oObj ) { - return ( oObj.collection ? oObj.collection.escapeHtml() : '' ); - } - }, - { - "data": function ( oObj ) { - return ( oObj.location ? oObj.location.escapeHtml() : '' ); - } - }, - { - "data": function ( oObj ) { - return (oObj.homebranch ? oObj.homebranch.escapeHtml() : '' ); - } - }, - { - "data": "issuedate", - "visible": false, - }, - { - "orderData": 10, // Sort on hidden unformatted issuedate column - "data": function( oObj ) { - return $datetime(oObj.issuedate, { no_tz_adjust: true }); - } - }, - { - "data": function ( oObj ) { - return (oObj.branchname ? oObj.branchname.escapeHtml() : '' ); - } - }, - { - "data": function ( oObj ) { - return ( oObj.itemcallnumber ? oObj.itemcallnumber.escapeHtml() : '' ); - } - }, - { - "data": function ( oObj ) { - return ( oObj.copynumber ? oObj.copynumber.escapeHtml() : '' ); - } - }, - { - "data": function ( oObj ) { - if ( ! oObj.charge ) oObj.charge = 0; - return '' + parseFloat(oObj.charge).format_price() + ''; - }, - "className": "nowrap" - }, - { - "data": function ( oObj ) { - if ( ! oObj.fine ) oObj.fine = 0; - return '' + parseFloat(oObj.fine).format_price() + ''; - }, - "className": "nowrap" - }, - { - "data": function ( oObj ) { - if ( ! oObj.price ) oObj.price = 0; - return '' + parseFloat(oObj.price).format_price() + ''; - }, - "className": "nowrap" - }, - { - "orderable": false, - "visible": AllowCirculate ? true : false, - "data": function ( oObj ) { - var content = ""; - var msg = ""; - var span_style = ""; - var span_class = ""; - - if ( oObj.can_renew ) { - // Do nothing - } else if ( oObj.can_renew_error == "recalled" ) { - msg += "" - + "" + __("Recalled") + "" - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed-recalled"; - } else if ( oObj.can_renew_error == "on_reserve" ) { - msg += "" - +"" + __("On hold") + "" - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed-on_reserve"; - } else if ( oObj.can_renew_error == "too_many" ) { - msg += "" - + __("Not renewable") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_unseen" ) { - msg += "" - + __("Must be renewed at the library") - + ""; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "restriction" ) { - msg += "" - + __("Not allowed: patron restricted") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "overdue" ) { - msg += "" - + __("Not allowed: overdue") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_soon" ) { - msg += "" - + __("No renewal before %s").format(oObj.can_renew_date) - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "auto_too_late" ) { - msg += "" - + __("Can no longer be auto-renewed - number of checkout days exceeded") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "auto_too_much_oweing" ) { - msg += "" - + __("Automatic renewal failed, patron has unpaid fines") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "auto_account_expired" ) { - msg += "" - + __("Automatic renewal failed, account expired") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "onsite_checkout" ) { - // Don't display something if it's an onsite checkout - } else if ( oObj.can_renew_error == "item_denied_renewal" ) { - content += "" - + __("Renewal denied by syspref") - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else { - msg += "" - + oObj.can_renew_error - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } - - var can_force_renew = ( oObj.onsite_checkout == 0 ) && - ( oObj.can_renew_error != "on_reserve" || (oObj.can_renew_error == "on_reserve" && AllowRenewalOnHoldOverride)) - ? true : false; - var can_renew = ( oObj.renewals_remaining > 0 && ( !oObj.can_renew_error || oObj.can_renew_error == "too_unseen" )); - content += ""; - if ( can_renew || can_force_renew ) { - content += "" + oObj.renewals_count + ""; - content += "" - + "" - + ""; - } - content += msg; - if ( can_renew || can_force_renew ) { - content += "("; - content += __("%s of %s renewals remaining").format(oObj.renewals_remaining, oObj.renewals_allowed); - if (UnseenRenewals && oObj.unseen_allowed) { - content += __(" and %s of %s unseen renewals remaining").format(oObj.unseen_remaining, oObj.unseen_allowed); - } - content += ")"; - } - if(oObj.auto_renew){ - content += "("; - content += __("Scheduled for automatic renewal"); - content += ")"; - } - - return content; - } - }, - { - "orderable": false, - "visible": AllowCirculate ? true : false, - "data": function ( oObj ) { - if ( oObj.can_renew_error == "recalled" ) { - return "" + __("Recalled") + ""; - } else if ( oObj.can_renew_error == "on_reserve" ) { - return "" + __("On hold") + ""; - } else if ( oObj.materials ) { - return ""; - } else { - return ""; - } - } - }, - { - "visible": ClaimReturnedLostValue ? true : false, - "orderable": false, - "data": function ( oObj ) { - let content = ""; - - if ( oObj.return_claim_id ) { - content = '' + oObj.return_claim_created_on_formatted + ''; - } else if ( ClaimReturnedLostValue ) { - content = ' ' + __("Claim returned") + ''; - } else { - content = ' ' + __("Claim returned") + ''; - } - return content; - } - }, - { - "visible": exports_enabled == 1 ? true : false, - "orderable": false, - "data": function ( oObj ) { - var s = ""; - - s += ""; - return s; - } - } - ], - "footerCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { - var total_charge = 0; - var total_fine = 0; - var total_price = 0; - for ( var i=0; i < aaData.length; i++ ) { - total_charge += aaData[i]['charge'] * 1; - total_fine += aaData[i]['fine'] * 1; - total_price += aaData[i]['price'] * 1; - } - $("#totaldue").html(total_charge.format_price() ); - $("#totalfine").html(total_fine.format_price() ); - $("#totalprice").html(total_price.format_price() ); - }, - "paging": false, - "processing": true, - "serverSide": false, - "sAjaxSource": '/cgi-bin/koha/svc/checkouts', - "fnServerData": function ( sSource, aoData, fnCallback ) { - aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); - - $.getJSON( sSource, aoData, function (json) { - fnCallback(json) - } ); - }, - "rowGroup":{ - "dataSrc": "issued_today", - "startRender": function ( rows, group ) { - if ( group ) { - return __("Today's checkouts"); - } else { - return __("Previous checkouts"); - } - } - }, - "initComplete": function(oSettings, json) { - // Build a summary of checkouts grouped by itemtype - var checkoutsByItype = json.aaData.reduce(function (obj, row) { - obj[row.type_for_stat] = (obj[row.type_for_stat] || 0) + 1; - return obj; - }, {}); - var ul = $('
      '); - Object.keys(checkoutsByItype).sort().forEach(function (itype) { - var li = $('
    • ') - .append($('').html(itype || __("No itemtype"))) - .append(': ' + checkoutsByItype[itype]); - ul.append(li); - }) - $('
      ') - .addClass('checkouts-by-itemtype') - .append($('').html( __("Number of checkouts by item type") )) - .append(ul) - .insertBefore(oSettings.nTableWrapper) - }, - }, table_settings_issues_table); - - if ( $("#issues-table").length ) { - $("#issues-table_processing").position({ - of: $( "#issues-table" ), - collision: "none" - }); - } - } - // Don't load relatives' issues table unless it is clicked on var relativesIssuesTable; $("#relatives-issues-tab").click( function() { -- 2.39.5