From e8df3a1b13fb47cee7c686d515a31d08d8d8ad2a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 13 Feb 2014 08:28:49 -0500 Subject: [PATCH] Bug 11703 - Use the ajax datatables on patron details page --- koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 123 ++++++++ .../intranet-tmpl/prog/en/js/pages/circulation.js | 129 -------- .../prog/en/modules/circ/circulation.tt | 84 ++---- .../prog/en/modules/members/moremember.tt | 319 ++++++-------------- members/moremember.pl | 129 +------- 5 files changed, 261 insertions(+), 523 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index 234282d..4cc8e32 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -1,4 +1,127 @@ $(document).ready(function() { + // Handle the select all/none links for checkouts table columns + $("#CheckAllRenewals").on("click",function(){ + $("#UncheckAllCheckins").click(); + $(".renew:visible").attr("checked", "checked" ); + return false; + }); + $("#UncheckAllRenewals").on("click",function(){ + $(".renew:visible").removeAttr("checked"); + return false; + }); + + $("#CheckAllCheckins").on("click",function(){ + $("#UncheckAllRenewals").click(); + $(".checkin:visible").attr("checked", "checked" ); + return false; + }); + $("#UncheckAllCheckins").on("click",function(){ + $(".checkin:visible").removeAttr("checked"); + return false; + }); + + // Don't allow both return and renew checkboxes to be checked + $(document).on("change", '.renew', function(){ + if ( $(this).is(":checked") ) { + $( "#checkin_" + $(this).val() ).removeAttr("checked"); + } + }); + $(document).on("change", '.checkin', function(){ + if ( $(this).is(":checked") ) { + $( "#renew_" + $(this).val() ).removeAttr("checked"); + } + }); + + // Clicking the table cell checks the checkbox inside it + $(document).on("click", 'td', function(e){ + if(e.target.tagName.toLowerCase() == 'td'){ + $(this).find("input:checkbox:visible").each( function() { + $(this).click(); + }); + } + }); + + // Handle renewals + $("#RenewCheckinChecked").on("click",function(){ + $(".checkin:checked:visible").each(function() { + itemnumber = $(this).val(); + + $(this).replaceWith(""); + + params = { + itemnumber: itemnumber, + borrowernumber: borrowernumber, + branchcode: branchcode, + exempt_fine: $("#exemptfine").is(':checked') + }; + + $.post( "/cgi-bin/koha/api/checkin.pl", params, function( data ) { + id = "#checkin_" + data.itemnumber; + + content = ""; + if ( data.returned ) { + content = _("Returned"); + } else { + content = _("Unable to return"); + } + + $(id).replaceWith( content ); + }, "json") + }); + + $(".renew:checked:visible").each(function() { + var override_limit = $("#override_limit").is(':checked') ? 1 : 0; + + var itemnumber = $(this).val(); + + $(this).replaceWith(""); + + var params = { + itemnumber: itemnumber, + borrowernumber: borrowernumber, + branchcode: branchcode, + override_limit: override_limit, + date_due: $("#newduedate").val() + }; + + $.post( "/cgi-bin/koha/api/renew.pl", params, function( data ) { + var id = "#renew_" + data.itemnumber; + + var content = ""; + if ( data.renew_okay ) { + content = _("Renewed, due: ") + data.date_due; + } else { + content = _("Renew failed: "); + if ( data.error == "no_checkout" ) { + content += _("not checked out"); + } else if ( data.error == "too_many" ) { + content += _("too many renewals"); + } else if ( data.error == "on_reserve" ) { + content += _("on reserve"); + } else if ( data.error ) { + content += data.error; + } else { + content += _("reason unknown"); + } + } + + $(id).replaceWith( content ); + }, "json") + }); + + // Prevent form submit + return false; + }); + + $("#RenewAll").on("click",function(){ + $("#CheckAllRenewals").click(); + $("#UncheckAllCheckins").click(); + $("#RenewCheckinChecked").click(); + + // Prevent form submit + return false; + }); + var ymd = $.datepicker.formatDate('yy-mm-dd', new Date()); $("#issues-table").dataTable({ diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js index 49dc9ae..489403f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js @@ -1,25 +1,4 @@ $(document).ready(function() { - // Handle the select all/none links for checkouts table columns - $("#CheckAllRenewals").on("click",function(){ - $("#UncheckAllCheckins").click(); - $(".renew:visible").attr("checked", "checked" ); - return false; - }); - $("#UncheckAllRenewals").on("click",function(){ - $(".renew:visible").removeAttr("checked"); - return false; - }); - - $("#CheckAllCheckins").on("click",function(){ - $("#UncheckAllRenewals").click(); - $(".checkin:visible").attr("checked", "checked" ); - return false; - }); - $("#UncheckAllCheckins").on("click",function(){ - $(".checkin:visible").removeAttr("checked"); - return false; - }); - $("#CheckAllExports").on("click",function(){ $(".export:visible").attr("checked", "checked" ); return false; @@ -29,99 +8,6 @@ $(document).ready(function() { return false; }); - // Don't allow both return and renew checkboxes to be checked - $(document).on("change", '.renew', function(){ - if ( $(this).is(":checked") ) { - $( "#checkin_" + $(this).val() ).removeAttr("checked"); - } - }); - $(document).on("change", '.checkin', function(){ - if ( $(this).is(":checked") ) { - $( "#renew_" + $(this).val() ).removeAttr("checked"); - } - }); - - // Handle renewals - $("#RenewCheckinChecked").on("click",function(){ - $(".checkin:checked:visible").each(function() { - itemnumber = $(this).val(); - - $(this).replaceWith(""); - - params = { - itemnumber: itemnumber, - borrowernumber: borrowernumber, - branchcode: branchcode, - exempt_fine: $("#exemptfine").is(':checked') - }; - - $.post( "/cgi-bin/koha/api/checkin.pl", params, function( data ) { - id = "#checkin_" + data.itemnumber; - - content = ""; - if ( data.returned ) { - content = _("Returned"); - } else { - content = _("Unable to return"); - } - - $(id).replaceWith( content ); - }, "json") - }); - - $(".renew:checked:visible").each(function() { - var override_limit = $("#override_limit").is(':checked') ? 1 : 0; - - var itemnumber = $(this).val(); - - $(this).replaceWith(""); - - var params = { - itemnumber: itemnumber, - borrowernumber: borrowernumber, - branchcode: branchcode, - override_limit: override_limit, - date_due: $("#newduedate").val() - }; - - $.post( "/cgi-bin/koha/api/renew.pl", params, function( data ) { - var id = "#renew_" + data.itemnumber; - - var content = ""; - if ( data.renew_okay ) { - content = _("Renewed, due: ") + data.date_due; - } else { - content = _("Renew failed: "); - if ( data.error == "no_checkout" ) { - content += _("not checked out"); - } else if ( data.error == "too_many" ) { - content += _("too many renewals"); - } else if ( data.error == "on_reserve" ) { - content += _("on reserve"); - } else if ( data.error ) { - content += data.error; - } else { - content += _("reason unknown"); - } - } - - $(id).replaceWith( content ); - }, "json") - }); - - // Prevent form submit - return false; - }); - - $("#RenewAll").on("click",function(){ - $("#CheckAllRenewals").click(); - $("#UncheckAllCheckins").click(); - $("#RenewCheckinChecked").click(); - - // Prevent form submit - return false; - }); - $('#patronlists').tabs(); $("#messages ul").after(""+MSG_ADD_MESSAGE+""); @@ -156,14 +42,6 @@ $(document).ready(function() { return false; }); - // Clicking the table cell checks the checkbox inside it - $(document).on("click", 'td', function(e){ - if(e.target.tagName.toLowerCase() == 'td'){ - $(this).find("input:checkbox:visible").each( function() { - $(this).click(); - }); - } - }); }); function export_checkouts(format) { @@ -200,10 +78,3 @@ function validate1(date) { return false; } } - -// prevent adjacent checkboxes from being checked simultaneously -function radioCheckBox(box){ - box.parents("td").siblings().find("input:checkbox.radio").each(function(){ - $(this).removeAttr("checked"); - }); - } 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 d148cfb..aa9feab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -668,8 +668,7 @@ No patron matched [% message %]
-[% IF ( issuecount ) %] -
+ [% IF ( issuecount ) %] @@ -689,64 +688,39 @@ No patron matched [% message %] [% INCLUDE 'checkouts-table-footer.inc' %]
- [% IF ( issuecount ) %] -
- [% IF ( CAN_user_circulate_override_renewals ) %] - [% IF ( AllowRenewalLimitOverride ) %] - - - [% END %] +
+ [% IF ( CAN_user_circulate_override_renewals ) %] + [% IF ( AllowRenewalLimitOverride ) %] + + [% END %] - - -
- - [% IF ( exports_enabled ) %] -
- - - - - - - - - -
[% END %] - [% END %] - -[% ELSE %] -

Patron has nothing checked out.

-[% END %] - + + +
+ [% ELSE %] +

Patron has nothing checked out.

+ [% END %]
- [% IF ( relatives_issues_count ) %] -
- - - - - - - - - - - - - - -
Due dateTitleItem typeChecked out onChecked out fromCall noChargePricePatron
-
+
+ + + + + + + + + + + + + + +
Due dateTitleItem typeChecked out onChecked out fromCall noChargePricePatron
+
[% END %] [% INCLUDE borrower_debarments.inc %] 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 79d319e..2d81c13 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -15,8 +15,21 @@ +