[Koha-patches] [PATCH] [SIGNED-OFF] Bug 5618: Multiple renewals in the opac

Ian Walls ian.walls at bywatersolutions.com
Thu Jan 20 18:16:43 CET 2011


From: Chris Cormack <chrisc at catalyst.net.nz>

Enables logged-in OPAC patrons to renew multiple items at once using checkboxes.

Errors are now handled better (for example, when item is on reserve)

Sponsored by Los Gatos Public Library

Squashed commit of the following:

commit 020d9904ddb22af238c8a90c1f7447ead5a6d0e7
Author: Chris Cormack <chrisc at catalyst.net.nz>
Date:   Thu Jan 20 08:57:01 2011 +1300

    Bug 5618: typo fix

commit 147cfd91dbe88fd58c5d404db9bf06a21310e2ef
Author: Chris Cormack <chrisc at catalyst.net.nz>
Date:   Thu Jan 20 08:47:39 2011 +1300

    Bug 5618: Adding better error handling for reserves, and always redirecting instead of exploding

commit 2dfb6c687d0d38c240e22d41f2aef6e3a9e53f02
Author: Chris Cormack <chrisc at koha.(none)>
Date:   Fri Jan 14 15:39:20 2011 +1300

    Bug 5618: Is mostly working now, needs some prettying up

commit f8d260a4dcde144c9ed487521a79ee687ff8feb3
Author: Chris Cormack <chrisc at catalyst.net.nz>
Date:   Fri Jan 14 15:03:45 2011 +1300

    bug 5618: Initial commit to set up checkboxes for choosing multiple items

Signed-off-by: Ian Walls <ian.walls at bywatersolutions.com>
---
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl |   11 ++++++-
 opac/opac-renew.pl                                 |   30 ++++++++++++++++----
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
index 001d947..6801350 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
@@ -192,6 +192,9 @@ $.tablesorter.addParser({
     <!-- /TMPL_IF -->
 
     <div id="opac-user-checkouts"><!-- TMPL_IF NAME="issues_count" -->
+        <form action="/cgi-bin/koha/opac-renew.pl" method="post">
+	<input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->">
+	<input type="hidden" name="from" value="opac_user" />
         <table id="checkoutst">
         <caption><!-- TMPL_VAR NAME="issues_count" --> Items Checked Out</caption>
        <thead><tr>
@@ -246,7 +249,7 @@ $.tablesorter.addParser({
                 <!-- /TMPL_IF -->
                 <!-- TMPL_IF name="OpacRenewalAllowed" -->
                     <!-- TMPL_UNLESS name="patron_flagged" -->
-                    <td><!-- TMPL_IF NAME="status" --><a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=<!-- TMPL_VAR NAME="itemnumber" -->&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Renew</a> <span class="renewals">(<!-- TMPL_VAR NAME="renewsleft" --> of <!-- TMPL_VAR NAME="renewsallowed" --> renewals remaining)</span>
+                    <td><!-- TMPL_IF NAME="status" --><input type="checkbox" name="item" value="<!-- TMPL_VAR NAME="itemnumber"-->"/><a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=<!-- TMPL_VAR NAME="itemnumber" -->&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Renew</a> <span class="renewals">(<!-- TMPL_VAR NAME="renewsleft" --> of <!-- TMPL_VAR NAME="renewsallowed" --> renewals remaining)</span>
                         <!-- TMPL_ELSE -->
                         Not renewable<!-- TMPL_IF NAME="too_many" --> <span class="renewals">(<!-- TMPL_VAR NAME="renewsleft" --> of <!-- TMPL_VAR NAME="renewsallowed" --> renewals remaining)</span><!-- TMPL_ELSE --><!-- TMPL_IF NAME="on_reserve" --> <span class="renewals">(On hold)</span><!-- /TMPL_IF --><!-- /TMPL_IF --> 
                         <!-- /TMPL_IF --></td>
@@ -258,7 +261,13 @@ $.tablesorter.addParser({
             </tr>
         <!-- /TMPL_LOOP --></tbody>
         </table>
+	
 		<!-- TMPL_IF name="OpacRenewalAllowed" -->
+		<input type="submit" value="Renew Selected" />
+		<!-- /TMPL_IF -->
+		</form>
+		<!-- TMPL_IF name="OpacRenewalAllowed" -->
+		
 		<form action="/cgi-bin/koha/opac-renew.pl" method="post">
 			<input type="hidden" name="from" value="opac_user" />
 			<input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl
index 205f48a..a84be25 100755
--- a/opac/opac-renew.pl
+++ b/opac/opac-renew.pl
@@ -2,7 +2,24 @@
 
 #written 18/1/2000 by chris at katipo.co.nz
 # adapted for use in the hlt opac by finlay at katipo.co.nz 29/11/2002
-#script to renew items from the web
+# script to renew items from the web
+# Parts Copyright 2010 Catalyst IT
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 
 use strict;
 use warnings;
@@ -27,15 +44,16 @@ my @items          = $query->param('item');
 $borrowernumber = $query->param('borrowernumber') || $query->param('bornum');
 my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
 
+my $errorstring='';
 for my $itemnumber ( @items ) {
     my ($status,$error) = CanBookBeRenewed( $borrowernumber, $itemnumber );
     if ( $status == 1 && $opacrenew == 1 ) {
         AddRenewal( $borrowernumber, $itemnumber );
     }
+    else {
+	$errorstring .= $error ."|";
+    }
 }
-# FIXME: else return ERROR to user!!
 
-if ( $query->param('from') eq 'opac_user' ) {
-    print $query->redirect("/cgi-bin/koha/opac-user.pl");
-} 
-# FIXME: ELSE WHAT?  No response at all.  Not very robust.
+print $query->redirect("/cgi-bin/koha/opac-user.pl?renew_error=$errorstring");
+
-- 
1.5.6.5



More information about the Koha-patches mailing list