Koha/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
Jonathan Druart abfef3cf5d
Bug 35366: (bug 33948 follow-up) Fix display of old checkouts if no checkouts exist
Same patch as
  commit bee2b3d33e
  Bug 33949: Fix display of old checkouts if no checkouts exist

But for the staff interface.

"""
If we pass an empty array from the perl controller, we retrieve an empty
string from the template, and the merge does not work.

This patch fixes the following bug:
Pick a patron without checkout history
Check them an item out and check it in
=> The table is empty, whereas it should display the item that has been
checked in.
"""

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-11-26 20:53:25 -03:00

209 lines
9.4 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE KohaDates %]
[% USE Koha %]
[% USE AuthorisedValues %]
[% USE Branches %]
[% USE TablesSettings %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% FILTER collapse %]
[% t("Circulation history for") | html %] [% INCLUDE 'patron-title.inc' no_html = 1 %]
[% t("Patrons") | html %] &rsaquo;
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body id="pat_readingrec" class="pat">
[% WRAPPER 'header.inc' %]
[% INCLUDE 'patron-search-header.inc' %]
[% END %]
[% WRAPPER 'sub-header.inc' %]
[% WRAPPER breadcrumbs %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
[% END %]
[% WRAPPER breadcrumb_item %]
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
[% END %]
[% WRAPPER breadcrumb_item bc_active= 1 %]
<span>Circulation history</span>
[% END %]
[% END #/ WRAPPER breadcrumbs %]
[% END #/ WRAPPER sub-header.inc %]
<div class="main container-fluid">
<div class="row">
<div class="col-sm-10 col-sm-push-2">
<main>
[% INCLUDE 'members-toolbar.inc' %]
<h1>Circulation history</h1>
[% UNLESS checkouts %][% checkouts = [] %][% END %]
[% UNLESS old_checkouts %][% old_checkouts = [] %][% END %]
[% SET all_checkouts = checkouts.merge(old_checkouts) %]
[% UNLESS Koha.Preference('intranetreadinghistory') %]
<div class="dialog alert">Staff members are not allowed to access patron's checkout history</div>
[% ELSIF is_anonymous %]
<div class="dialog alert">This is the anonymous patron, so no circulation history is displayed. To get a list of anonymized loans, please run a report.</div>
[% ELSIF ( patron.privacy == 2) %]
<div class="dialog message">This patron has set the privacy rules to never keeping a circulation history.</div>
[% ELSIF ( !all_checkouts.size ) %]
<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="[% patron.borrowernumber | html %]" /></form>
[% BLOCK table_readingrec %]
<table id="table_readingrec">
<thead>
<tr>
<th style="display:none;">Type</th>
<th>Date</th>
<th class="anti-the">Title</th>
<th>Author</th>
<th>Call number</th>
<th>Vol info</th>
<th>Barcode</th>
<th>Number of renewals</th>
<th>Checked out on</th>
<th>Checked out from</th>
[% IF Koha.Preference('RecordStaffUserOnCheckout') %]
<th>Checked out by</th>
[% END %]
<th>Date due</th>
<th>Return date</th>
</tr>
</thead>
<tbody>
[% FOREACH checkout IN all_checkouts %]
[% SET item = checkout.item %]
[% SET biblio = item.biblio %]
[% IF checkout.returndate %]<tr>[% ELSE %]<tr class="onissue">[% END %]
<td style="display:none;">
[% IF checkout.onsite_checkout %][% issuetype = 'onsite_checkout' | html %]
[% ELSE %][% issuetype = 'standard_checkout' | html %]
[% END %]
[% issuetype | html %]
</td>
<td data-order="[% checkout.timestamp | html %]">
[% checkout.timestamp | $KohaDates with_hours => 1 %]
</td>
<td>
[% INCLUDE 'biblio-title.inc' biblio=biblio link = 1 %]
</td>
<td>[% biblio.author | html %]</td>
<td>
[% item.itemcallnumber | html %]
</td>
<td>
[% IF item.enumchron %]
[% item.enumchron | html %]
[% END %]
</td>
<td><a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% item.itemnumber | uri %]&amp;biblionumber=[% biblio.biblionumber | uri %]&amp;bi=[% item.biblioitemnumber | uri %]#item[% item.itemnumber | uri %]">[% item.barcode | html %]</a></td>
<td>
[% checkout.renewals_count | html %]
[% IF checkout.renewals_count > 0 %]
[ <a class="checkout_renewals_view" data-renewals="[% checkout.renewals_count | html %]" data-issueid="[% checkout.issue_id | html %]" href="#">View</a> ]
[% END %]
</td>
<td data-order="[% checkout.issuedate | html %]">
[% checkout.issuedate | $KohaDates with_hours => 1 %]
</td>
<td>[% Branches.GetName( checkout.branchcode ) | html %]</td>
[% IF Koha.Preference('RecordStaffUserOnCheckout') %]
[% SET issuer = checkout.issuer %]
<td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% issuer.borrowernumber | uri %]">[% issuer.firstname | html %] [% issuer.surname | html %]</a></td>
[% END %]
<td data-order="[% checkout.date_due | html %]">
[% checkout.date_due | $KohaDates as_due_date => 1 %]
</td>
[% IF checkout.returndate %]
<td data-order="[% checkout.returndate | html %]">
[% checkout.returndate | $KohaDates with_hours => 1 %]
[% ELSE %]
<td data-order="checked out">
<small>Checked out</small>
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
[% END %]
[% IF Koha.Preference('OnSiteCheckouts') %]
[% WRAPPER tabs id= "tabs" %]
[% WRAPPER tabs_nav %]
[% WRAPPER tab_item tabname= "tab_all" bt_active= 1 %] <span>All</span> [% END %]
[% WRAPPER tab_item tabname= "tab_checkout" %] <span>Checkouts</span> [% END %]
[% WRAPPER tab_item tabname= "tab_onsite_checkout" %] <span>On-site checkouts</span> [% END %]
[% END # /WRAPPER tabs_nav %]
[% WRAPPER tab_panels %]
[% WRAPPER tab_panel tabname="readingrec" bt_active= 1 %]
[% INCLUDE table_readingrec %]
[% END # /tab_panel# %]
[% END # /WRAPPER tab_panels %]
[% END # /WRAPPER tabs %]
[% ELSE %]
<div class="page-section">
[% INCLUDE table_readingrec %]
</div> <!-- /.page-section -->
[% END # /IF Koha.Preference('OnSiteCheckouts') %]
[% END %]
</main>
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
[% INCLUDE 'circ-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
</div> <!-- /.row -->
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'str/members-menu.inc' %]
[% Asset.js("js/members-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
[% INCLUDE 'modals/checkout_renewals.inc' %]
[% INCLUDE 'js-date-format.inc' %]
[% INCLUDE 'js-patron-format.inc' %]
[% Asset.js("js/checkout_renewals_modal.js") | $raw %]
<script id="js">
$(document).ready(function() {
[% IF Koha.Preference('RecordStaffUserOnCheckout') %]
var column_sort = 11;
[% ELSE %]
var column_sort = 10;
[% END %]
var table_settings = [% TablesSettings.GetTableSettings('members', 'checkouthistory', 'checkouthistory-table', 'json') | $raw %];
var table = KohaTable("table_readingrec", {
"sPaginationType": "full",
"aaSorting": [[column_sort, 'desc']]
}, table_settings);
$("#tabs a[data-toggle='tab']").on("shown.bs.tab", function (e) {
active_tab = $(this).attr("href");
if( active_tab == "#tab_checkout_panel" ){
table.fnFilter("standard_checkout", 0);
} else if( active_tab == "#tab_onsite_checkout_panel" ){
table.fnFilter("onsite_checkout", 0);
} else {
table.fnFilter('', 0);
}
});
});
</script>
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]