From 30720d5ed22f85f8d770c8a0058f820dca613ca6 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 20 Oct 2021 18:18:33 -0300 Subject: [PATCH] Bug 29275: Use the API to fetch checkouts information This patch changes issuehistory.pl so it leverages on the API for fetching checkouts information in the template. Workflow changes: This development splits the 'current' checkouts and the 'past' checkouts in two different tables. Terminology could be revisited by native english speakers. To test: 1. Have records with and without current/past checkouts 2. Notice how the Checkouts history tab presents the information on each case. => SUGGESTION: Keep each of them open on separate tabs for comparing 3. Apply this patchset and its dependencies 4. Restart plack, run: $ koha-plack --restart kohadev 5. Follow the same steps you followed for those open tabs, in new ones => SUCCESS: What you see makes sense, information is displayed as it used to, with the different tables now. 6. Try searching on the datatables => SUCCESS: Search works correctly! 7. Revisit the new texts I added => SUGGESTION: If you have better wordings, submit a patch, or just comment on the bug so I do it inline. 8. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Victor Grousset/tuxayo --- catalogue/issuehistory.pl | 29 +-- .../prog/en/modules/catalogue/issuehistory.tt | 213 ++++++++++++------ 2 files changed, 157 insertions(+), 85 deletions(-) diff --git a/catalogue/issuehistory.pl b/catalogue/issuehistory.pl index 8d17dc933a..add7cb2d40 100755 --- a/catalogue/issuehistory.pl +++ b/catalogue/issuehistory.pl @@ -24,8 +24,6 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Search qw( enabled_staff_search_views ); use C4::Serials qw( CountSubscriptionFromBiblionumber ); -use Koha::Checkouts; -use Koha::Old::Checkouts; use Koha::Biblios; @@ -40,29 +38,18 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); my $biblionumber = $query->param('biblionumber'); +my $biblio = Koha::Biblios->find($biblionumber); -my @checkouts = Koha::Checkouts->search( - { biblionumber => $biblionumber }, - { - join => 'item', - order_by => 'timestamp', - } -); -my @old_checkouts = Koha::Old::Checkouts->search( - { biblionumber => $biblionumber }, - { - join => 'item', - order_by => 'timestamp', - } +$template->param( + current_checkouts_count => $biblio->current_checkouts->count, + past_checkouts_count => $biblio->old_checkouts->count, + biblio => $biblio, ); -my $biblio = Koha::Biblios->find( $biblionumber ); - +# variables for biblio-view-menu.inc $template->param( - checkouts => [ @checkouts, @old_checkouts ], - biblio => $biblio, - issuehistoryview => 1, - C4::Search::enabled_staff_search_views, + issuehistoryview => 1, + C4::Search::enabled_staff_search_views, subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber), ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt index 53c0121d52..6995915006 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -45,75 +45,68 @@ [% SET show_patron_column = Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]
- [% IF checkouts %] -

Checked out [% checkouts.size | html %] times

- - - [% IF show_patron_column %] +[% IF current_checkouts_count + past_checkouts_count > 0 %] +

Checked out [% current_checkouts_count + past_checkouts_count | html %] times

+ +

Current checkouts

+[% IF current_checkouts_count > 0 %] +
+ + [% IF show_patron_column %] - [% END %] + [% END %] - [% IF Koha.Preference('RecordStaffUserOnCheckout') %] + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] - [% ELSE %] + [% ELSE %] - [% END %] + [% END %] - - - - [% FOREACH checkout IN checkouts %] - - [% IF show_patron_column %] - - [% END %] - - - - - - - - + +
PatronBarcode Checked out fromChecked out byChecked out byRenewed Checkout on Due dateCheckin on
- [% IF checkout.patron %][%# Not set for deleted patron records %] - [% INCLUDE 'patron-title.inc' patron => checkout.patron hide_patron_infos_if_needed=1 %] - [% END %] - - [% IF checkout.item.barcode %] [%# FIXME This test is not mandatory I think %] - [% checkout.item.barcode | html %] - [% ELSE %] -   - [% END %][% IF checkout.branchcode %] - [% Branches.GetName( checkout.branchcode ) | html %] - [% ELSE %] -   - [% END %][% IF checkout.issuer_id %] - - [% INCLUDE 'patron-title.inc' patron=checkout.issuer %] - - [% END %][% IF checkout.renewals %] - Yes[% IF checkout.lastreneweddate %], last on: [% checkout.lastreneweddate |$KohaDates with_hours => 1 %] - [% END %] - [% ELSE %] - No - [% END %] - [% checkout.issuedate |$KohaDates with_hours => 1 %] - - [% checkout.date_due |$KohaDates with_hours => 1 %] - - [% checkout.returndate |$KohaDates with_hours => 1 %] -
+[% ELSE %] +
+

Not currently checked out.

+
+[% END %] + +

Past checkouts

+ +[% IF past_checkouts_count > 0 %] + + + [% IF show_patron_column %] + [% END %] - -
Patron
- [% ELSE %] -

- [% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %] has never been checked out.

+ Barcode + Checked out from + [% IF Koha.Preference('RecordStaffUserOnCheckout') %] + Checked out by + [% ELSE %] + Checked out by + [% END %] + Renewed + Checkout on + Due date + Checkin on + + +[% ELSE %] +
+

No past checkouts.

+
+[% END %] - [% END %] +[% ELSE %] +
+

+ [% biblio.title | html %][% IF biblio.author %], by [% biblio.author | html %][% END %] has never been checked out. +

+
+[% END %]
@@ -129,18 +122,110 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] +[% INCLUDE 'js-date-format.inc' %] +[% INCLUDE 'js-patron-format.inc' %] [% END %] -- 2.34.0