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

(-)a/C4/Reserves.pm (+23 lines)
Lines 38-43 use C4::Branch qw( GetBranchDetail ); Link Here
38
use C4::Dates qw( format_date_in_iso );
38
use C4::Dates qw( format_date_in_iso );
39
39
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use Koha::Calendar;
42
43
use DateTime;
41
44
42
use List::MoreUtils qw( firstidx );
45
use List::MoreUtils qw( firstidx );
43
46
Lines 132-137 BEGIN { Link Here
132
        &ToggleSuspend
135
        &ToggleSuspend
133
        &SuspendAll
136
        &SuspendAll
134
137
138
        &_reserve_last_pickup_date
139
135
        &GetReservesControlBranch
140
        &GetReservesControlBranch
136
    );
141
    );
137
    @EXPORT_OK = qw( MergeHolds );
142
    @EXPORT_OK = qw( MergeHolds );
Lines 1815-1820 sub _Findgroupreserve { Link Here
1815
    return @results;
1820
    return @results;
1816
}
1821
}
1817
1822
1823
=head2 _reserve_last_pickup_date
1824
1825
 my $last_dt = _reserve_last_pickup_date($reserve);
1826
1827
Returns the DateTime for the last pickup date for reserve.
1828
1829
=cut
1830
1831
sub _reserve_last_pickup_date {
1832
    my ($reserve) = @_;
1833
1834
    my $startdate = $reserve->{waitingdate} ? dt_from_string($reserve->{waitingdate}) : DateTime->now( time_zone => C4::Context->tz() );
1835
    my $calendar = Koha::Calendar->new( branchcode => $reserve->{branchcode} );
1836
    my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') );
1837
1838
    return $expiration;
1839
}
1840
1818
=head2 _koha_notify_reserve
1841
=head2 _koha_notify_reserve
1819
1842
1820
  _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber, $reserve_id );
1843
  _koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber, $reserve_id );
(-)a/Koha/Calendar.pm (+12 lines)
Lines 267-272 sub prev_open_day { Link Here
267
    return $base_date;
267
    return $base_date;
268
}
268
}
269
269
270
sub days_forward {
271
    my $self     = shift;
272
    my $start_dt = shift;
273
    my $num_days = shift;
274
275
    my $base_dt = $start_dt->clone();
276
277
    while ($num_days--) { $base_dt = $self->next_open_day($base_dt); }
278
279
    return $base_dt;
280
}
281
270
sub days_between {
282
sub days_between {
271
    my $self     = shift;
283
    my $self     = shift;
272
    my $start_dt = shift;
284
    my $start_dt = shift;
(-)a/Koha/Reserves.pm (-1 / +29 lines)
Lines 27-33 BEGIN { Link Here
27
    @ISA = qw(Exporter);
27
    @ISA = qw(Exporter);
28
    @EXPORT = qw(
28
    @EXPORT = qw(
29
29
30
30
        &GetLastpickupdate
31
        &GetWaitingReserves
31
    );
32
    );
32
}    
33
}    
33
34
Lines 35-37 use C4::Context; Link Here
35
use Koha::DateUtils;
36
use Koha::DateUtils;
36
use Koha::Database;
37
use Koha::Database;
37
38
39
=head2 GetLastpickupdate
40
41
 my $last_dt = GetLastpickupdate($reserve);
42
43
@PARAM1 Koha::Schema::Result::Reserve-object received via DBIx searching
44
@RETURNS the DateTime for the last pickup date for the given reserve.
45
=cut
46
47
sub GetLastpickupdate {
48
    my ($reserve) = @_;
49
50
    my $branchcode = $reserve->branchcode();
51
    if (ref $branchcode eq 'Koha::Schema::Result::Branch') {
52
        $branchcode = $branchcode->branchcode();
53
    }
54
55
    my $waitingdate = $reserve->waitingdate();
56
    my $startdate = $waitingdate ? Koha::DateUtils::dt_from_string($waitingdate) : DateTime->now( time_zone => C4::Context->tz() );
57
    my $calendar = Koha::Calendar->new( branchcode => $branchcode );
58
    my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') );
59
60
    return $expiration;
61
}
62
63
64
65
return 1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-2 / +1 lines)
Lines 404-410 Circulation: Link Here
404
            - Mark a hold as problematic if it has been waiting for more than
404
            - Mark a hold as problematic if it has been waiting for more than
405
            - pref: ReservesMaxPickUpDelay
405
            - pref: ReservesMaxPickUpDelay
406
              class: integer
406
              class: integer
407
            - days.
407
            - non-holiday days.
408
        -
408
        -
409
            - pref: ExpireReservesMaxPickUpDelay
409
            - pref: ExpireReservesMaxPickUpDelay
410
              choices:
410
              choices:
411
- 

Return to bug 12917