Bug 18403: Use patron-title.inc when hidepatronname is used [SPECIFIC for issuehistory]
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 5 Apr 2017 20:04:36 +0000 (17:04 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 12 Feb 2018 18:41:39 +0000 (15:41 -0300)
On this page we do not have the patron object sent to the template,
let's pass it!

Test plan:
Go on the checkout history of a bibliographic record
(catalogue/issuehistory.pl)
You should not see patron's information that are not part of your group
if you
are not allowed to see them.

Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

catalogue/issuehistory.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt

index 5cf0405..6a7f623 100755 (executable)
@@ -22,9 +22,9 @@ use CGI qw ( -utf8 );
 use C4::Auth;
 use C4::Output;
 
-use C4::Circulation;    # GetBiblioIssues
 use C4::Biblio;    # GetBiblio
 use C4::Search;                # enabled_staff_search_views
+use Koha::Checkouts;
 
 use Koha::Biblios;
 
@@ -41,18 +41,18 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
 
 my $biblionumber = $query->param('biblionumber');
 
-if (C4::Context->preference("HidePatronName")) {
-   $template->param(HidePatronName => 1);
-}
-
-my $issues = GetBiblioIssues($biblionumber);
+my $checkouts = Koha::Checkouts->search(
+    { biblionumber => $biblionumber },
+    {
+        join       => 'item',
+        order_by   => 'timestamp',
+    }
+);
 my $biblio = Koha::Biblios->find( $biblionumber );
 
 $template->param(
-    biblionumber => $biblionumber, # required for left-side navigation
-    biblio       => $biblio,
-    total        => scalar @$issues,
-    issues       => $issues,
+    checkouts => $checkouts,
+    biblio    => $biblio,
        issuehistoryview => 1,
        C4::Search::enabled_staff_search_views,
 );
index 83c60cc..7ee061c 100644 (file)
@@ -25,8 +25,8 @@
 [% IF biblio.author %]<h3>by [% biblio.author %]</h3>[% END %]
 
 <div class="searchresults">
-    [% IF ( issues ) %]
-        <h4>Checked out [% total %] times</h4>
+    [% IF checkouts.count %]
+        <h4>Checked out [% checkouts.count %] times</h4>
         <table id="table_issues">
             <thead><tr>
             [% IF Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]
             <th class='title-string'>Checkin on</th>
             </tr></thead>
             <tbody>
-        [% FOREACH issue IN issues %]
+        [% FOREACH checkout IN checkouts %]
             <tr>
                 [% IF Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]
                 <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% issue.borrowernumber %]">[% IF HidePatronName %][% issue.cardnumber %][% ELSE %][% issue.surname %][% IF ( issue.firstname ) %], [% issue.firstname %][% END %][% END %]</a></td>
                 [% END %]
-                <td>[% IF ( issue.barcode ) %]
-                        <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% issue.biblionumber %]&amp;itemnumber=[% issue.itemnumber %]">[% issue.barcode %]</a>
+                <td>
+                    [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %]
+                        <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% checkout.item.biblionumber %]&amp;itemnumber=[% checkout.item.itemnumber %]">[% checkout.item.barcode %]</a>
                     [% ELSE %]
                         &nbsp;
                     [% END %]</td>
-                <td>[% IF ( issue.branchcode ) %]
-                        [% Branches.GetName( issue.branchcode ) %]
+                <td>[% IF checkout.branchcode %]
+                        [% Branches.GetName( checkout.branchcode ) %]
                     [% ELSE %]
                         &nbsp;
                     [% END %]</td>
-                <td>[% IF ( issue.renewals ) %]
-                        Yes[% IF ( issue.lastreneweddate ) %], <small>last on: [% issue.lastreneweddate |$KohaDates with_hours => 1  %]</small>
+                <td>[% IF checkout.renewals %]
+                        Yes[% IF checkout.lastreneweddate %], <small>last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1  %]</small>
                             [% END %]
                     [% ELSE %]
                         No
                     [% END %]</td>
-                <td>[% IF ( issue.issuedate ) %]
-                        <span title="[% issue.issuedate %]">[% issue.issuedate |$KohaDates with_hours => 1  %]</span>
+                <td>[% IF checkout.issuedate %]
+                        <span title="[% checkout.issuedate %]">[% checkout.issuedate |$KohaDates with_hours => 1  %]</span>
                     [% ELSE %]
                         <span title="0000-00-00"></span>
                     [% END %]</td>
-                <td>[% IF ( issue.date_due ) %]
-                        <span title="[% issue.date_due %]">[% issue.date_due |$KohaDates with_hours => 1  %]</span>
+                <td>[% IF checkout.date_due %]
+                        <span title="[% checkout.date_due %]">[% checkout.date_due |$KohaDates with_hours => 1  %]</span>
                     [% ELSE %]
                         <span title="0000-00-00"></span>
                     [% END %]</td>
-                <td>[% IF ( issue.returndate ) %]
-                        <span title="[% issue.returndate %]">[% issue.returndate |$KohaDates with_hours => 1  %]</span>
+                <td>[% IF checkout.returndate %]
+                        <span title="[% checkout.returndate %]">[% checkout.returndate |$KohaDates with_hours => 1  %]</span>
                     [% ELSE %]
                         <span title="Checked out"><small>Checked out</small></span>
                     [% END %]</td>