Bugzilla – Attachment 12700 Details for
Bug 6030
Allow for html in letters in overdue notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 6030 follow-up
Bug-6030-follow-up.patch (text/plain), 8.76 KB, created by
Kyle M Hall (khall)
on 2012-10-05 13:02:09 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 6030 follow-up
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2012-10-05 13:02:09 UTC
Size:
8.76 KB
patch
obsolete
>From a8043ec8790f9b9b4458a5014cebdf70f8873398 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Wed, 31 Aug 2011 16:11:39 +0200 >Subject: [PATCH] Bug 6030 follow-up >Content-Type: text/plain; charset="utf-8" > >Fixing problem detected previously: >* add column_def retrieval, to have header displaying the "explained" row name, not the table name. (the name is not expanded for CSV exports) >* removed some warnings. >* fixed some problems with csvfilename being defined/empty. Now, csvfilename is always defined, and set to '' by default. Some tests have been updated accordingly >* added the charset=UTF8 on mail headers. > >This patch also adds some missing columns to columns.def > >Signed-off-by: Sophie Meynieux <sophie.meynieux@biblibre.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > koha-tmpl/intranet-tmpl/prog/en/columns.def | 6 +++ > misc/cronjobs/overdue_notices.pl | 49 +++++++++++++++++++------- > 2 files changed, 42 insertions(+), 13 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/columns.def b/koha-tmpl/intranet-tmpl/prog/en/columns.def >index 726ecc6..f4be00a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/columns.def >+++ b/koha-tmpl/intranet-tmpl/prog/en/columns.def >@@ -66,6 +66,11 @@ borrowers.privacy Privacy settings > items.itemnumber Item number (internal) > items.biblionumber Biblio number (internal) > items.biblioitemnumber Biblioitem number (internal) >+issues.date_due Due date >+items.itemnumber Item Number (koha internal) >+items.biblionumber Biblio Number (koha internal) >+items.multivolumepart Item one part of a Multi volume set >+items.biblioitemnumber Biblioitem Number (koha internal) > items.barcode Barcode > items.dateaccessioned Date acquired > items.booksellerid Source of acquisition >@@ -112,6 +117,7 @@ statistics.itemnumber Item number > statistics.itemtype Itemtype > statistics.borrowernumber Borrower number > biblio.frameworkcode Framework code >+biblio.title Title > biblio.author Author > biblio.datecreated Creation date > biblio.timestamp Modification date >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index c386916..9f9b4bc 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -38,8 +38,10 @@ use Encode; > use C4::Context; > use C4::Dates qw/format_date/; > use C4::Debug; >+use C4::Charset; > use C4::Letters; > use C4::Overdues qw(GetFine); >+use C4::Reports::Guided; > > =head1 NAME > >@@ -256,7 +258,7 @@ my $verbose = 0; > my $nomail = 0; > my $MAX = 90; > my @branchcodes; # Branch(es) passed as parameter >-my $csvfilename; >+my $csvfilename = ''; > my $htmlfilename; > my $triggered = 0; > my $listall = 0; >@@ -284,7 +286,21 @@ GetOptions( > pod2usage(1) if $help; > pod2usage( -verbose => 2 ) if $man; > >-if ( defined $csvfilename && $csvfilename =~ /^-/ ) { >+my $columns_def_hashref = C4::Reports::Guided::_get_column_defs(); >+ >+# get column header definitions >+foreach my $key ( keys %$columns_def_hashref ) { >+ my $initkey = $key; >+ $key =~ s/[^\.]*\.//; >+ #warn "KEY : $initkey = ".$columns_def_hashref->{$initkey}; >+ if ($columns_def_hashref->{$initkey}) { >+ $columns_def_hashref->{$initkey}=NormalizeString($columns_def_hashref->{$initkey}); >+ $columns_def_hashref->{$initkey}=~s# #<br/>#; >+ } >+ $columns_def_hashref->{$key} = $columns_def_hashref->{$initkey}; >+} >+ >+if ( $csvfilename =~ /^-/ ) { > warn qq(using "$csvfilename" as filename, that seems odd); > } > >@@ -341,7 +357,7 @@ binmode( STDOUT, ':encoding(UTF-8)' ); > > our $csv; # the Text::CSV_XS object > our $csv_fh; # the filehandle to the CSV file. >-if ( defined $csvfilename ) { >+if ( $csvfilename ) { > my $sep_char = C4::Context->preference('delimiter') || ','; > $sep_char = "\t" if ($sep_char eq 'tabulation'); > $csv = Text::CSV_XS->new( { binary => 1 , sep_char => $sep_char } ); >@@ -350,7 +366,7 @@ if ( defined $csvfilename ) { > } else { > open $csv_fh, ">", $csvfilename or die "unable to open $csvfilename: $!"; > } >- if ( $csv->combine(qw(name surname address1 address2 zipcode city country email itemcount itemsinfo)) ) { >+ if ( $csvfilename && $csv->combine(qw(name surname address1 address2 zipcode city country email itemcount itemsinfo)) ) { > print $csv_fh $csv->string, "\n"; > } else { > $verbose and warn 'combine failed on argument: ' . $csv->error_input; >@@ -486,8 +502,8 @@ END_SQL > $verbose and warn "debarring $borrowernumber $firstname $lastname\n"; > } > my @params = ($listall ? ( $borrowernumber , 1 , $MAX ) : ( $borrowernumber, $mindays, $maxdays )); >- $verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber, mindays = $mindays, maxdays = $maxdays"; > $sth2->execute(@params); >+ $verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber, mindays = $mindays, maxdays = $maxdays returns ".$sth2->rows." rows"; > my $itemcount = 0; > my $titles; > if ($htmlfilename) { >@@ -506,10 +522,16 @@ END_SQL > } > $j++; > my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields; >- $titles .= join("\t", @item_info) . "\n"; >+ if ($htmlfilename) { >+ $titles .= "<tr><td>" . join( "</td><td>", @item_info ) . "</td></tr>"; >+ } else { >+ $titles .= join("\t", @item_info) . "\n"; >+ } > $itemcount++; > push @items, $item_info; > } >+ $titles .= "</tbody></table>" if ($htmlfilename); >+ $debug && warn $titles; > $sth2->finish; > > my $letter = parse_letter( >@@ -533,19 +555,19 @@ END_SQL > next PERIOD; > } > >- $letter->{'content-type'}="text/".($htmlfilename?"html":"plain"); >+ $letter->{'content-type'}="text/".($htmlfilename?"html":"plain")."; charset=UTF8"; > > if ($exceededPrintNoticesMaxLines) { > $letter->{'content'} .= "List too long for form; please check your account online for a complete list of your overdue items."; > } > >- my @misses = grep { /./ } map { /^([^>]*)[>]+/; ( $1 || '' ); } split /\</, $letter->{'content'}; >+ my @misses = grep { /./ } map { /^([^>]*)[>]{2,}/; ( $1 || '' ); } split /\<\</, $letter->{'content'}; > if (@misses) { > $verbose and warn "The following terms were not matched and replaced: \n\t" . join "\n\t", @misses; > } >- $letter->{'content'} =~ s/\<[^<>]*?\>//g; # Now that we've warned about them, remove them. >- $letter->{'content'} =~ s/\<[^<>]*?\>//g; # 2nd pass for the double nesting. >+ $letter->{'content'} =~ s/\<\<[^<>]*?\>\>//g; # Now that we've warned about them, remove them. > >+ # $letter->{'content'} =~ s/\<[^<>]*?\>//g; # 2nd pass for the double nesting. > if ($nomail) { > > push @output_chunks, >@@ -561,7 +583,7 @@ END_SQL > email => $email, > itemcount => $itemcount, > titles => $titles, >- outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '', >+ outputformat => $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '', > } > ); > } else { >@@ -589,7 +611,7 @@ END_SQL > email => $email, > itemcount => $itemcount, > titles => $titles, >- outputformat => defined $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '', >+ outputformat => $csvfilename ? 'csv' : defined $htmlfilename ? 'html' : '', > } > ); > } >@@ -600,7 +622,7 @@ END_SQL > } > > if (@output_chunks) { >- if ( defined $csvfilename ) { >+ if ( $csvfilename ) { > print $csv_fh @output_chunks; > } > elsif ( defined $htmlfilename ) { >@@ -760,6 +782,7 @@ sub prepare_letter_for_printing { > } > } elsif ( exists $params->{'outputformat'} && $params->{'outputformat'} eq 'html' ) { > $return = "<pre>\n"; >+ $params->{'letter'}->{'content'} =~ s# #<br/>#g; > $return .= "$params->{'letter'}->{'content'}\n"; > $return .= "\n</pre>\n"; > } else { >-- >1.7.2.5
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 6030
:
3596
|
5240
|
5241
|
6251
|
6252
|
12110
|
12111
|
12112
|
12113
|
12231
|
12232
|
12234
|
12235
|
12397
|
12698
|
12699
|
12700
|
12701
|
12772
|
13017
|
13018
|
14128
|
14129