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

(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (-12 / +11 lines)
Lines 30-42 BEGIN { Link Here
30
30
31
use Getopt::Long;
31
use Getopt::Long;
32
use Pod::Usage;
32
use Pod::Usage;
33
use Date::Calc qw(Add_Delta_Days);
34
33
35
use C4::Context;
34
use C4::Context;
36
use C4::Items;
35
use C4::Items;
37
use C4::Letters;
36
use C4::Letters;
38
use C4::Overdues;
37
use C4::Overdues;
39
use C4::Calendar;
38
use Koha::Calendar;
40
use Koha::DateUtils;
39
use Koha::DateUtils;
41
40
42
sub usage {
41
sub usage {
Lines 292-313 sub GetWaitingHolds { Link Here
292
    $sth->execute();
291
    $sth->execute();
293
    my @results;
292
    my @results;
294
    while ( my $issue = $sth->fetchrow_hashref() ) {
293
    while ( my $issue = $sth->fetchrow_hashref() ) {
295
        my $calendar = C4::Calendar->new( branchcode => $issue->{'site'} );
294
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
296
295
297
        my ( $waiting_year, $waiting_month, $waiting_day ) = split( /-/, $issue->{'waitingdate'} );
296
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
298
        my ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $pickupdelay );
297
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
299
298
        if ( $calendar->is_holiday($pickup_date) ) {
300
        while ( $calendar->isHoliday( $pickup_day, $pickup_month, $pickup_year ) ) {
299
            $pickup_date = $calendar->next_open_day( $pickup_date );
301
            ( $pickup_year, $pickup_month, $pickup_day ) = Add_Delta_Days( $pickup_year, $pickup_month, $pickup_day, 1 );
302
        }
300
        }
303
301
304
        $issue->{'date_due'} = sprintf( "%04d-%02d-%02d", $pickup_year, $pickup_month, $pickup_day );
302
        $issue->{'date_due'} = output_pref({dt => $pickup_date, dateformat => 'iso' });
305
        $issue->{'level'} = 1;    # only one level for Hold Waiting notifications
303
        $issue->{'level'} = 1;    # only one level for Hold Waiting notifications
306
304
307
        my $days_to_subtract = 0;
305
        my $days_to_subtract = 0;
308
        while ( $calendar->isHoliday( reverse( Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, $days_to_subtract ) ) ) ) {
306
        if ( $calendar->is_holiday($waiting_date) ) {
309
            $days_to_subtract++;
307
            my $next_open_day = $calendar->next_open_day( $waiting_date );
308
            $days_to_subtract = $calendar->days_between($waiting_date, $next_open_day)->days;
310
        }
309
        }
310
311
        $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract;
311
        $issue->{'days_since_waiting'} = $issue->{'days_since_waiting'} - $days_to_subtract;
312
312
313
        if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call )
313
        if ( ( grep $_ eq $issue->{'days_since_waiting'}, @holds_waiting_days_to_call )
314
- 

Return to bug 9004