@@ -, +, @@ tables - adds a switch to turn off and on row grouping (today's checkouts vs previous checkouts) (on by default) - adds "column settings" for relatives' checkouts tables - factorize some code that was duplicated across the two DataTables configurations (mDataProp) the relatives checkouts table contain at least 10 checkouts. in both tables (sorting, pagination, the data itself, ...) --- admin/columns_settings.yml | 60 +- installer/data/mysql/atomicupdate/bug_15219.sql | 2 + installer/data/mysql/sysprefs.sql | 1 + .../plugins/jquery.dataTables.rowGrouping.js | 10 +- .../prog/en/includes/checkouts-table-footer.inc | 2 +- .../prog/en/includes/checkouts-table.inc | 1 - .../prog/en/includes/checkouts.js.inc | 24 + .../prog/en/includes/columns_settings.inc | 2 +- .../intranet-tmpl/prog/en/includes/datatables.inc | 20 +- .../intranet-tmpl/prog/en/includes/strings.inc | 1 + koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 689 +++++++++++---------- .../en/modules/admin/preferences/circulation.pref | 6 + .../prog/en/modules/circ/circulation.tt | 13 +- .../prog/en/modules/members/moremember.tt | 12 +- svc/checkouts | 108 ++-- 15 files changed, 495 insertions(+), 456 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15219.sql create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc --- a/admin/columns_settings.yml +++ a/admin/columns_settings.yml @@ -187,7 +187,7 @@ modules: moremember: issues-table: - - columnname: sort_order + columnname: group_order cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 @@ -197,11 +197,6 @@ modules: cannot_be_modified: 1 is_hidden: 1 - - columnname: due_date_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - - columnname: due_date - columnname: title @@ -233,6 +228,29 @@ modules: columnname: export cannot_be_toggled: 1 cannot_be_modified: 1 + relatives-issues-table: + - + columnname: due_date + - + columnname: title + - + columnname: item_type + - + columnname: location + - + columnname: checkout_on + - + columnname: checkout_from + - + columnname: callno + - + columnname: charge + - + columnname: fine + - + columnname: price + - + columnname: patron reports: lostitems: @@ -270,7 +288,7 @@ modules: circulation: issues-table: - - columnname: sort_order + columnname: group_order cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 @@ -280,11 +298,6 @@ modules: cannot_be_modified: 1 is_hidden: 1 - - columnname: due_date_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - - columnname: due_date - columnname: title @@ -316,6 +329,29 @@ modules: columnname: export cannot_be_toggled: 1 cannot_be_modified: 1 + relatives-issues-table: + - + columnname: due_date + - + columnname: title + - + columnname: item_type + - + columnname: location + - + columnname: checkout_on + - + columnname: checkout_from + - + columnname: callno + - + columnname: charge + - + columnname: fine + - + columnname: price + - + columnname: patron returns: checkedintable: --- a/installer/data/mysql/atomicupdate/bug_15219.sql +++ a/installer/data/mysql/atomicupdate/bug_15219.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) +VALUES ('ServerSideCheckoutsTables','0',NULL,'If enabled, use the "server-side processing" feature for checkouts tables. Can improve performance when there is a big number of checkouts to display.','YesNo'); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -427,6 +427,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'), ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), +('ServerSideCheckoutsTables','0',NULL,'If enabled, use the "server-side processing" feature for checkouts tables. Can improve performance when there is a big number of checkouts per patron.','YesNo'), ('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'), ('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'), ('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'), --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js +++ a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js @@ -608,15 +608,15 @@ } - oTable.fnSetColumnVis(properties.iGroupingColumnIndex, !properties.bHideGroupingColumn); + oTable.fnSetColumnVis(properties.iGroupingColumnIndex, !properties.bHideGroupingColumn, false); if (properties.bCustomColumnOrdering) { - oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex, !properties.bHideGroupingOrderByColumn); + oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex, !properties.bHideGroupingOrderByColumn, false); } if (properties.iGroupingColumnIndex2 != -1) { - oTable.fnSetColumnVis(properties.iGroupingColumnIndex2, !properties.bHideGroupingColumn2); + oTable.fnSetColumnVis(properties.iGroupingColumnIndex2, !properties.bHideGroupingColumn2, false); } if (properties.bCustomColumnOrdering2) { - oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex2, !properties.bHideGroupingOrderByColumn2); + oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex2, !properties.bHideGroupingOrderByColumn2, false); } oTable.fnSettings().aoDrawCallback.push({ "fn": _fnDrawCallBackWithGrouping, @@ -687,4 +687,4 @@ }); }; -})(jQuery); +})(jQuery); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc @@ -1,6 +1,6 @@ - Totals: + Totals: [% totaldue %] [% finetotal %] [% totalprice %] --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -13,7 +13,6 @@     Due date - Due date Title Item type Location --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc @@ -0,0 +1,24 @@ +[% USE Koha %] + + + + --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -28,7 +28,7 @@ function KohaTable(selector, dt_parameters, columns_settings) { var table = $(selector).dataTable($.extend(true, {}, dataTablesDefaults, dt_parameters)); $(hidden_ids).each(function(index, value) { - table.fnSetColumnVis( value, false ); + table.fnSetColumnVis( value, false, false ); }); return table; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc @@ -3,23 +3,5 @@ - +[% INCLUDE 'datatables-strings.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc @@ -38,5 +38,6 @@ var SUSPEND_HOLD_ERROR_DATE = _("Unable to suspend hold, invalid date"); var SUSPEND_HOLD_ERROR_NOT_FOUND = _("Unable to suspend hold, hold not found"); var RESUME_HOLD_ERROR_NOT_FOUND = _("Unable to resume, hold not found"); + var GROUP_TODAYS_CHECKOUTS = _("Group today's checkouts"); //]]> --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -1,3 +1,242 @@ +(function($) { + +var ymd = $.datepicker.formatDate('yy-mm-dd', new Date()); + +function enableGrouping(datatable) { + datatable.rowGrouping({ + iGroupingColumnIndex: 1, + iGroupingOrderByColumnIndex: 0, + sGroupingColumnSortDirection: "desc" + }); +} + +function disableGrouping(datatable) { + var oSettings = datatable.fnSettings(); + for (f = 0; f < oSettings.aoDrawCallback.length; f++) { + if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') { + oSettings.aoDrawCallback.splice(f, 1); + oSettings.aaSortingFixed = null; + datatable.fnDraw(); + break; + } + } +} + +var mRenders = { + groupOrder: function (oData, sType, oObj) { + if ( oObj.issued_today ) { + return "1"; + } else { + return "0"; + } + }, + groupName: function (oData, sType, oObj) { + if (oObj.issued_today) { + return "" + TODAYS_CHECKOUTS + ""; + } else { + return "" + PREVIOUS_CHECKOUTS + ""; + } + }, + dateDueFormatted: function (oData, sType, oObj) { + var due = oObj.date_due_formatted; + + if (oObj.date_due_overdue) { + due = "" + due + ""; + } + + if (oObj.lost) { + due += "" + oObj.lost + ""; + } + + if (oObj.damaged) { + due += "" + oObj.damaged + ""; + } + + due = "" + due + ""; + + return due; + }, + title: function (oData, sType, oObj) { + var title = "" + + oObj.title; + + $.each(oObj.subtitle, function (index, value) { + title += " " + value.subfield; + }); + + title += ""; + + if (oObj.author) { + title += " " + BY.replace("_AUTHOR_", " " + oObj.author); + } + + if (oObj.itemnotes) { + var span_class = ""; + if ($.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate)) == ymd) { + span_class = "circ-hlt"; + } + title += " - " + oObj.itemnotes + "" + } + + if ( oObj.itemnotes_nonpublic ) { + var span_class = ""; + if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { + span_class = "circ-hlt"; + } + title += " - " + oObj.itemnotes_nonpublic + "" + } + + var onsite_checkout = ''; + if (oObj.onsite_checkout == 1) { + onsite_checkout += " (" + INHOUSE_USE + ")"; + } + + title += " " + + "" + + oObj.barcode + + "" + + onsite_checkout; + + return title; + }, + itemtype: function (oData, sType, oObj) { + return oObj.itemtype_description; + }, + issuedate: function (oData, sType, oObj) { + return oObj.issuedate_formatted; + }, + branch: function (oData, sType, oObj) { + return oObj.branchname; + }, + charge: function (oData, sType, oObj) { + if (!oObj.charge) oObj.charge = 0; + return '' + parseFloat(oObj.charge).toFixed(2) + ''; + }, + fine: function (oData, sType, oObj) { + if (!oObj.fine) oObj.fine = 0; + return '' + parseFloat(oObj.fine).toFixed(2) + ''; + }, + price: function (oData, sType, oObj) { + if (!oObj.price) oObj.price = 0; + return parseFloat(oObj.price).toFixed(2); + }, + renew: function (oData, sType, oObj) { + var content = ""; + var span_style = ""; + var span_class = ""; + + content += ""; + content += "" + oObj.renewals_count + ""; + + if (oObj.can_renew) { + // Do nothing + } else if (oObj.can_renew_error == "on_reserve") { + content += "" + + "" + ON_HOLD + "" + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "too_many") { + content += "" + + NOT_RENEWABLE + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "restriction") { + content += "" + + NOT_RENEWABLE_RESTRICTION + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "overdue") { + content += "" + + NOT_RENEWABLE_OVERDUE + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "too_soon") { + content += "" + + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "auto_too_soon") { + content += "" + + NOT_RENEWABLE_AUTO_TOO_SOON + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if (oObj.can_renew_error == "auto_renew") { + content += "" + + NOT_RENEWABLE_AUTO_RENEW + + ""; + + 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 { + content += "" + + 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"); + var can_renew = (oObj.renewals_remaining > 0 && !oObj.can_renew_error); + if (can_renew || can_force_renew) { + content += "" + + "" + + ""; + + content += "(" + + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) + + ")"; + } + + content += ""; + + return content; + }, + checkin: function (oData, sType, oObj) { + if (oObj.can_renew_error == "on_reserve") { + return "" + ON_HOLD + ""; + } else { + return ""; + } + }, + export: function (oData, sType, oObj) { + var s = ""; + + s += ""; + return s; + }, + patron: function (oData, sType, oObj) { + return "" + + oObj.borrower.firstname + " " + oObj.borrower.surname + " (" + oObj.borrower.cardnumber + ")" + } +}; + $(document).ready(function() { $.ajaxSetup ({ cache: false }); @@ -139,8 +378,6 @@ $(document).ready(function() { return false; }); - var ymd = $.datepicker.formatDate('yy-mm-dd', new Date()); - $('#issues-table').hide(); $('#issues-table-actions').hide(); $('#issues-table-load-immediately').change(function(){ @@ -174,16 +411,24 @@ $(document).ready(function() { "sProcessing": MSG_DT_LOADING_RECORDS, }, "bAutoWidth": false, - "dom": 'B<"clearfix">rt', + "bProcessing": true, + "bServerSide": ServerSideCheckoutsTables, + "sAjaxSource": "/cgi-bin/koha/svc/checkouts", + "fnServerParams": function (aoData) { + aoData.push({ "name": "borrowernumber", "value": borrowernumber }); + }, + "bPaginate": true, + "sPaginationType": "four_button", + "dom": 'B<"clearfix"><"top pager"ilp>rt', + "aaSorting": [], "aoColumns": [ { - "mDataProp": function( oObj ) { - return oObj.sort_order; - } + "mData": "issued_today", + "mRender": mRenders.groupOrder }, { - "mDataProp": function( oObj ) { - if ( oObj.issued_today ) { + "mData": function (oObj) { + if (oObj.issued_today) { return "" + TODAYS_CHECKOUTS + ""; } else { return "" + PREVIOUS_CHECKOUTS + ""; @@ -191,222 +436,56 @@ $(document).ready(function() { } }, { - "mDataProp": "date_due", - "bVisible": false, + "mData": "date_due", + "mRender": mRenders.dateDueFormatted }, { - "iDataSort": 2, // Sort on hidden unformatted date due column - "mDataProp": function( oObj ) { - var due = oObj.date_due_formatted; - - if ( oObj.date_due_overdue ) { - due = "" + due + ""; - } - - if ( oObj.lost ) { - due += "" + oObj.lost + ""; - } - - if ( oObj.damaged ) { - due += "" + oObj.damaged + ""; - } - - due = "" + due + ""; - - return due; - } + "mData": "title", + "mRender": mRenders.title }, { - "mDataProp": function ( oObj ) { - title = "" - + oObj.title; - - $.each(oObj.subtitle, function( index, value ) { - title += " " + value.subfield; - }); - - title += ""; - - if ( oObj.author ) { - title += " " + BY.replace( "_AUTHOR_", " " + oObj.author ); - } - - if ( oObj.itemnotes ) { - var span_class = ""; - if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes + "" - } - - if ( oObj.itemnotes_nonpublic ) { - var span_class = ""; - if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes_nonpublic + "" - } - - var onsite_checkout = ''; - if ( oObj.onsite_checkout == 1 ) { - onsite_checkout += " (" + INHOUSE_USE + ")"; - } - - title += " " - + "" - + oObj.barcode - + "" - + onsite_checkout; - - return title; - }, - "sType": "anti-the" + "mData": "itemtype", + "mRender": mRenders.itemtype }, - { "mDataProp": "itemtype_description" }, - { "mDataProp": "location" }, - { "mDataProp": "issuedate_formatted" }, - { "mDataProp": "branchname" }, - { "mDataProp": "itemcallnumber" }, + { "mData": "location" }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.charge ) oObj.charge = 0; - return '' + parseFloat(oObj.charge).toFixed(2) + ''; - } + "mData": "issuedate", + "mRender": mRenders.issuedate }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.fine ) oObj.fine = 0; - return '' + parseFloat(oObj.fine).toFixed(2) + ''; - } + "mData": "branchcode", + "mRender": mRenders.branch }, + { "mData": "itemcallnumber" }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.price ) oObj.price = 0; - return '' + parseFloat(oObj.price).toFixed(2) + ''; - } + "mData": "charge", + "mRender": mRenders.charge, + "bSortable": ServerSideCheckoutsTables ? false : true + }, + { + "mData": "fine", + "mRender": mRenders.fine, + "bSortable": ServerSideCheckoutsTables ? false : true + }, + { + "mData": "replacementprice", + "mRender": mRenders.price, + "bSortable": ServerSideCheckoutsTables ? false : true }, { - "bSortable": false, "bVisible": AllowCirculate ? true : false, - "mDataProp": function ( oObj ) { - var content = ""; - var span_style = ""; - var span_class = ""; - - content += ""; - content += "" + oObj.renewals_count + ""; - - if ( oObj.can_renew ) { - // Do nothing - } else if ( oObj.can_renew_error == "on_reserve" ) { - content += "" - + "" + ON_HOLD + "" - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_many" ) { - content += "" - + NOT_RENEWABLE - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "restriction" ) { - content += "" - + NOT_RENEWABLE_RESTRICTION - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "overdue" ) { - content += "" - + NOT_RENEWABLE_OVERDUE - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "too_soon" ) { - content += "" - + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "auto_too_soon" ) { - content += "" - + NOT_RENEWABLE_AUTO_TOO_SOON - + ""; - - span_style = "display: none"; - span_class = "renewals-allowed"; - } else if ( oObj.can_renew_error == "auto_renew" ) { - content += "" - + NOT_RENEWABLE_AUTO_RENEW - + ""; - - 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 { - content += "" - + 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" ); - var can_renew = ( oObj.renewals_remaining > 0 && !oObj.can_renew_error ); - if ( can_renew || can_force_renew ) { - content += "" - + "" - + ""; - - content += "(" - + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) - + ")"; - } - - content += ""; - - return content; - } + "mRender": mRenders.renew, + "bSortable": false }, { - "bSortable": false, "bVisible": AllowCirculate ? true : false, - "mDataProp": function ( oObj ) { - if ( oObj.can_renew_error == "on_reserve" ) { - return "" + ON_HOLD + ""; - } else { - return ""; - } - } + "mRender": mRenders.checkin, + "bSortable": false }, { "bVisible": exports_enabled ? true : false, "bSortable": false, - "mDataProp": function ( oObj ) { - var s = ""; - - s += ""; - return s; - } + "mRender": mRenders.export } ], "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { @@ -421,39 +500,30 @@ $(document).ready(function() { $("#totaldue").html(total_charge.toFixed(2)); $("#totalfine").html(total_fine.toFixed(2)); $("#totalprice").html(total_price.toFixed(2)); - }, - "bPaginate": false, - "bProcessing": true, - "bServerSide": 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) - } ); - }, - "fnInitComplete": function(oSettings) { - // Disable rowGrouping plugin after first use - // so any sorting on the table doesn't use it - var oSettings = issuesTable.fnSettings(); - - for (f = 0; f < oSettings.aoDrawCallback.length; f++) { - if (oSettings.aoDrawCallback[f].sName == 'fnRowGrouping') { - oSettings.aoDrawCallback.splice(f, 1); - break; - } - } - - oSettings.aaSortingFixed = null; - }, - }, columns_settings).rowGrouping( - { - iGroupingColumnIndex: 1, - iGroupingOrderByColumnIndex: 0, - sGroupingColumnSortDirection: "asc" } - ); + }, columns_settings); + + enableGrouping(issuesTable); + + var groupingSwitch = $('') + .attr('id', 'issues-table-row-grouping-switch') + .attr('checked', 'checked') + .css('vertical-align', 'middle') + .change(function() { + if ($(this).is(':checked')) { + enableGrouping(issuesTable); + } else { + disableGrouping(issuesTable); + } + }); + $('
') + .css('float', 'left') + .css('padding', '0.3em 0.5em') + .css('line-height', '1.9em') + .append(groupingSwitch) + .append(' ') + .append('') + .appendTo('#issues-table_wrapper .top.pager'); if ( $("#issues-table").length ) { $("#issues-table_processing").position({ @@ -467,125 +537,60 @@ $(document).ready(function() { var relativesIssuesTable; $("#relatives-issues-tab").click( function() { if ( ! relativesIssuesTable ) { - relativesIssuesTable = $("#relatives-issues-table").dataTable({ + relativesIssuesTable = KohaTable("#relatives-issues-table", { "bAutoWidth": false, - "sDom": "rt", - "aaSorting": [], + "sDom": 'C<"top pager"ilp>rt', + "aaSorting": [[4, "desc"]], + "bProcessing": true, + "bServerSide": ServerSideCheckoutsTables, + "sAjaxSource": "/cgi-bin/koha/svc/checkouts", + "fnServerParams": function (aoData) { + for (i in relatives_borrowernumbers) { + var borrowernumber = relatives_borrowernumbers[i]; + aoData.push({ "name": "borrowernumber", "value": borrowernumber }); + } + }, + "bPaginate": true, + "sPaginationType": "four_button", "aoColumns": [ { - "mDataProp": "date_due", - "bVisible": false, + "mData": "date_due", + "mRender": mRenders.dateDueFormatted }, { - "iDataSort": 1, // Sort on hidden unformatted date due column - "mDataProp": function( oObj ) { - var today = new Date(); - var due = new Date( oObj.date_due ); - if ( today > due ) { - return "" + oObj.date_due_formatted + ""; - } else { - return oObj.date_due_formatted; - } - } + "mData": "title", + "mRender": mRenders.title, }, + { "mData": "itemtype" }, + { "mData": "location" }, { - "mDataProp": function ( oObj ) { - title = "" - + oObj.title; - - $.each(oObj.subtitle, function( index, value ) { - title += " " + value.subfield; - }); - - title += ""; - - if ( oObj.author ) { - title += " " + BY.replace( "_AUTHOR_", " " + oObj.author ); - } - - if ( oObj.itemnotes ) { - var span_class = ""; - if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes + "" - } - - if ( oObj.itemnotes_nonpublic ) { - var span_class = ""; - if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { - span_class = "circ-hlt"; - } - title += " - " + oObj.itemnotes_nonpublic + "" - } - - var onsite_checkout = ''; - if ( oObj.onsite_checkout == 1 ) { - onsite_checkout += " (" + INHOUSE_USE + ")"; - } - - title += " " - + "" - + oObj.barcode - + "" - + onsite_checkout; - - return title; - }, - "sType": "anti-the" + "mData": "issuedate", + "mRender": mRenders.issuedate }, - { "mDataProp": "itemtype" }, - { "mDataProp": "location" }, - { "mDataProp": "issuedate_formatted" }, - { "mDataProp": "branchname" }, - { "mDataProp": "itemcallnumber" }, + { "mData": "branchname" }, + { "mData": "itemcallnumber" }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.charge ) oObj.charge = 0; - return parseFloat(oObj.charge).toFixed(2); - } + "mData": "charge", + "mRender": mRenders.charge, + "bSortable": ServerSideCheckoutsTables ? false : true }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.fine ) oObj.fine = 0; - return parseFloat(oObj.fine).toFixed(2); - } + "mData": "fine", + "mRender": mRenders.fine, + "bSortable": ServerSideCheckoutsTables ? false : true }, { - "mDataProp": function ( oObj ) { - if ( ! oObj.price ) oObj.price = 0; - return parseFloat(oObj.price).toFixed(2); - } + "mData": "replacementprice", + "mRender": mRenders.price, + "bSortable": ServerSideCheckoutsTables ? false : true }, { - "mDataProp": function( oObj ) { - return "" - + oObj.borrower.firstname + " " + oObj.borrower.surname + " (" + oObj.borrower.cardnumber + ")" - } - }, - ], - "bPaginate": false, - "bProcessing": true, - "bServerSide": false, - "sAjaxSource": '/cgi-bin/koha/svc/checkouts', - "fnServerData": function ( sSource, aoData, fnCallback ) { - $.each(relatives_borrowernumbers, function( index, value ) { - aoData.push( { "name": "borrowernumber", "value": value } ); - }); - - $.getJSON( sSource, aoData, function (json) { - fnCallback(json) - } ); - }, - }); + "mData": "borrowernumber", + "mRender": mRenders.patron, + "bSortable": ServerSideCheckoutsTables ? false : true + } + ] + }, relatives_columns_settings); } }); @@ -605,4 +610,6 @@ $(document).ready(function() { } } ).attr( 'checked', false ); } - }); +}); + +})(jQuery); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -40,6 +40,12 @@ Circulation: desc: latest to earliest - due date. - + - pref: ServerSideCheckoutsTables + choices: + yes: Enable + no: Do not enable + - server-side processing on checkouts tables. It can improve performance when there is a big number of checkouts to display. + - - pref: SpecifyDueDate choices: yes: Allow --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -26,31 +26,21 @@ [% INCLUDE 'timepicker.inc' %] - +[% INCLUDE 'checkouts.js.inc' %] - +[% INCLUDE 'checkouts.js.inc' %]