From 117e3a18f5b7c24e6c9fb7eabb78ab1b5320cd14 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Jun 2018 13:26:43 -0300 Subject: [PATCH] Bug 20934: Fix display of old checkouts in the checkout history page Again a regression caused by commit fa54100dffe092e606f79b15692eedaf78f42e45 Bug 18403: Use patron-title.inc when hidepatronname is used [SPECIFIC for issuehistory] GetBiblioIssues does a union all with issues and old_issues, so we should old_issues as well. To make the join on the items table we need to define the item and patron methods. For consistency the relationships have been redefined (item instead of itemnumber, borrower instead of borrowernumber) in the DBIx::Class definition. This is not perfect but I think the best way to provide an easy to backport patch. It highlights that we need improvements in this area. Signed-off-by: Maryse Simard The patch works as expected. Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- Koha/Old/Checkout.pm | 32 +++++++++++++++++++ Koha/Schema/Result/OldIssue.pm | 19 +++++++++++ catalogue/issuehistory.pl | 13 ++++++-- .../prog/en/modules/catalogue/issuehistory.tt | 4 +-- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/Koha/Old/Checkout.pm b/Koha/Old/Checkout.pm index 3a7c1eb088..2507cc1326 100644 --- a/Koha/Old/Checkout.pm +++ b/Koha/Old/Checkout.pm @@ -21,6 +21,38 @@ use Koha::Database; use base qw(Koha::Object); +=head3 item + +my $item = $checkout->item; + +Return the checked out item + +=cut + +sub item { + my ( $self ) = @_; + my $item_rs = $self->_result->item; + return Koha::Item->_new_from_dbic( $item_rs ); +} + +=head3 patron + +my $patron = $checkout->patron + +Return the patron for who the checkout has been done + +=cut + +sub patron { + my ( $self ) = @_; + my $patron_rs = $self->_result->borrower; + return Koha::Patron->_new_from_dbic( $patron_rs ); +} + + + + + sub _type { return 'OldIssue'; } diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm index b9c5b234b5..32a90ab6d3 100644 --- a/Koha/Schema/Result/OldIssue.pm +++ b/Koha/Schema/Result/OldIssue.pm @@ -229,6 +229,25 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RKLeDDEz22G5BU/ZAl7QLA +__PACKAGE__->belongs_to( + "borrower", + "Koha::Schema::Result::Borrower", + { borrowernumber => "borrowernumber" }, + { join_type => "LEFT", on_delete => "CASCADE", on_update => "CASCADE" }, +); + +__PACKAGE__->belongs_to( + "item", + "Koha::Schema::Result::Item", + { itemnumber => "itemnumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + sub koha_objects_class { 'Koha::Old::Checkouts'; } diff --git a/catalogue/issuehistory.pl b/catalogue/issuehistory.pl index 6a7f623336..f7044022f0 100755 --- a/catalogue/issuehistory.pl +++ b/catalogue/issuehistory.pl @@ -25,6 +25,7 @@ use C4::Output; use C4::Biblio; # GetBiblio use C4::Search; # enabled_staff_search_views use Koha::Checkouts; +use Koha::Old::Checkouts; use Koha::Biblios; @@ -41,17 +42,25 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $biblionumber = $query->param('biblionumber'); -my $checkouts = Koha::Checkouts->search( +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', + } +); + my $biblio = Koha::Biblios->find( $biblionumber ); $template->param( - checkouts => $checkouts, + checkouts => [ @checkouts, @old_checkouts ], biblio => $biblio, issuehistoryview => 1, C4::Search::enabled_staff_search_views, 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 0d3c01d498..e831fa6d27 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt @@ -26,8 +26,8 @@ [% IF biblio.author %]

by [% biblio.author %]

[% END %]
- [% IF checkouts.count %] -

Checked out [% checkouts.count %] times

+ [% IF checkouts %] +

Checked out [% checkouts %] times

[% IF Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %] -- 2.39.5