View | Details | Raw Unified | Return to bug 16686
Collapse All | Expand All

(-)a/Koha/Item.pm (-1 / +79 lines)
Lines 26-31 use Koha::Database; Link Here
26
use Koha::Patrons;
26
use Koha::Patrons;
27
use Koha::Libraries;
27
use Koha::Libraries;
28
28
29
use C4::Circulation qw( GetTransfers );
30
29
use base qw(Koha::Object);
31
use base qw(Koha::Object);
30
32
31
=head1 NAME
33
=head1 NAME
Lines 107-113 sub last_returned_by { Link Here
107
    }
109
    }
108
}
110
}
109
111
110
=head3 type
112
=head3 _get_transit_data
113
114
=cut
115
116
sub _get_transit_data {
117
    my ($self) = @_;
118
119
    return $self->{_transit_data} if defined $self->{_transit_data};
120
121
    $self->{_transit_data} = {};
122
123
    my ( $date, $from, $to ) = C4::Circulation::GetTransfers( $self->id );
124
125
    $self->{_transit_data}->{date} = $date;
126
    $self->{_transit_data}->{from} = $from;
127
    $self->{_transit_data}->{to}   = $to;
128
129
    return $self->{_transit_data};
130
}
131
132
=head3 is_in_transit
133
134
$item->is_in_transit();
135
136
=cut
137
138
sub is_in_transit {
139
    my ($self) = @_;
140
141
    my $data = $self->_get_transit_data();
142
143
    return $data->{date} ? 1 : 0;
144
}
145
146
=head3 in_transit_date
147
148
my $transfer_date = $item->in_transit_date();
149
150
=cut
151
152
sub in_transit_date {
153
    my ($self) = @_;
154
155
    my $data = $self->_get_transit_data();
156
157
    return $data->{date};
158
}
159
160
=head3 in_transit_to
161
162
my $library_id = $item->in_transit_to();
163
164
=cut
165
166
sub in_transit_to {
167
    my ($self) = @_;
168
169
    my $data = $self->_get_transit_data();
170
171
    return $data->{to};
172
}
173
174
=head3 in_transit_from
175
176
my $library_id = $item->in_transit_from();
177
178
=cut
179
180
sub in_transit_from {
181
    my ($self) = @_;
182
183
    my $data = $self->_get_transit_data();
184
185
    return $data->{from};
186
}
187
188
=head3 _type
111
189
112
=cut
190
=cut
113
191
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-2 / +2 lines)
Lines 604-611 Link Here
604
                                                    [% END %]
604
                                                    [% END %]
605
                                                [% ELSE %]
605
                                                [% ELSE %]
606
                                                    [% IF ( RESERVE.is_in_transit ) %]
606
                                                    [% IF ( RESERVE.is_in_transit ) %]
607
                                                        Item in transit from <b> [% RESERVE.frombranch %]</b> since
607
                                                        Item in transit from <b> [% Branches.GetName( RESERVE.item.in_transit_from ) %]</b> since
608
                                                        [% RESERVE.datesent | $KohaDates %]
608
                                                        [% RESERVE.item.in_transit_date | $KohaDates %]
609
                                                    [% ELSIF ( RESERVE.suspend ) %]
609
                                                    [% ELSIF ( RESERVE.suspend ) %]
610
                                                        Suspended [% IF ( RESERVE.suspend_until ) %] until [% RESERVE.suspend_until %] [% END %]
610
                                                        Suspended [% IF ( RESERVE.suspend_until ) %] until [% RESERVE.suspend_until %] [% END %]
611
                                                    [% ELSE %]
611
                                                    [% ELSE %]
(-)a/t/db_dependent/Circulation/transfers.t (-2 / +26 lines)
Lines 8-18 use C4::Branch; Link Here
8
use C4::Circulation;
8
use C4::Circulation;
9
use Koha::Database;
9
use Koha::Database;
10
use Koha::DateUtils;
10
use Koha::DateUtils;
11
use Koha::Items;
11
use DateTime::Duration;
12
use DateTime::Duration;
12
13
13
use t::lib::TestBuilder;
14
use t::lib::TestBuilder;
14
15
15
use Test::More tests => 22;
16
use Test::More tests => 37;
16
use Test::Deep;
17
use Test::Deep;
17
18
18
BEGIN {
19
BEGIN {
Lines 77-82 my @sampleitem2 = C4::Items::AddItem( Link Here
77
);
78
);
78
my $item_id2 = $sampleitem2[2];
79
my $item_id2 = $sampleitem2[2];
79
80
81
my $item = Koha::Items->find( $item_id1 );
82
my $transit_data = $item->_get_transit_data();
83
is( ref($transit_data), 'HASH', '_get_transit_data() returns hashref even if item is not in transit' );
84
is( $transit_data->{date}, undef, 'Got transit date undef from _get_transit_data()' );
85
is( $transit_data->{from}, undef, 'Got transit from undef from _get_transit_data()' );
86
is( $transit_data->{to}, undef, 'Got transit to undef from _get_tranist_data()' );
87
88
is( $item->is_in_transit(), 0, 'Item is not in transit' );
89
is( $item->in_transit_date(), undef, 'Transit date is undef' );
90
is( $item->in_transit_to(), undef, 'Transit to library is undef' );
91
is( $item->in_transit_from(), undef, 'Transit from library is undef' );
92
80
#Add transfers
93
#Add transfers
81
ModItemTransfer(
94
ModItemTransfer(
82
    $item_id1,
95
    $item_id1,
Lines 116-121 cmp_deeply( Link Here
116
    [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ],
129
    [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ],
117
    "Transfers of the item1"
130
    "Transfers of the item1"
118
);    #NOTE: Only the first transfer is returned
131
);    #NOTE: Only the first transfer is returned
132
133
$item = Koha::Items->find( $item_id1 );
134
$transit_data = $item->_get_transit_data();
135
is( $transit_data->{date}, $transfers[0], 'Got transit date correctly from _get_transit_data()' );
136
is( $transit_data->{from}, $samplebranch1->{branchcode}, 'Got transit from correctly from _get_transit_data()' );
137
is( $transit_data->{to}, $samplebranch2->{branchcode}, 'Got transit to correctly from _get_tranist_data()' );
138
139
is( $item->is_in_transit(), 1, 'Item is in transit' );
140
is( $item->in_transit_date(), $transfers[0], 'Transit date is correct' );
141
is( $item->in_transit_to(), $samplebranch2->{branchcode}, 'Transit to library is correct' );
142
is( $item->in_transit_from(), $samplebranch1->{branchcode}, 'Transit from library is correct' );
143
119
@transfers = GetTransfers;
144
@transfers = GetTransfers;
120
is_deeply( \@transfers, [],
145
is_deeply( \@transfers, [],
121
    "GetTransfers without params returns an empty array" );
146
    "GetTransfers without params returns an empty array" );
122
- 

Return to bug 16686