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

(-)a/misc/cronjobs/batch_anonymise.pl (-1 lines)
Lines 31-37 BEGIN { Link Here
31
31
32
use C4::Context;
32
use C4::Context;
33
use C4::Circulation;
33
use C4::Circulation;
34
use C4::Dates;
35
use Date::Calc qw(
34
use Date::Calc qw(
36
  Today
35
  Today
37
  Add_Delta_Days
36
  Add_Delta_Days
(-)a/misc/cronjobs/cleanup_database.pl (-1 lines)
Lines 35-41 BEGIN { Link Here
35
}
35
}
36
36
37
use C4::Context;
37
use C4::Context;
38
use C4::Dates;
39
use C4::Search;
38
use C4::Search;
40
use C4::Search::History;
39
use C4::Search::History;
41
use Getopt::Long;
40
use Getopt::Long;
(-)a/misc/cronjobs/gather_print_notices.pl (-6 / +7 lines)
Lines 11-17 BEGIN { Link Here
11
11
12
use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
12
use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
13
use C4::Context;
13
use C4::Context;
14
use C4::Dates;
15
use C4::Debug;
14
use C4::Debug;
16
use C4::Letters;
15
use C4::Letters;
17
use C4::Templates;
16
use C4::Templates;
Lines 82-88 $delimiter ||= q|,|; Link Here
82
81
83
cronlogaction();
82
cronlogaction();
84
83
85
my $today        = C4::Dates->new();
84
my $today_iso     = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ;
85
my $today_syspref = output_pref( { dt => dt_from_string, dateonly => 1 } );
86
86
my @all_messages = @{ GetPrintMessages() };
87
my @all_messages = @{ GetPrintMessages() };
87
88
88
# Filter by letter_code
89
# Filter by letter_code
Lines 166-173 sub print_notices { Link Here
166
    while ( my ( $branchcode, $branch_messages ) = each %$messages_by_branch ) {
167
    while ( my ( $branchcode, $branch_messages ) = each %$messages_by_branch ) {
167
        my $letter_codes = @letter_codes == 0 ? 'all' : join '_', @letter_codes;
168
        my $letter_codes = @letter_codes == 0 ? 'all' : join '_', @letter_codes;
168
        my $filename = $split
169
        my $filename = $split
169
            ? "notices_$letter_codes-" . $today->output('iso') . "-$branchcode.$format"
170
            ? "notices_$letter_codes-" . $today_iso . "-$branchcode.$format"
170
            : "notices_$letter_codes-" . $today->output('iso') . ".$format";
171
            : "notices_$letter_codes-" . $today_iso . ".$format";
171
        my $filepath = File::Spec->catdir( $output_directory, $filename );
172
        my $filepath = File::Spec->catdir( $output_directory, $filename );
172
        if ( $format eq 'html' ) {
173
        if ( $format eq 'html' ) {
173
            generate_html({
174
            generate_html({
Lines 212-218 sub generate_html { Link Here
212
213
213
    $template->param(
214
    $template->param(
214
        stylesheet => C4::Context->preference("NoticeCSS"),
215
        stylesheet => C4::Context->preference("NoticeCSS"),
215
        today      => $today->output(),
216
        today      => $today_syspref,
216
        messages   => $messages,
217
        messages   => $messages,
217
    );
218
    );
218
219
Lines 310-316 sub send_files { Link Here
310
    my $mail = MIME::Lite->new(
311
    my $mail = MIME::Lite->new(
311
        From     => $from,
312
        From     => $from,
312
        To       => $to,
313
        To       => $to,
313
        Subject  => 'Print notices for ' . $today->output(),
314
        Subject  => 'Print notices for ' . $today_syspref,
314
        Type     => 'multipart/mixed',
315
        Type     => 'multipart/mixed',
315
    );
316
    );
316
317
(-)a/misc/cronjobs/overdue_notices.pl (-5 / +7 lines)
Lines 38-44 use DateTime; Link Here
38
use DateTime::Duration;
38
use DateTime::Duration;
39
39
40
use C4::Context;
40
use C4::Context;
41
use C4::Dates qw/format_date/;
42
use C4::Debug;
41
use C4::Debug;
43
use C4::Letters;
42
use C4::Letters;
44
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
43
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
Lines 527-533 END_SQL Link Here
527
            my $borrowernumber;
526
            my $borrowernumber;
528
            while ( my $data = $sth->fetchrow_hashref ) {
527
            while ( my $data = $sth->fetchrow_hashref ) {
529
528
530
                next unless ( DateTime->compare( $date_to_run,  dt_from_string($data->{date_due})) ) == 1;
529
                next unless ( DateTime->compare( $date_to_run, dt_from_string($data->{date_due})) ) == 1;
531
530
532
                # check the borrower has at least one item that matches
531
                # check the borrower has at least one item that matches
533
                my $days_between;
532
                my $days_between;
Lines 536-547 END_SQL Link Here
536
                    my $calendar =
535
                    my $calendar =
537
                      Koha::Calendar->new( branchcode => $branchcode );
536
                      Koha::Calendar->new( branchcode => $branchcode );
538
                    $days_between =
537
                    $days_between =
539
                      $calendar->days_between(  dt_from_string($data->{date_due}),
538
                      $calendar->days_between( dt_from_string($data->{date_due}),
540
                        $date_to_run );
539
                        $date_to_run );
541
                }
540
                }
542
                else {
541
                else {
543
                    $days_between =
542
                    $days_between =
544
                      $date_to_run->delta_days(  dt_from_string($data->{date_due}) );
543
                      $date_to_run->delta_days( dt_from_string($data->{date_due}) );
545
                }
544
                }
546
                $days_between = $days_between->in_units('days');
545
                $days_between = $days_between->in_units('days');
547
                if ($triggered) {
546
                if ($triggered) {
Lines 657-663 END_SQL Link Here
657
                      last;
656
                      last;
658
                    }
657
                    }
659
                    $j++;
658
                    $j++;
660
                    my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields;
659
                    my @item_info = map { $_ =~ /^date|date$/ ?
660
                                           eval { output_pref( { dt => dt_from_string( $item_info->{$_} ), dateonly => 1 } ); }
661
                                           :
662
                                           $item_info->{$_} || '' } @item_content_fields;
661
                    $titles .= join("\t", @item_info) . "\n";
663
                    $titles .= join("\t", @item_info) . "\n";
662
                    $itemcount++;
664
                    $itemcount++;
663
                    push @items, $item_info;
665
                    push @items, $item_info;
(-)a/misc/cronjobs/serialsUpdate.pl (-2 / +2 lines)
Lines 29-38 BEGIN { Link Here
29
}
29
}
30
30
31
use C4::Context;
31
use C4::Context;
32
use C4::Dates qw/format_date format_date_in_iso/;
33
use C4::Debug;
32
use C4::Debug;
34
use C4::Serials;
33
use C4::Serials;
35
use C4::Log;
34
use C4::Log;
35
use Koha::DateUtils;
36
36
37
use Date::Calc qw/Date_to_Days check_date/;
37
use Date::Calc qw/Date_to_Days check_date/;
38
use Getopt::Long;
38
use Getopt::Long;
Lines 119-125 while ( my $issue = $sth->fetchrow_hashref ) { Link Here
119
119
120
    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
120
    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
121
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate );
121
        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate );
122
        my $today = format_date_in_iso( C4::Dates->new()->output() );
122
        my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
123
123
124
        if ( $nextpublisheddate && $today ) {
124
        if ( $nextpublisheddate && $today ) {
125
            my ( $year,  $month,  $day )  = split( /-/, $nextpublisheddate );
125
            my ( $year,  $month,  $day )  = split( /-/, $nextpublisheddate );
(-)a/misc/cronjobs/staticfines.pl (-8 / +7 lines)
Lines 103-109 foreach (@pcategories) { Link Here
103
}
103
}
104
104
105
use vars qw(@borrower_fields @item_fields @other_fields);
105
use vars qw(@borrower_fields @item_fields @other_fields);
106
use vars qw($fldir $libname $control $mode $delim $dbname $today $today_iso $today_days);
106
use vars qw($fldir $libname $control $mode $delim $dbname $today_iso $today_days);
107
use vars qw($filename);
107
use vars qw($filename);
108
108
109
CHECK {
109
CHECK {
Lines 135-142 if (defined $borrowernumberlimit) { Link Here
135
}
135
}
136
my $overdueItemsCounted = 0;
136
my $overdueItemsCounted = 0;
137
my %calendars           = ();
137
my %calendars           = ();
138
$today      = C4::Dates->new();
138
$today_iso  = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
139
$today_iso  = $today->output('iso');
140
my ($tyear, $tmonth, $tday) = split( /-/, $today_iso );
139
my ($tyear, $tmonth, $tday) = split( /-/, $today_iso );
141
$today_days = Date_to_Days( $tyear, $tmonth, $tday );
140
$today_days = Date_to_Days( $tyear, $tmonth, $tday );
142
141
Lines 145-158 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
145
    my $datedue;
144
    my $datedue;
146
    my $datedue_days;
145
    my $datedue_days;
147
    eval {
146
    eval {
148
    $datedue = C4::Dates->new( $data->[$i]->{'date_due'}, 'iso' );
147
    $datedue = eval { output_pref( { dt => dt_from_string( $data->[$i]->{'date_due'} ), dateonly => 1, dateformat => 'iso' } ); };
149
    $datedue_days = Date_to_Days( split( /-/, $datedue->output('iso') ) );
148
    $datedue_days = Date_to_Days( split( /-/, $datedue ) );
150
    };
149
    };
151
    if ($@) {
150
    if ($@) {
152
    warn "Error on date for borrower " . $data->[$i]->{'borrowernumber'} .  ": $@date_due: " . $data->[$i]->{'date_due'} . "\ndatedue_days: " . $datedue_days . "\nSkipping";
151
    warn "Error on date for borrower " . $data->[$i]->{'borrowernumber'} .  ": $@date_due: " . $data->[$i]->{'date_due'} . "\ndatedue_days: " . $datedue_days . "\nSkipping";
153
    next;
152
    next;
154
    }
153
    }
155
    my $due_str = $datedue->output();
154
    my $due_str = eval { output_pref( { dt => dt_from_string( $datedue ), dateonly => 1 } ); };
156
    unless ( defined $data->[$i]->{'borrowernumber'} ) {
155
    unless ( defined $data->[$i]->{'borrowernumber'} ) {
157
        print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL.  Repair 'issues' table now!  Skipping record.\n";
156
        print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL.  Repair 'issues' table now!  Skipping record.\n";
158
        next;    # Note: this doesn't solve everything.  After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up.
157
        next;    # Note: this doesn't solve everything.  After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up.
Lines 192-199 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
192
        $data->[$i],
191
        $data->[$i],
193
        $borrower->{'categorycode'},
192
        $borrower->{'categorycode'},
194
        $branchcode,
193
        $branchcode,
195
        dt_from_string($datedue->output('iso')),
194
        dt_from_string( $datedue ),
196
        dt_from_string($today->output('iso')),
195
        dt_from_string( $today_iso ),
197
    );
196
    );
198
197
199
    # Reassign fine's amount if specified in command-line
198
    # Reassign fine's amount if specified in command-line
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (-4 / +3 lines)
Lines 36-43 use C4::Context; Link Here
36
use C4::Items;
36
use C4::Items;
37
use C4::Letters;
37
use C4::Letters;
38
use C4::Overdues;
38
use C4::Overdues;
39
use C4::Dates;
40
use C4::Calendar;
39
use C4::Calendar;
40
use Koha::DateUtils;
41
41
42
sub usage {
42
sub usage {
43
    pod2usage( -verbose => 2 );
43
    pod2usage( -verbose => 2 );
Lines 124-131 foreach my $type (@types) { Link Here
124
    }
124
    }
125
125
126
    foreach my $issues (@loop) {
126
    foreach my $issues (@loop) {
127
        my $date = C4::Dates->new( $issues->{'date_due'}, 'iso' );
127
        my $date_dt = dt_from_string ( $issues->{'date_due'} );
128
        my $due_date = $date->output('metric');
128
        my $due_date = output_pref( { dt => $date_dt, dateonly => 1, dateformat =>'metric' } );
129
129
130
        my $letter = C4::Letters::GetPreparedLetter(
130
        my $letter = C4::Letters::GetPreparedLetter(
131
            module      => $module,
131
            module      => $module,
132
- 

Return to bug 14960