Bug 11009: Do not display circulation history of anonymous patron
authorFridolyn SOMERS <fridolyn.somers@biblibre.com>
Tue, 8 Oct 2013 07:34:42 +0000 (09:34 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 10 Dec 2013 20:19:00 +0000 (20:19 +0000)
When using an anonymous patron to anonymise issues history, this patron
may have a huge number of old issues. In this case, trying to display
the reading history of this patron will perform a huge SQL query.
It is not useful to have the reading history of this anonymous patron.

This patch adds an alert instead of old issues when displaying reading
records of anonymous patron.

Test plan :
- Set syspref AnonymousPatron to 0.
- Select a borrower with old issues. For example 123.
- Look at its reading records page : members/readingrec.pl
=> Old issues are displayed in a datatable
- Set syspref AnonymousPatron with this borrower number. For example 123.
- Look at its reading records page
=> Old issues are not displayed and an alert is displayed
- Using SQL query, remove old issues of this borrower :
    DELETE FROM old_issues WHERE borrowernumber=123.
- Look at its reading records page
=> A message is displayed

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
This works as advertised and seems like a reasonable thing to do. I
suspect that someone will object... Perhaps that person will implement a
solution which uses an AJAX DataTable.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
members/readingrec.pl

index f36e254..47ed060 100644 (file)
        <div class="yui-b">
 [% INCLUDE 'members-toolbar.inc' %]
 <h1>Circulation history</h1>
-[% IF loop_reading %]
+
+[% IF is_anonymous %]
+    <div class="dialog alert">This is the anonymous patron.</div>
+[% ELSIF ( !loop_reading ) %]
+    <div class="dialog message">This patron has no circulation history.</div>
+[% ELSE %]
 <form action="/cgi-bin/koha/members/readingrec.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" /></form>
 
 
 </tr>
 [% END %]
 </table>
-[% ELSE %]
-<div class="dialog message">This patron has no circulation history.</div>
 [% END %]
 </div>
 </div>
index 0f0c3df..2a57c42 100755 (executable)
@@ -63,7 +63,13 @@ if ($input->param('borrowernumber')) {
 
 my $order = 'date_due desc';
 my $limit = 0;
-my $issues = GetAllIssues($borrowernumber,$order,$limit);
+my $issues = ();
+# Do not request the old issues of anonymous patron
+if ( $borrowernumber == C4::Context->preference('AnonymousPatron') ){
+    $template->param( is_anonymous => 1 );
+} else {
+    $issues = GetAllIssues($borrowernumber,$order,$limit);
+}
 
 my $branches = GetBranches();
 foreach my $issue ( @{$issues} ) {