[Koha-patches] [PATCH] [SIGNED-OFF] Fix for Bug 6534 - Duplicate opac renew buttons at the top of the checkouts list

alex.arnaud at biblibre.com alex.arnaud at biblibre.com
Fri Jul 8 10:40:41 CEST 2011


From: Owen Leonard <oleonard at myacpl.org>

This patch uses JS to add two links to the top of the checkouts
table: renew selected and renew all. Clicking each one submits
the respective form.

Also added is a small validation routine to warn the user if
they try to "renew selected" without having checked any boxes.

Signed-off-by: Alex Arnaud <alex.arnaud at biblibre.com>
---
 koha-tmpl/opac-tmpl/prog/en/css/opac.css         |   21 ++++++++++++++
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt |   33 ++++++++++++++++++----
 koha-tmpl/opac-tmpl/prog/images/check.png        |  Bin 0 -> 210 bytes
 koha-tmpl/opac-tmpl/prog/images/checks.png       |  Bin 0 -> 223 bytes
 opac/opac-user.pl                                |    8 ++++-
 5 files changed, 54 insertions(+), 8 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/prog/images/check.png
 create mode 100644 koha-tmpl/opac-tmpl/prog/images/checks.png

diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
index b8a531f..335e091 100644
--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css
+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
@@ -2018,3 +2018,24 @@ div.ft {
 #opac-isbddetail #isbdcontents { margin-top: 2em; }
 
 div.bibmessage { background-color : #ffffb0; border-radius : 5px; padding : 3px; margin : 2px; }
+
+#renewcontrols {
+	 float: right;
+	 font-size: 66%;
+}
+
+#renewcontrols a {
+	background-position : 3px center;
+	background-repeat : no-repeat;
+	text-decoration:none;
+	padding : .1em .4em;
+	padding-left : 18px;
+}
+
+#renewselected_link {
+	background-image : url(../../images/check.png);
+}
+
+#renewall_link {
+	background-image : url(../../images/checks.png);
+}
\ No newline at end of file
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
index 58c6fa5..d98d4a2 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
@@ -5,7 +5,7 @@
 [% END %]
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/JavaScript" language="JavaScript">
+<script type="text/JavaScript">
 //<![CDATA[
 var MSG_CONFIRM_DELETE_HOLD = _("Are you sure you want to cancel this hold?");
 $.tablesorter.addParser({
@@ -64,6 +64,25 @@ $.tablesorter.addParser({
 				[% END %]
 			});
 [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
+        [% IF ( OpacRenewalAllowed ) %][% IF ( canrenew ) %]$("#renewselected").submit(function(){
+            valid = false;
+            $("input[type=checkbox]").each(function(){
+                if($(this).is(':checked')){
+                    valid = true;
+                }
+            });
+            if(!valid){
+                alert(_("Nothing has been selected. Check the box for each item you want to renew"));
+            }
+            return valid;
+        });
+        $("#renewselected_link").live('click',function(){
+            $("#renewselected").submit();
+        });
+        $("#renewall_link").live('click',function(){
+            $("#renewall").submit();
+        });
+        $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" href=\"#\">"+_("Renew selected")+"</a> <a id=\"renewall_link\" href=\"#\">"+_("Renew all")+"</a></div>");[% END %][% END %]
             });
 //]]>
 </script>
@@ -192,7 +211,7 @@ $.tablesorter.addParser({
     [% END %]
 
     <div id="opac-user-checkouts">[% IF ( issues_count ) %]
-        <form action="/cgi-bin/koha/opac-renew.pl" method="post">
+        <form id="renewselected" action="/cgi-bin/koha/opac-renew.pl" method="post">
 	<input type="hidden" name="borrowernumber" value="[% borrowernumber %]">
 	<input type="hidden" name="from" value="opac_user" />
         <table id="checkoutst">
@@ -254,7 +273,7 @@ $.tablesorter.addParser({
                 [% END %]
                 [% IF ( OpacRenewalAllowed ) %]
                     [% UNLESS ( ISSUE.patron_flagged ) %]
-                    <td>[% IF ( ISSUE.status ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/><a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a> <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
+                    <td>[% IF ( ISSUE.status ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=[% ISSUE.itemnumber %]&amp;borrowernumber=[% ISSUE.borrowernumber %]">Renew</a> <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
                         [% ELSE %]
                         Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %] 
                         [% END %]</td>
@@ -269,14 +288,15 @@ $.tablesorter.addParser({
             </tr>
         [% END %]</tbody>
         </table>
-	
+	   [% IF ( canrenew ) %]
 		[% IF ( OpacRenewalAllowed ) %]
 		<input type="submit" value="Renew Selected" />
 		[% END %]
+        [% END %]
 		</form>
 		[% IF ( OpacRenewalAllowed ) %]
-		
-		<form action="/cgi-bin/koha/opac-renew.pl" method="post">
+        [% IF ( canrenew ) %]
+		<form id="renewall" action="/cgi-bin/koha/opac-renew.pl" method="post">
 			<input type="hidden" name="from" value="opac_user" />
 			<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
 			[% FOREACH ISSUE IN ISSUES %]
@@ -285,6 +305,7 @@ $.tablesorter.addParser({
 			[% UNLESS ( patron_flagged ) %]<input type="submit" value="Renew All" />[% END %]
 		</form>
 		[% END %]
+        [% END %]
     [% ELSE %]
         <table>
             <tr><td>You have nothing checked out</td></tr>
diff --git a/koha-tmpl/opac-tmpl/prog/images/check.png b/koha-tmpl/opac-tmpl/prog/images/check.png
new file mode 100644
index 0000000000000000000000000000000000000000..249805717f1de5b22c8c1f6a7e2ea415da552ea2
GIT binary patch
literal 210
zcmeAS at N?(olHy`uVBq!ia0vp^oFL4>3?#4ne^UZdEa{HEjtmUzPnffIy#(?lOI#yL
zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=?1^9%xns;yg|Nno0&Gg4W5vGzL
zzu^B2Pq!O*0eLQ-E{-7;w~`WC7#kRp8ZI+1vZNXs7%;I2Fe@|9ICy|Vz=0=0Prw)`
yFoVfZf|03%QHhm>f$<2#b$*~!!Dj|09tLg}2HUjyoo9gNF?hQAxvX<aXaWGSqBrjV

literal 0
HcmV?d00001

diff --git a/koha-tmpl/opac-tmpl/prog/images/checks.png b/koha-tmpl/opac-tmpl/prog/images/checks.png
new file mode 100644
index 0000000000000000000000000000000000000000..75e8f45ef52853cdac4a4beae3e73805efdefe19
GIT binary patch
literal 223
zcmeAS at N?(olHy`uVBq!ia0vp at K+Mg-3?wJ#d=CavEa{HEjtmUzPnffIy#(?lOI#yL
zg7ec#$`gxH85~pclTsBta}(23gHjVyDhp4h+5i=?1^9%xns;yg|Nno0&Gg4W5vGzL
zzu^B2Pq!O*0eOL*E{-7;w~`WE*ccd(G`JWUF|i2DNNf1Wz|_I0!S}3zm4S)lNLqt8
zGm8MThln1pfI~oSKxP9&lEXzHyWsMHOCWtoh7Jsd3wE$79AHp7$WW9WVOa+>oWax8
K&t;ucLK6U at T|m_U

literal 0
HcmV?d00001

diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index a2f7d9b..3f0d6c4 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -112,6 +112,7 @@ my @overdues;
 my @issuedat;
 my $itemtypes = GetItemTypes();
 my ($issues) = GetPendingIssues($borrowernumber);
+my $canrenew = 0;
 if ($issues){
 	foreach my $issue ( sort { $b->{'date_due'} cmp $a->{'date_due'} } @$issues ) {
 		# check for reserves
@@ -140,7 +141,10 @@ if ($issues){
 		# check if item is renewable
 		my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
 		($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
-		$issue->{'status'} = $status && C4::Context->preference("OpacRenewalAllowed");
+        if($status && C4::Context->preference("OpacRenewalAllowed")){
+            $issue->{'status'} = $status;
+            $canrenew = 1;
+        }
 		$issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many';
 		$issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve';
 
@@ -179,7 +183,7 @@ if ($issues){
 }
 $template->param( ISSUES       => \@issuedat );
 $template->param( issues_count => $count );
-
+$template->param( canrenew     => $canrenew );
 $template->param( OVERDUES       => \@overdues );
 $template->param( overdues_count => $overdues_count );
 
-- 
1.7.0.4



More information about the Koha-patches mailing list