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

(-)a/Koha/Hold.pm (+25 lines)
Lines 21-29 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
23
24
use C4::Context qw(preference);
24
use Koha::Branches;
25
use Koha::Branches;
25
use Koha::Biblios;
26
use Koha::Biblios;
26
use Koha::Items;
27
use Koha::Items;
28
use Koha::DateUtils qw(dt_from_string);
27
29
28
use base qw(Koha::Object);
30
use base qw(Koha::Object);
29
31
Lines 37-42 Koha::Hold - Koha Hold object class Link Here
37
39
38
=cut
40
=cut
39
41
42
=head3 waiting_expires_on
43
44
Returns a DateTime for the date a waiting holds expires on.
45
Returns undef if the system peference ReservesMaxPickUpDelay is not set.
46
Returns undef if the hold is not waiting ( found = 'W' ).
47
48
=cut
49
50
sub waiting_expires_on {
51
    my ($self) = @_;
52
53
    return unless $self->found() eq 'W';
54
55
    my $ReservesMaxPickUpDelay = C4::Context->preference('ReservesMaxPickUpDelay');
56
    return unless $ReservesMaxPickUpDelay;
57
58
    my $dt = dt_from_string( $self->waitingdate() );
59
60
    $dt->add( days => $ReservesMaxPickUpDelay );
61
62
    return $dt;
63
}
64
40
=head3 biblio
65
=head3 biblio
41
66
42
Returns the related Koha::Biblio object for this hold
67
Returns the related Koha::Biblio object for this hold
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +1 lines)
Lines 775-781 No patron matched <span class="ex">[% message %]</span> Link Here
775
775
776
                                <br/>
776
                                <br/>
777
                                [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode()  ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]
777
                                [% IF ( w.branch.branchcode == Branches.GetLoggedInBranchcode()  ) %]<strong class="waitinghere">[% ELSE %]<strong>[% END %]
778
                                    Waiting at [% w.branch.branchname | html %]
778
                                    Waiting at [% w.branch.branchname | html %] [% IF w.waiting_expires_on %] until [% w.waiting_expires_on | $KohaDates %] [% END %]
779
                                </strong>
779
                                </strong>
780
                            </li>
780
                            </li>
781
                        </ul>
781
                        </ul>
(-)a/t/Hold.t (-1 / +54 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::MockModule;
21
use Test::More tests => 5;
22
use t::lib::Mocks;
23
24
my $module = new Test::MockModule('C4::Context');
25
$module->mock(
26
    '_new_dbh',
27
    sub {
28
        my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
29
          || die "Cannot create handle: $DBI::errstr\n";
30
        return $dbh;
31
    }
32
);
33
34
use_ok('Koha::Hold');
35
36
my $hold = Koha::Hold->new({ found => 'W', waitingdate => '2000-01-01'});
37
38
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', undef);
39
my $dt = $hold->waiting_expires_on();
40
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set");
41
42
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 5);
43
$dt = $hold->waiting_expires_on();
44
is( $dt->ymd, "2000-01-06", "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set");
45
46
$hold->found('T');
47
$dt = $hold->waiting_expires_on();
48
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )");
49
50
$hold->found(q{});
51
$dt = $hold->waiting_expires_on();
52
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )");
53
54
1;

Return to bug 13030