Lines 1-30
Link Here
|
1 |
use C4::Context; |
1 |
$DBversion = 'XXX'; |
|
|
2 |
if( CheckVersion( $DBversion ) ) { |
3 |
use Koha::Holds; |
2 |
|
4 |
|
3 |
use Koha::Holds; |
5 |
my $waiting_holds = Koha::Holds->search({ found => 'W', priority => 0 }); |
4 |
use Koha::DateUtils; |
6 |
while ( my $hold = $waiting_holds->next ) { |
5 |
use Koha::Calendar; |
|
|
6 |
|
7 |
|
7 |
my $waiting_holds = Koha::Holds->search({ found => 'W', priority => 0 }); |
8 |
my $requested_expiration; |
8 |
while ( my $hold = $waiting_holds->next ) { |
9 |
if ($hold->expirationdate) { |
|
|
10 |
$requested_expiration = dt_from_string($hold->expirationdate); |
11 |
} |
9 |
|
12 |
|
10 |
my $requested_expiration; |
13 |
if ( my $waitingdate = dt_from_string($hold->waitingdate) ) { |
11 |
if ($hold->expirationdate) { |
14 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
12 |
$requested_expiration = dt_from_string($hold->expirationdate); |
15 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
13 |
} |
16 |
my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); |
14 |
|
17 |
|
15 |
if ( my $waitingdate = dt_from_string($hold->waitingdate) ) { |
18 |
my $expirationdate = $waitingdate->clone; |
16 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
19 |
$expirationdate->add(days => $max_pickup_delay); |
17 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
|
|
18 |
my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode ); |
19 |
|
20 |
|
20 |
my $expirationdate = $waitingdate->clone; |
21 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
21 |
$expirationdate->add(days => $max_pickup_delay); |
22 |
$expirationdate = $calendar->days_forward( dt_from_string($hold->waitingdate), $max_pickup_delay ); |
|
|
23 |
} |
22 |
|
24 |
|
23 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
25 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
24 |
$expirationdate = $calendar->days_forward( dt_from_string($hold->waitingdate), $max_pickup_delay ); |
26 |
$hold->expirationdate($cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd)->store; |
25 |
} |
27 |
} |
26 |
|
|
|
27 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
28 |
$hold->expirationdate($cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd)->store; |
29 |
} |
28 |
} |
|
|
29 |
|
30 |
SetVersion( $DBversion ); |
31 |
print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; |
30 |
} |
32 |
} |
31 |
- |
|
|