From 65967c106b7863c6727471e2e2b96782e60efeba Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 7 Jun 2016 15:50:04 +0000 Subject: [PATCH] Bug 16686 - Fix "Item in transit from since" in Holds tab "From branch" and date do not show up in patron's "Holds" tab: "Item in transit from since" OPAC log: opac-user.pl: No method frombranch! at /usr/share/kohaclone/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt line 607 Test Plan: 1) Apply this patch 2) Create an in transit hold 3) Not the from library is displayed --- Koha/Item.pm | 80 +++++++++++++++++++++- .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 4 +- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index d721537..c3d65a0 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -26,6 +26,8 @@ use Koha::Database; use Koha::Patrons; use Koha::Libraries; +use C4::Circulation qw( GetTransfers ); + use base qw(Koha::Object); =head1 NAME @@ -107,7 +109,83 @@ sub last_returned_by { } } -=head3 type +=head3 _get_transit_data + +=cut + +sub _get_transit_data { + my ($self) = @_; + + return $self->{_transit_data} if defined $self->{_transit_data}; + + $self->{_transit_data} = {}; + + my ( $date, $from, $to ) = GetTransfers( $self->id ); + + $self->{_transit_data}->{date} = $date; + $self->{_transit_data}->{from} = $from; + $self->{_transit_data}->{to} = $to; + + return $self->{_transit_data}; +} + +=head3 is_in_transit + +$item->is_in_transit(); + +=cut + +sub is_in_transit { + my ($self) = @_; + + my $data = $self->_get_transit_data(); + + return $data->{date} ? 1 : 0; +} + +=head3 in_transit_date + +my $transfer_date = $item->in_transit_date(); + +=cut + +sub in_transit_date { + my ($self) = @_; + + my $data = $self->_get_transit_data(); + + return $data->{date}; +} + +=head3 in_transit_to + +my $library_id = $item->in_transit_to(); + +=cut + +sub in_transit_to { + my ($self) = @_; + + my $data = $self->_get_transit_data(); + + return $data->{to}; +} + +=head3 in_transit_from + +my $library_id = $item->in_transit_from(); + +=cut + +sub in_transit_from { + my ($self) = @_; + + my $data = $self->_get_transit_data(); + + return $data->{from}; +} + +=head3 _type =cut diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index f31f47e..ada22d3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -604,8 +604,8 @@ [% END %] [% ELSE %] [% IF ( RESERVE.is_in_transit ) %] - Item in transit from [% RESERVE.frombranch %] since - [% RESERVE.datesent | $KohaDates %] + Item in transit from [% Branches.GetName( RESERVE.item.in_transit_from ) %] since + [% RESERVE.item.in_transit_date | $KohaDates %] [% ELSIF ( RESERVE.suspend ) %] Suspended [% IF ( RESERVE.suspend_until ) %] until [% RESERVE.suspend_until %] [% END %] [% ELSE %] -- 2.1.4