Bugzilla – Attachment 27017 Details for
Bug 11598
Add --text option to overdue_notices similar to --html option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11598 - Add --text option to overdue_notices similar to --html option
Bug-11598---Add---text-option-to-overduenotices-si.patch (text/plain), 5.99 KB, created by
Jonathan Druart
on 2014-04-11 12:59:12 UTC
(
hide
)
Description:
Bug 11598 - Add --text option to overdue_notices similar to --html option
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-04-11 12:59:12 UTC
Size:
5.99 KB
patch
obsolete
>From 84b1cd31adcf70f4142ef3502c239d80cc914ff5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 22 Jan 2014 09:50:16 -0500 >Subject: [PATCH] Bug 11598 - Add --text option to overdue_notices similar to > --html option > >We have a number of reports of libraries that were upset by Bug 10720 >being fixed! These libraries preferred this single file output, but as >text only. We should bring back this behavior, but as a feature, not a >bug. > >Test Plan: >1) Apply this patch >2) Run overdue_notices.pl --html >3) Note the output is wrapped in html tags >4) Run overdue_notices.pl --text >5) Note the same output, but not wrapped in html tags > >Signed-off-by: wajasu <matted-34813@mypacks.net> >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >To test, add the -n parameter. >The filename generation could be refactored but not blocker. >--- > misc/cronjobs/overdue_notices.pl | 62 ++++++++++++++++++++++++++------------ > 1 file changed, 43 insertions(+), 19 deletions(-) > >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 7e83d45..7d3ad6c 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -64,6 +64,7 @@ overdue_notices.pl > -library <branchname> only deal with overdues from this library (repeatable : several libraries can be given) > -csv <filename> populate CSV file > -html <directory> Output html to a file in the given directory >+ -text <directory> Output plain text to a file in the given directory > -itemscontent <list of fields> item information in templates > -borcat <categorycode> category code that must be included > -borcatout <categorycode> category code that must be excluded >@@ -119,6 +120,14 @@ directory. This can be downloaded or futher processed by library staff. > The file will be called notices-YYYY-MM-DD.html and placed in the directory > specified. > >+=item B<-text> >+ >+Produces plain text data. if patron does not have a mail address or >+-n (no mail) flag is set, a text file is generated in the specified >+directory. This can be downloaded or futher processed by library staff. >+The file will be called notices-YYYY-MM-DD.txt and placed in the directory >+specified. >+ > =item B<-itemscontent> > > comma separated list of fields that get substituted into templates in >@@ -274,6 +283,7 @@ my @emails_to_use; # Emails to use for messaging > my @emails; # Emails given in command-line parameters > my $csvfilename; > my $htmlfilename; >+my $text_filename; > my $triggered = 0; > my $listall = 0; > my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) ); >@@ -290,6 +300,7 @@ GetOptions( > 'library=s' => \@branchcodes, > 'csv:s' => \$csvfilename, # this optional argument gets '' if not supplied. > 'html:s' => \$htmlfilename, # this optional argument gets '' if not supplied. >+ 'text:s' => \$text_filename, # this optional argument gets '' if not supplied. > 'itemscontent=s' => \$itemscontent, > 'list-all' => \$listall, > 't|triggered' => \$triggered, >@@ -375,26 +386,34 @@ if ( defined $csvfilename ) { > } > > @branches = @overduebranches unless @branches; >-our $html_fh; >+our $fh; > if ( defined $htmlfilename ) { > if ( $htmlfilename eq '' ) { >- $html_fh = *STDOUT; >+ $fh = *STDOUT; > } else { > my $today = DateTime->now(time_zone => C4::Context->tz ); >- open $html_fh, ">",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html"); >+ open $fh, ">",File::Spec->catdir ($htmlfilename,"notices-".$today->ymd().".html"); > } > >- print $html_fh "<html>\n"; >- print $html_fh "<head>\n"; >- print $html_fh "<style type='text/css'>\n"; >- print $html_fh "pre {page-break-after: always;}\n"; >- print $html_fh "pre {white-space: pre-wrap;}\n"; >- print $html_fh "pre {white-space: -moz-pre-wrap;}\n"; >- print $html_fh "pre {white-space: -o-pre-wrap;}\n"; >- print $html_fh "pre {word-wrap: break-work;}\n"; >- print $html_fh "</style>\n"; >- print $html_fh "</head>\n"; >- print $html_fh "<body>\n"; >+ print $fh "<html>\n"; >+ print $fh "<head>\n"; >+ print $fh "<style type='text/css'>\n"; >+ print $fh "pre {page-break-after: always;}\n"; >+ print $fh "pre {white-space: pre-wrap;}\n"; >+ print $fh "pre {white-space: -moz-pre-wrap;}\n"; >+ print $fh "pre {white-space: -o-pre-wrap;}\n"; >+ print $fh "pre {word-wrap: break-work;}\n"; >+ print $fh "</style>\n"; >+ print $fh "</head>\n"; >+ print $fh "<body>\n"; >+} >+elsif ( defined $text_filename ) { >+ if ( $text_filename eq '' ) { >+ $fh = *STDOUT; >+ } else { >+ my $today = DateTime->now(time_zone => C4::Context->tz ); >+ open $fh, ">",File::Spec->catdir ($text_filename,"notices-".$today->ymd().".txt"); >+ } > } > > foreach my $branchcode (@branches) { >@@ -606,7 +625,7 @@ END_SQL > email => $notice_email, > itemcount => $itemcount, > titles => $titles, >- outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '', >+ outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : defined $text_filename ? 'text' : '', > } > ); > } >@@ -620,7 +639,10 @@ END_SQL > print $csv_fh @output_chunks; > } > elsif ( defined $htmlfilename ) { >- print $html_fh @output_chunks; >+ print $fh @output_chunks; >+ } >+ elsif ( defined $text_filename ) { >+ print $fh @output_chunks; > } > elsif ($nomail){ > local $, = "\f"; # pagebreak >@@ -665,9 +687,11 @@ if ($csvfilename) { > } > > if ( defined $htmlfilename ) { >- print $html_fh "</body>\n"; >- print $html_fh "</html>\n"; >- close $html_fh; >+ print $fh "</body>\n"; >+ print $fh "</html>\n"; >+ close $fh; >+} elsif ( defined $text_filename ) { >+ close $fh; > } > > =head1 INTERNAL METHODS >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11598
:
24609
|
25668
| 27017