Fix for Bug 6534 - Duplicate opac renew buttons at the top of the checkouts list
authorOwen Leonard <oleonard@myacpl.org>
Thu, 7 Jul 2011 16:46:58 +0000 (12:46 -0400)
committerChris Cormack <chrisc@catalyst.net.nz>
Sun, 7 Aug 2011 10:55:12 +0000 (22:55 +1200)
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@biblibre.com>
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
koha-tmpl/opac-tmpl/prog/en/css/opac.css
koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
koha-tmpl/opac-tmpl/prog/images/check.png [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/checks.png [new file with mode: 0644]
opac/opac-user.pl

index b8a531f..335e091 100644 (file)
@@ -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
index be67c8a..9d7a2a7 100644 (file)
@@ -6,7 +6,7 @@
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.metadata.min.js"></script>
 <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({
@@ -27,6 +27,25 @@ $.tablesorter.addParser({
             }); 
                        $("#overduest").tablesorter();
 [% 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>
@@ -155,7 +174,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">
@@ -217,7 +236,7 @@ $.tablesorter.addParser({
                 <td>[% ISSUE.itemcallnumber %]</td>
                 [% IF ( OpacRenewalAllowed ) %]
                     [% UNLESS 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>
@@ -232,16 +251,15 @@ $.tablesorter.addParser({
             </tr>
         [% END %]</tbody>
         </table>
-
-        [% IF OpacRenewalAllowed %]
-            [% UNLESS patron_flagged %]
-            <input type="submit" value="Renew Selected" />
-            [% END %]
+          [% 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 %]
@@ -250,6 +268,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 (file)
index 0000000..2498057
Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/check.png differ
diff --git a/koha-tmpl/opac-tmpl/prog/images/checks.png b/koha-tmpl/opac-tmpl/prog/images/checks.png
new file mode 100644 (file)
index 0000000..75e8f45
Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/checks.png differ
index 97574b1..e99e557 100755 (executable)
@@ -114,6 +114,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
@@ -142,7 +143,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';
 
@@ -181,7 +185,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 );