Bugzilla – Attachment 45018 Details for
Bug 15219
Server-side processing and pagination on checkouts tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15219: Load checkouts table incrementally
Bug-15219-Load-checkouts-table-incrementally.patch (text/plain), 43.62 KB, created by
Julian Maurice
on 2015-11-19 15:11:22 UTC
(
hide
)
Description:
Bug 15219: Load checkouts table incrementally
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2015-11-19 15:11:22 UTC
Size:
43.62 KB
patch
obsolete
>From a186d7746c0d1df6674560b4f7278fc6d63c151d Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 18 Nov 2015 15:52:14 +0100 >Subject: [PATCH] Bug 15219: Load checkouts table incrementally > >Some libraries have patrons with more than 1000 checkouts. Loading all >of them at once can be very long, and sometimes can cause timeout >errors. >This patch prevent that by loading checkouts in the table by batches of >100. >This affects patron's checkouts and patron's relatives' checkouts tables >on pages circ/circulation.pl and members/moremember.pl. > >Additionally, this patch: >- adds a switch to turn off and on row grouping (today's checkouts vs > previous checkouts) (on by default) >- adds a global filter text input on all tables >- adds "column settings" for relatives' checkouts tables >- factorize some code that was duplicated across the two DataTables > configurations (mDataProp) >--- > admin/columns_settings.yml | 61 ++ > .../prog/en/includes/checkouts-table-footer.inc | 2 +- > .../prog/en/includes/checkouts-table.inc | 1 + > .../prog/en/includes/datatables-strings.inc | 1 + > .../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 | 662 ++++++++++----------- > koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 1 + > .../prog/en/modules/circ/circulation.tt | 1 + > .../prog/en/modules/members/moremember.tt | 1 + > svc/checkouts | 66 +- > 11 files changed, 423 insertions(+), 394 deletions(-) > >diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml >index 3849245..baa53e0 100644 >--- a/admin/columns_settings.yml >+++ b/admin/columns_settings.yml >@@ -231,6 +231,34 @@ modules: > columnname: export > cannot_be_toggled: 1 > cannot_be_modified: 1 >+ relatives-issues-table: >+ - >+ columnname: due_date_unformatted >+ cannot_be_toggled: 1 >+ cannot_be_modified: 1 >+ is_hidden: 1 >+ - >+ 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: >@@ -273,6 +301,11 @@ modules: > cannot_be_modified: 1 > is_hidden: 1 > - >+ columnname: group_order >+ cannot_be_toggled: 1 >+ cannot_be_modified: 1 >+ is_hidden: 1 >+ - > columnname: todays_or_previous_checkouts > cannot_be_toggled: 1 > cannot_be_modified: 1 >@@ -314,3 +347,31 @@ modules: > columnname: export > cannot_be_toggled: 1 > cannot_be_modified: 1 >+ relatives-issues-table: >+ - >+ columnname: due_date_unformatted >+ cannot_be_toggled: 1 >+ cannot_be_modified: 1 >+ is_hidden: 1 >+ - >+ 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 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc >index 0de211f..d15c0cb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc >@@ -1,6 +1,6 @@ > <tfoot> > <tr> >- <td colspan="10" style="text-align: right; font-weight:bold;">Totals:</td> >+ <td colspan="11" style="text-align: right; font-weight:bold;">Totals:</td> > <td id="totaldue">[% totaldue %]</td> > <td id="totalfine">[% finetotal %]</td> > <td id="totalprice">[% totalprice %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >index 0c1a7f1..ce2f0e9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc >@@ -11,6 +11,7 @@ > <tr> > <th scope="col"> </th> > <th scope="col"> </th> >+ <th scope="col"> </th> > <th scope="col">Due date</th> > <th scope="col">Due date</th> > <th scope="col">Title</th> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables-strings.inc >index ead071b..fa156d6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables-strings.inc >@@ -6,6 +6,7 @@ > var MSG_DT_PREVIOUS = _("Previous"); > var MSG_DT_EMPTY_TABLE = _("No data available in table"); > var MSG_DT_INFO = _("Showing _START_ to _END_ of _TOTAL_"); >+ var MSG_DT_INFO_SIMPLE = _("Entries shown: _TOTAL_"); > var MSG_DT_INFO_EMPTY = _("No entries to show"); > var MSG_DT_INFO_FILTERED = _("(filtered from _MAX_ total entries)"); > var MSG_DT_LENGTH_MENU = _("Show _MENU_ entries"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >index 4381b01..8760f54 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >@@ -1,22 +1,4 @@ > [% INCLUDE 'format_price.inc' %] > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >-<script type="text/javascript"> >-//<![CDATA[ >- var MSG_DT_FIRST = _("First"); >- var MSG_DT_LAST = _("Last"); >- var MSG_DT_NEXT = _("Next"); >- var MSG_DT_PREVIOUS = _("Previous"); >- var MSG_DT_EMPTY_TABLE = _("No data available in table"); >- var MSG_DT_INFO = _("Showing _START_ to _END_ of _TOTAL_"); >- var MSG_DT_INFO_EMPTY = _("No entries to show"); >- var MSG_DT_INFO_FILTERED = _("(filtered from _MAX_ total entries)"); >- var MSG_DT_LENGTH_MENU = _("Show _MENU_ entries"); >- var MSG_DT_LOADING_RECORDS = _("Loading..."); >- var MSG_DT_PROCESSING = _("Processing..."); >- var MSG_DT_SEARCH = _("Search:"); >- var MSG_DT_ZERO_RECORDS = _("No matching records found"); >- var MSG_DT_ALL = _("All"); >- var CONFIG_EXCLUDE_ARTICLES_FROM_SORT = _("a an the"); >-//]]> >-</script> >+[% INCLUDE 'datatables-strings.inc' %] > <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >index 3226ad3..73a3f60 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >@@ -30,5 +30,6 @@ > var NO = _("No"); > var YES = _("Yes"); > var INHOUSE_USE = _("On-site checkout"); >+ var GROUP_TODAYS_CHECKOUTS = _("Group today's checkouts"); > //]]> > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js >index b4b676b..adc8d4a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js >@@ -1,3 +1,278 @@ >+(function($) { >+ >+var ymd = $.datepicker.formatDate('yy-mm-dd', new Date()); >+ >+function enableGrouping(datatable) { >+ datatable.rowGrouping({ >+ iGroupingColumnIndex: 2, >+ iGroupingOrderByColumnIndex: 1, >+ sGroupingColumnSortDirection: "asc" >+ }); >+} >+ >+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); >+ datatable.fnDraw(); >+ break; >+ } >+ } >+} >+ >+function loadTableData(datatable, borrowernumbers, offset, count) { >+ offset = offset ? offset : 0; >+ count = count ? count : 100; >+ >+ var args = { >+ "borrowernumber": borrowernumbers, >+ "offset": offset, >+ "count": count >+ }; >+ >+ $.ajax({ >+ dataType: "json", >+ traditional: true, >+ url: '/cgi-bin/koha/svc/checkouts', >+ data: args, >+ success: function(data) { >+ if (data.length) { >+ datatable.fnAddData(data); >+ } >+ >+ if (data.length < count) { >+ var oSettings = datatable.fnSettings(); >+ oSettings.bDataFullyLoaded = true; >+ >+ // We need to redraw to update the info text >+ datatable.fnDraw(); >+ } else { >+ loadTableData(datatable, borrowernumbers, offset + count, count); >+ } >+ } >+ }); >+} >+ >+function dtSimpleInfoCallback (oSettings, iStart, iEnd, iMax, iTotal, sPre) { >+ var sInfo; >+ var oLanguage = oSettings.oLanguage; >+ >+ if (iTotal > 0) { >+ sInfo = oLanguage.sInfoSimple.replace('_TOTAL_', iTotal); >+ } else { >+ sInfo = oLanguage.sInfoEmpty; >+ } >+ >+ if (iMax > iTotal) { >+ sInfo += ' ' + oLanguage.sInfoFiltered.replace('_MAX_', iMax); >+ } >+ >+ if (!oSettings.bDataFullyLoaded) { >+ sInfo += ' (' + oLanguage.sLoadingRecords + ')'; >+ } >+ >+ return sInfo; >+} >+ >+var mDataProps = { >+ groupOrder: function( oObj ) { >+ if ( oObj.issued_today ) { >+ return "0"; >+ } else { >+ return "1"; >+ } >+ }, >+ groupName: function( oObj ) { >+ if ( oObj.issued_today ) { >+ return "<strong>" + TODAYS_CHECKOUTS + "</strong>"; >+ } else { >+ return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>"; >+ } >+ }, >+ dateDueFormatted: function( oObj ) { >+ var due = oObj.date_due_formatted; >+ >+ if ( oObj.date_due_overdue ) { >+ due = "<span class='overdue'>" + due + "</span>"; >+ } >+ >+ if ( oObj.lost ) { >+ due += "<span class='lost'>" + oObj.lost + "</span>"; >+ } >+ >+ if ( oObj.damaged ) { >+ due += "<span class='dmg'>" + oObj.damaged + "</span>"; >+ } >+ >+ due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>"; >+ >+ return due; >+ }, >+ title: function ( oObj ) { >+ var title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" >+ + oObj.biblionumber >+ + "'>" >+ + oObj.title; >+ >+ $.each(oObj.subtitle, function( index, value ) { >+ title += " " + value.subfield; >+ }); >+ >+ title += "</a></span>"; >+ >+ 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 += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>" >+ } >+ >+ var onsite_checkout = ''; >+ if ( oObj.onsite_checkout == 1 ) { >+ onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; >+ } >+ >+ title += " " >+ + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" >+ + oObj.biblionumber >+ + "&itemnumber=" >+ + oObj.itemnumber >+ + "#" >+ + oObj.itemnumber >+ + "'>" >+ + oObj.barcode >+ + "</a>" >+ + onsite_checkout; >+ >+ return title; >+ }, >+ charge: function ( oObj ) { >+ if ( ! oObj.charge ) oObj.charge = 0; >+ return parseFloat(oObj.charge).toFixed(2); >+ }, >+ fine: function ( oObj ) { >+ if ( ! oObj.fine ) oObj.fine = 0; >+ return parseFloat(oObj.fine).toFixed(2); >+ }, >+ price: function ( oObj ) { >+ if ( ! oObj.price ) oObj.price = 0; >+ return parseFloat(oObj.price).toFixed(2); >+ }, >+ renew: function ( oObj ) { >+ var content = ""; >+ var span_style = ""; >+ var span_class = ""; >+ >+ content += "<span>"; >+ content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>"; >+ >+ if ( oObj.can_renew ) { >+ // Do nothing >+ } else if ( oObj.can_renew_error == "on_reserve" ) { >+ content += "<span class='renewals-disabled-no-override'>" >+ + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>" >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "too_many" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "restriction" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE_RESTRICTION >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "overdue" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE_OVERDUE >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "too_soon" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "auto_too_soon" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE_AUTO_TOO_SOON >+ + "</span>"; >+ >+ span_style = "display: none"; >+ span_class = "renewals-allowed"; >+ } else if ( oObj.can_renew_error == "auto_renew" ) { >+ content += "<span class='renewals-disabled'>" >+ + NOT_RENEWABLE_AUTO_RENEW >+ + "</span>"; >+ >+ 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 += "<span class='renewals-disabled'>" >+ + oObj.can_renew_error >+ + "</span>"; >+ >+ 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 += "<span class='" + span_class + "' style='" + span_style + "'>" >+ + "<input type='checkbox' "; >+ if ( oObj.date_due_overdue && can_renew ) { >+ content += "checked='checked' "; >+ } >+ content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>" >+ + "</span>"; >+ >+ content += "<span class='renewals'>(" >+ + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) >+ + ")</span>"; >+ } >+ >+ content += "</span>"; >+ >+ return content; >+ }, >+ checkin: function ( oObj ) { >+ if ( oObj.can_renew_error == "on_reserve" ) { >+ return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"; >+ } else { >+ return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; >+ } >+ }, >+ export: function ( oObj ) { >+ var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />"; >+ >+ s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />"; >+ return s; >+ }, >+ patron: function( oObj ) { >+ return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>" >+ + oObj.borrower.firstname + " " + oObj.borrower.surname + " (" + oObj.borrower.cardnumber + ")</a>" >+ } >+}; >+ > $(document).ready(function() { > $.ajaxSetup ({ cache: false }); > >@@ -139,8 +414,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,92 +447,19 @@ $(document).ready(function() { > "sProcessing": MSG_DT_LOADING_RECORDS, > }, > "bAutoWidth": false, >- "sDom": 'C<"clearfix">rt', >+ "bPaginate": false, >+ "sDom": 'C<"top pager"if>rt', > "aoColumns": [ >- { >- "mDataProp": function( oObj ) { >- return oObj.sort_order; >- } >- }, >- { >- "mDataProp": function( oObj ) { >- if ( oObj.issued_today ) { >- return "<strong>" + TODAYS_CHECKOUTS + "</strong>"; >- } else { >- return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>"; >- } >- } >- }, >- { >- "mDataProp": "date_due", >- "bVisible": false, >- }, >+ { "mDataProp": "sort_order" }, >+ { "mDataProp": mDataProps.groupOrder }, >+ { "mDataProp": mDataProps.groupName }, >+ { "mDataProp": "date_due" }, > { > "iDataSort": 2, // Sort on hidden unformatted date due column >- "mDataProp": function( oObj ) { >- var due = oObj.date_due_formatted; >- >- if ( oObj.date_due_overdue ) { >- due = "<span class='overdue'>" + due + "</span>"; >- } >- >- if ( oObj.lost ) { >- due += "<span class='lost'>" + oObj.lost + "</span>"; >- } >- >- if ( oObj.damaged ) { >- due += "<span class='dmg'>" + oObj.damaged + "</span>"; >- } >- >- due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>"; >- >- return due; >- } >+ "mDataProp": mDataProps.dateDueFormatted > }, > { >- "mDataProp": function ( oObj ) { >- title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" >- + oObj.biblionumber >- + "'>" >- + oObj.title; >- >- $.each(oObj.subtitle, function( index, value ) { >- title += " " + value.subfield; >- }); >- >- title += "</a></span>"; >- >- 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 += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>" >- } >- >- var onsite_checkout = ''; >- if ( oObj.onsite_checkout == 1 ) { >- onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; >- } >- >- title += " " >- + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" >- + oObj.biblionumber >- + "&itemnumber=" >- + oObj.itemnumber >- + "#" >- + oObj.itemnumber >- + "'>" >- + oObj.barcode >- + "</a>" >- + onsite_checkout; >- >- return title; >- }, >+ "mDataProp": mDataProps.title, > "sType": "anti-the" > }, > { "mDataProp": "itemtype_description" }, >@@ -267,136 +467,21 @@ $(document).ready(function() { > { "mDataProp": "issuedate_formatted" }, > { "mDataProp": "branchname" }, > { "mDataProp": "itemcallnumber" }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.charge ) oObj.charge = 0; >- return parseFloat(oObj.charge).toFixed(2); >- } >- }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.fine ) oObj.fine = 0; >- return parseFloat(oObj.fine).toFixed(2); >- } >- }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.price ) oObj.price = 0; >- return parseFloat(oObj.price).toFixed(2); >- } >- }, >+ { "mDataProp": mDataProps.charge }, >+ { "mDataProp": mDataProps.fine }, >+ { "mDataProp": mDataProps.price }, > { > "bSortable": false, >- "mDataProp": function ( oObj ) { >- var content = ""; >- var span_style = ""; >- var span_class = ""; >- >- content += "<span>"; >- content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>"; >- >- if ( oObj.can_renew ) { >- // Do nothing >- } else if ( oObj.can_renew_error == "on_reserve" ) { >- content += "<span class='renewals-disabled-no-override'>" >- + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>" >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "too_many" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "restriction" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_RESTRICTION >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "overdue" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_OVERDUE >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "too_soon" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "auto_too_soon" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_TOO_SOON >- + "</span>"; >- >- span_style = "display: none"; >- span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "auto_renew" ) { >- content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_AUTO_RENEW >- + "</span>"; >- >- 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 += "<span class='renewals-disabled'>" >- + oObj.can_renew_error >- + "</span>"; >- >- 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 += "<span class='" + span_class + "' style='" + span_style + "'>" >- + "<input type='checkbox' "; >- if ( oObj.date_due_overdue && can_renew ) { >- content += "checked='checked' "; >- } >- content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>" >- + "</span>"; >- >- content += "<span class='renewals'>(" >- + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) >- + ")</span>"; >- } >- >- content += "</span>"; >- >- return content; >- } >+ "mDataProp": mDataProps.renew > }, > { > "bSortable": false, >- "mDataProp": function ( oObj ) { >- if ( oObj.can_renew_error == "on_reserve" ) { >- return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"; >- } else { >- return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; >- } >- } >+ "mDataProp": mDataProps.checkin > }, > { > "bVisible": exports_enabled ? true : false, > "bSortable": false, >- "mDataProp": function ( oObj ) { >- var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />"; >- >- s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />"; >- return s; >- } >+ "mDataProp": mDataProps.checkin > } > ], > "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { >@@ -412,38 +497,32 @@ $(document).ready(function() { > $("#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; >- } >- } >+ "fnInfoCallback": dtSimpleInfoCallback >+ }, columns_settings); >+ >+ enableGrouping(issuesTable); >+ >+ var groupingSwitch = $('<input type="checkbox">') >+ .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); >+ } >+ }); >+ $('<div></div>') >+ .css('float', 'left') >+ .css('padding', '0.3em 0.5em') >+ .css('line-height', '1.9em') >+ .append(groupingSwitch) >+ .append(' ') >+ .append('<label for="issues-table-row-grouping-switch">' + GROUP_TODAYS_CHECKOUTS + '</label>') >+ .appendTo('#issues-table_wrapper .top.pager'); > >- oSettings.aaSortingFixed = null; >- }, >- }, columns_settings).rowGrouping( >- { >- iGroupingColumnIndex: 1, >- iGroupingOrderByColumnIndex: 0, >- sGroupingColumnSortDirection: "asc" >- } >- ); >+ loadTableData(issuesTable, borrowernumber); > > if ( $("#issues-table").length ) { > $("#issues-table_processing").position({ >@@ -457,71 +536,19 @@ $(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", >+ "sDom": 'C<"top pager"if>rt', > "aaSorting": [], >+ "bPaginate": false, > "aoColumns": [ >- { >- "mDataProp": "date_due", >- "bVisible": false, >- }, >+ { "mDataProp": "date_due" }, > { > "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 "<span class='overdue'>" + oObj.date_due_formatted + "</span>"; >- } else { >- return oObj.date_due_formatted; >- } >- } >+ "mDataProp": mDataProps.dateDueFormatted > }, > { >- "mDataProp": function ( oObj ) { >- title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" >- + oObj.biblionumber >- + "'>" >- + oObj.title; >- >- $.each(oObj.subtitle, function( index, value ) { >- title += " " + value.subfield; >- }); >- >- title += "</a></span>"; >- >- 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 += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>" >- } >- >- var onsite_checkout = ''; >- if ( oObj.onsite_checkout == 1 ) { >- onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; >- } >- >- title += " " >- + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" >- + oObj.biblionumber >- + "&itemnumber=" >- + oObj.itemnumber >- + "#" >- + oObj.itemnumber >- + "'>" >- + oObj.barcode >- + "</a>" >- + onsite_checkout; >- >- return title; >- }, >+ "mDataProp": mDataProps.title, > "sType": "anti-the" > }, > { "mDataProp": "itemtype" }, >@@ -529,45 +556,14 @@ $(document).ready(function() { > { "mDataProp": "issuedate_formatted" }, > { "mDataProp": "branchname" }, > { "mDataProp": "itemcallnumber" }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.charge ) oObj.charge = 0; >- return parseFloat(oObj.charge).toFixed(2); >- } >- }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.fine ) oObj.fine = 0; >- return parseFloat(oObj.fine).toFixed(2); >- } >- }, >- { >- "mDataProp": function ( oObj ) { >- if ( ! oObj.price ) oObj.price = 0; >- return parseFloat(oObj.price).toFixed(2); >- } >- }, >- { >- "mDataProp": function( oObj ) { >- return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>" >- + oObj.borrower.firstname + " " + oObj.borrower.surname + " (" + oObj.borrower.cardnumber + ")</a>" >- } >- }, >+ { "mDataProp": mDataProps.charge }, >+ { "mDataProp": mDataProps.fine }, >+ { "mDataProp": mDataProps.price }, >+ { "mDataProp": mDataProps.patron } > ], >- "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) >- } ); >- }, >- }); >+ "fnInfoCallback": dtSimpleInfoCallback >+ }, relatives_columns_settings); >+ loadTableData(relativesIssuesTable, relatives_borrowernumbers); > } > }); > >@@ -587,4 +583,6 @@ $(document).ready(function() { > } > } ).attr( 'checked', false ); > } >- }); >+}); >+ >+})(jQuery); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >index e42918c..8c93bc4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >@@ -15,6 +15,7 @@ var dataTablesDefaults = { > }, > "sEmptyTable" : window.MSG_DT_EMPTY_TABLE || "No data available in table", > "sInfo" : window.MSG_DT_INFO || "Showing _START_ to _END_ of _TOTAL_ entries", >+ "sInfoSimple" : window.MSG_DT_INFO_SIMPLE || "Entries shown: _TOTAL_", > "sInfoEmpty" : window.MSG_DT_INFO_EMPTY || "No entries to show", > "sInfoFiltered" : window.MSG_DT_INFO_FILTERED || "(filtered from _MAX_ total entries)", > "sLengthMenu" : window.MSG_DT_LENGTH_MENU || "Show _MENU_ entries", >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 19ba9fa..1c5ceba 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -48,6 +48,7 @@ var MSG_ADD_MESSAGE = _("Add a new message"); > var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > > columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'issues-table', 'json' ) %] >+relatives_columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'relatives-issues-table', 'json' ) %] > > [% IF ( borrowernumber ) %] > if($.cookie("holdfor") != [% borrowernumber %]){ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 97e547d..b34e666 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -44,6 +44,7 @@ var MSG_ADD_MESSAGE = _("Add a new message"); > var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); > > columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'issues-table', 'json' ) %] >+relatives_columns_settings = [% ColumnsSettings.GetColumns( 'members', 'moremember', 'relatives-issues-table', 'json' ) %] > > $(document).ready(function() { > $('#finesholdsissues').tabs({ >diff --git a/svc/checkouts b/svc/checkouts >index 6ecfd09..cf993ce 100755 >--- a/svc/checkouts >+++ b/svc/checkouts >@@ -42,22 +42,9 @@ if ( $auth_status ne "ok" ) { > exit 0; > } > >-my @sort_columns = qw/date_due title itype issuedate branchcode itemcallnumber/; >- > my @borrowernumber = $input->param('borrowernumber'); >-my $offset = $input->param('iDisplayStart'); >-my $results_per_page = $input->param('iDisplayLength') || -1; >- >-my $sorting_column = $input->param('iSortCol_0') || q{}; >-$sorting_column = ( $sorting_column && $sort_columns[$sorting_column] ) ? $sort_columns[$sorting_column] : 'issuedate'; >- >-my $sorting_direction = $input->param('sSortDir_0') || q{}; >-$sorting_direction = $sorting_direction eq 'asc' ? 'asc' : 'desc'; >- >-$results_per_page = undef if ( $results_per_page == -1 ); >- >-binmode STDOUT, ":encoding(UTF-8)"; >-print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+my $offset = $input->param('offset') || 0; >+my $count = $input->param('count') || 10; > > my @parameters; > my $sql = ' >@@ -112,7 +99,9 @@ else { > } > push( @parameters, @borrowernumber ); > >-$sql .= " ORDER BY $sorting_column $sorting_direction "; >+$sql .= " ORDER BY date_due DESC"; >+$sql .= " LIMIT ?,?"; >+push @parameters, $offset, $count; > > my $dbh = C4::Context->dbh(); > my $sth = $dbh->prepare($sql); >@@ -120,8 +109,7 @@ $sth->execute(@parameters); > > my $item_level_itypes = C4::Context->preference('item-level_itypes'); > >-my @checkouts_today; >-my @checkouts_previous; >+my @checkouts; > while ( my $c = $sth->fetchrow_hashref() ) { > my ($charge) = GetIssuingCharges( $c->{itemnumber}, $c->{borrowernumber} ); > my $fine = GetFine( $c->{itemnumber}, $c->{borrowernumber} ); >@@ -198,33 +186,27 @@ while ( my $c = $sth->fetchrow_hashref() ) { > issued_today => !$c->{not_issued_today}, > }; > >- if ( $c->{not_issued_today} ) { >- push( @checkouts_previous, $checkout ); >- } >- else { >- push( @checkouts_today, $checkout ); >- } >+ push @checkouts, $checkout; > } > >+my $todaysIssuesDefaultSortOrder = >+ C4::Context->preference('todaysIssuesDefaultSortOrder'); >+my $previousIssuesDefaultSortOrder = >+ C4::Context->preference('previousIssuesDefaultSortOrder'); > >-@checkouts_today = sort { $a->{timestamp} cmp $b->{timestamp} } @checkouts_today; >-@checkouts_today = reverse(@checkouts_today) >- unless ( C4::Context->preference('todaysIssuesDefaultSortOrder') eq 'desc' ); >- >-@checkouts_previous = sort { $a->{date_due} cmp $b->{date_due} } @checkouts_previous; >-@checkouts_previous = reverse(@checkouts_previous) >- if ( C4::Context->preference('previousIssuesDefaultSortOrder') eq 'desc' ); >- >-my @checkouts = ( @checkouts_today, @checkouts_previous ); >- >-my $i = 1; >-map { $_->{sort_order} = $i++ } @checkouts; >+my $i = $offset + 1; >+foreach my $c (@checkouts) { >+ my $sort_order = $i++; > >+ if ($c->{issued_today} && $todaysIssuesDefaultSortOrder eq 'asc') { >+ $sort_order = - $sort_order; >+ } elsif (!$c->{issued_today} && $previousIssuesDefaultSortOrder eq 'asc') { >+ $sort_order = - $sort_order; >+ } > >-my $data; >-$data->{'iTotalRecords'} = scalar @checkouts; >-$data->{'iTotalDisplayRecords'} = scalar @checkouts; >-$data->{'sEcho'} = $input->param('sEcho') || undef; >-$data->{'aaData'} = \@checkouts; >+ $c->{sort_order} = $sort_order; >+} > >-print to_json($data); >+binmode STDOUT, ":encoding(UTF-8)"; >+print $input->header( -type => 'application/json', -charset => 'UTF-8' ); >+print to_json(\@checkouts); >-- >1.9.1
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 15219
:
45018
|
45036
|
45054
|
48107
|
50075
|
60071
|
60642
|
61158
|
61159
|
61545
|
61546
|
72905
|
72906
|
74224
|
74225
|
75911
|
75912
|
75913
|
78555
|
78556
|
78557
|
78558
|
78559
|
79195
|
79196
|
79197
|
79198
|
79199
|
92776
|
92777
|
92778
|
92779
|
92780
|
92781
|
93921