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 %]