Browse Source

Bug 20934: Fix display of old checkouts in the checkout history page

Again a regression caused by
  commit fa54100dff
  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 <maryse.simard@inlibro.com>
The patch works as expected.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
18.11.x
Jonathan Druart 3 years ago
committed by Nick Clemens
parent
commit
117e3a18f5
  1. 32
      Koha/Old/Checkout.pm
  2. 19
      Koha/Schema/Result/OldIssue.pm
  3. 13
      catalogue/issuehistory.pl
  4. 4
      koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt

32
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';
}

19
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';
}

13
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,

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

@ -26,8 +26,8 @@
[% IF biblio.author %]<h3>by [% biblio.author %]</h3>[% END %]
<div class="searchresults">
[% IF checkouts.count %]
<h4>Checked out [% checkouts.count %] times</h4>
[% IF checkouts %]
<h4>Checked out [% checkouts %] times</h4>
<table id="table_issues">
<thead><tr>
[% IF Koha.Preference('intranetreadinghistory') AND CAN_user_circulate_circulate_remaining_permissions %]

Loading…
Cancel
Save