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

(-)a/misc/cronjobs/overdue_notices.pl (-20 / +43 lines)
Lines 64-69 overdue_notices.pl Link Here
64
   -library      <branchname>     only deal with overdues from this library (repeatable : several libraries can be given)
64
   -library      <branchname>     only deal with overdues from this library (repeatable : several libraries can be given)
65
   -csv          <filename>       populate CSV file
65
   -csv          <filename>       populate CSV file
66
   -html         <directory>      Output html to a file in the given directory
66
   -html         <directory>      Output html to a file in the given directory
67
   -text         <directory>      Output plain text to a file in the given directory
67
   -itemscontent <list of fields> item information in templates
68
   -itemscontent <list of fields> item information in templates
68
   -borcat       <categorycode>   category code that must be included
69
   -borcat       <categorycode>   category code that must be included
69
   -borcatout    <categorycode>   category code that must be excluded
70
   -borcatout    <categorycode>   category code that must be excluded
Lines 119-124 directory. This can be downloaded or futher processed by library staff. Link Here
119
The file will be called notices-YYYY-MM-DD.html and placed in the directory
120
The file will be called notices-YYYY-MM-DD.html and placed in the directory
120
specified.
121
specified.
121
122
123
=item B<-text>
124
125
Produces plain text data. if patron does not have a mail address or
126
-n (no mail) flag is set, a text file is generated in the specified
127
directory. This can be downloaded or futher processed by library staff.
128
The file will be called notices-YYYY-MM-DD.txt and placed in the directory
129
specified.
130
122
=item B<-itemscontent>
131
=item B<-itemscontent>
123
132
124
comma separated list of fields that get substituted into templates in
133
comma separated list of fields that get substituted into templates in
Lines 274-279 my @emails_to_use; # Emails to use for messaging Link Here
274
my @emails;           # Emails given in command-line parameters
283
my @emails;           # Emails given in command-line parameters
275
my $csvfilename;
284
my $csvfilename;
276
my $htmlfilename;
285
my $htmlfilename;
286
my $text_filename;
277
my $triggered = 0;
287
my $triggered = 0;
278
my $listall = 0;
288
my $listall = 0;
279
my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) );
289
my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) );
Lines 290-295 GetOptions( Link Here
290
    'library=s'      => \@branchcodes,
300
    'library=s'      => \@branchcodes,
291
    'csv:s'          => \$csvfilename,    # this optional argument gets '' if not supplied.
301
    'csv:s'          => \$csvfilename,    # this optional argument gets '' if not supplied.
292
    'html:s'         => \$htmlfilename,    # this optional argument gets '' if not supplied.
302
    'html:s'         => \$htmlfilename,    # this optional argument gets '' if not supplied.
303
    'text:s'         => \$text_filename,    # this optional argument gets '' if not supplied.
293
    'itemscontent=s' => \$itemscontent,
304
    'itemscontent=s' => \$itemscontent,
294
    'list-all'       => \$listall,
305
    'list-all'       => \$listall,
295
    't|triggered'    => \$triggered,
306
    't|triggered'    => \$triggered,
Lines 375-400 if ( defined $csvfilename ) { Link Here
375
}
386
}
376
387
377
@branches = @overduebranches unless @branches;
388
@branches = @overduebranches unless @branches;
378
our $html_fh;
389
our $fh;
379
if ( defined $htmlfilename ) {
390
if ( defined $htmlfilename ) {
380
  if ( $htmlfilename eq '' ) {
391
  if ( $htmlfilename eq '' ) {
381
    $html_fh = *STDOUT;
392
    $fh = *STDOUT;
382
  } else {
393
  } else {
383
    my $today = DateTime->now(time_zone => C4::Context->tz );
394
    my $today = DateTime->now(time_zone => C4::Context->tz );
384
    open $html_fh, ">",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
395
    open $fh, ">",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html");
385
  }
396
  }
386
  
397
  
387
  print $html_fh "<html>\n";
398
  print $fh "<html>\n";
388
  print $html_fh "<head>\n";
399
  print $fh "<head>\n";
389
  print $html_fh "<style type='text/css'>\n";
400
  print $fh "<style type='text/css'>\n";
390
  print $html_fh "pre {page-break-after: always;}\n";
401
  print $fh "pre {page-break-after: always;}\n";
391
  print $html_fh "pre {white-space: pre-wrap;}\n";
402
  print $fh "pre {white-space: pre-wrap;}\n";
392
  print $html_fh "pre {white-space: -moz-pre-wrap;}\n";
403
  print $fh "pre {white-space: -moz-pre-wrap;}\n";
393
  print $html_fh "pre {white-space: -o-pre-wrap;}\n";
404
  print $fh "pre {white-space: -o-pre-wrap;}\n";
394
  print $html_fh "pre {word-wrap: break-work;}\n";
405
  print $fh "pre {word-wrap: break-work;}\n";
395
  print $html_fh "</style>\n";
406
  print $fh "</style>\n";
396
  print $html_fh "</head>\n";
407
  print $fh "</head>\n";
397
  print $html_fh "<body>\n";
408
  print $fh "<body>\n";
409
}
410
elsif ( defined $text_filename ) {
411
  if ( $text_filename eq '' ) {
412
    $fh = *STDOUT;
413
  } else {
414
    my $today = DateTime->now(time_zone => C4::Context->tz );
415
    open $fh, ">",File::Spec->catdir ($text_filename,"notices-".$today->ymd().".txt");
416
  }
398
}
417
}
399
418
400
foreach my $branchcode (@branches) {
419
foreach my $branchcode (@branches) {
Lines 606-612 END_SQL Link Here
606
                            email          => $notice_email,
625
                            email          => $notice_email,
607
                            itemcount      => $itemcount,
626
                            itemcount      => $itemcount,
608
                            titles         => $titles,
627
                            titles         => $titles,
609
                            outputformat   => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '',
628
                            outputformat   => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : defined $text_filename ? 'text' : '',
610
                        }
629
                        }
611
                      );
630
                      );
612
                }
631
                }
Lines 620-626 END_SQL Link Here
620
            print $csv_fh @output_chunks;        
639
            print $csv_fh @output_chunks;        
621
        }
640
        }
622
        elsif ( defined $htmlfilename ) {
641
        elsif ( defined $htmlfilename ) {
623
            print $html_fh @output_chunks;        
642
            print $fh @output_chunks;        
643
        }
644
        elsif ( defined $text_filename ) {
645
            print $fh @output_chunks;        
624
        }
646
        }
625
        elsif ($nomail){
647
        elsif ($nomail){
626
                local $, = "\f";    # pagebreak
648
                local $, = "\f";    # pagebreak
Lines 658-666 if ($csvfilename) { Link Here
658
}
680
}
659
681
660
if ( defined $htmlfilename ) {
682
if ( defined $htmlfilename ) {
661
  print $html_fh "</body>\n";
683
  print $fh "</body>\n";
662
  print $html_fh "</html>\n";
684
  print $fh "</html>\n";
663
  close $html_fh;
685
  close $fh;
686
} elsif ( defined $text_filename ) {
687
  close $fh;
664
}
688
}
665
689
666
=head1 INTERNAL METHODS
690
=head1 INTERNAL METHODS
667
- 

Return to bug 11598