Bugzilla – Attachment 52898 Details for
Bug 16686
Fix "Item in transit from since" in Holds tab
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16686 - Fix "Item in transit from since" in Holds tab
Bug-16686---Fix-Item-in-transit-from-since-in-Hold.patch (text/plain), 5.99 KB, created by
Kyle M Hall (khall)
on 2016-06-27 15:12:24 UTC
(
hide
)
Description:
Bug 16686 - Fix "Item in transit from since" in Holds tab
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-27 15:12:24 UTC
Size:
5.99 KB
patch
obsolete
>From f818bc593ddb7e164b0ac5e11fe7aca0dcf87f1a Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >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 +- > t/db_dependent/Circulation/transfers.t | 27 +++++++- > 3 files changed, 107 insertions(+), 4 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index d721537..7d4d965 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 ) = C4::Circulation::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 264641f..116fb17 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 <b> [% RESERVE.frombranch %]</b> since >- [% RESERVE.datesent | $KohaDates %] >+ Item in transit from <b> [% Branches.GetName( RESERVE.item.in_transit_from ) %]</b> since >+ [% RESERVE.item.in_transit_date | $KohaDates %] > [% ELSIF ( RESERVE.suspend ) %] > Suspended [% IF ( RESERVE.suspend_until ) %] until [% RESERVE.suspend_until %] [% END %] > [% ELSE %] >diff --git a/t/db_dependent/Circulation/transfers.t b/t/db_dependent/Circulation/transfers.t >index e92cadf..7880b3c 100644 >--- a/t/db_dependent/Circulation/transfers.t >+++ b/t/db_dependent/Circulation/transfers.t >@@ -8,11 +8,12 @@ use C4::Branch; > use C4::Circulation; > use Koha::Database; > use Koha::DateUtils; >+use Koha::Items; > use DateTime::Duration; > > use t::lib::TestBuilder; > >-use Test::More tests => 22; >+use Test::More tests => 37; > use Test::Deep; > > BEGIN { >@@ -77,6 +78,18 @@ my @sampleitem2 = C4::Items::AddItem( > ); > my $item_id2 = $sampleitem2[2]; > >+my $item = Koha::Items->find( $item_id1 ); >+my $transit_data = $item->_get_transit_data(); >+is( ref($transit_data), 'HASH', '_get_transit_data() returns hashref even if item is not in transit' ); >+is( $transit_data->{date}, undef, 'Got transit date undef from _get_transit_data()' ); >+is( $transit_data->{from}, undef, 'Got transit from undef from _get_transit_data()' ); >+is( $transit_data->{to}, undef, 'Got transit to undef from _get_tranist_data()' ); >+ >+is( $item->is_in_transit(), 0, 'Item is not in transit' ); >+is( $item->in_transit_date(), undef, 'Transit date is undef' ); >+is( $item->in_transit_to(), undef, 'Transit to library is undef' ); >+is( $item->in_transit_from(), undef, 'Transit from library is undef' ); >+ > #Add transfers > ModItemTransfer( > $item_id1, >@@ -116,6 +129,18 @@ cmp_deeply( > [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ], > "Transfers of the item1" > ); #NOTE: Only the first transfer is returned >+ >+$item = Koha::Items->find( $item_id1 ); >+$transit_data = $item->_get_transit_data(); >+is( $transit_data->{date}, $transfers[0], 'Got transit date correctly from _get_transit_data()' ); >+is( $transit_data->{from}, $samplebranch1->{branchcode}, 'Got transit from correctly from _get_transit_data()' ); >+is( $transit_data->{to}, $samplebranch2->{branchcode}, 'Got transit to correctly from _get_tranist_data()' ); >+ >+is( $item->is_in_transit(), 1, 'Item is in transit' ); >+is( $item->in_transit_date(), $transfers[0], 'Transit date is correct' ); >+is( $item->in_transit_to(), $samplebranch2->{branchcode}, 'Transit to library is correct' ); >+is( $item->in_transit_from(), $samplebranch1->{branchcode}, 'Transit from library is correct' ); >+ > @transfers = GetTransfers; > is_deeply( \@transfers, [], > "GetTransfers without params returns an empty array" ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16686
:
52157
|
52163
|
52164
|
52183
|
52898
|
53050
|
53053
|
53084
|
53190
|
53191
|
53192
|
53227
|
54128
|
54129
|
54130
|
54131
|
54392
|
54393
|
54394
|
54395