Bugzilla – Attachment 11628 Details for
Bug 8378
<fine> syntax not working on overdues anymore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
0001-Bug-8378-fine-syntax-not-working-on-overdues-anymore
0001-Bug-8378-fine-syntax-not-working-on-overdues-anymore.patch (text/plain), 6.15 KB, created by
wajasu
on 2012-08-15 18:44:59 UTC
(
hide
)
Description:
0001-Bug-8378-fine-syntax-not-working-on-overdues-anymore
Filename:
MIME Type:
Creator:
wajasu
Created:
2012-08-15 18:44:59 UTC
Size:
6.15 KB
patch
obsolete
>From f75506d8e09c9b40fd2d50386a22674a883fcb13 Mon Sep 17 00:00:00 2001 >From: wajasu <matted-34813@mypacks.net> >Date: Wed, 15 Aug 2012 12:51:28 -0500 >Subject: [PATCH] Bug 8378 - <fine> syntax not working on overdues anymore >Content-Type: text/plain; charset="utf-8" > > >Signed-off-by: wajasu <matted-34813@mypacks.net> >--- > C4/Letters.pm | 80 ++++++++++++++++++++++++++++++++++++++++ > misc/cronjobs/overdue_notices.pl | 14 +++++-- > 2 files changed, 91 insertions(+), 3 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index b17cb08..4347d8b 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -116,6 +116,33 @@ sub GetLetters { > return \%letters; > } > >+=head2 GetLetter( %params ) >+ >+ retrieves the letter template >+ >+ %params hash: >+ module => letter module, mandatory >+ letter_code => letter code, mandatory >+ branchcode => for letter selection, if missing default system letter taken >+ Return value: >+ letter fields hashref (title & content useful) >+ >+=cut >+ >+sub GetLetter { >+ my %params = @_; >+ >+ my $module = $params{module} or croak "No module"; >+ my $letter_code = $params{letter_code} or croak "No letter_code"; >+ my $branchcode = $params{branchcode} || ''; >+ >+ my $letter = getletter( $module, $letter_code, $branchcode ) >+ or warn( "No $module $letter_code letter"), >+ return; >+ >+ return $letter; >+} >+ > my %letter; > sub getletter { > my ( $module, $code, $branchcode ) = @_; >@@ -409,6 +436,8 @@ sub SendAlerts { > > =head2 GetPreparedLetter( %params ) > >+ retrieves letter template and performs substituion processing >+ > %params hash: > module => letter module, mandatory > letter_code => letter code, mandatory >@@ -436,14 +465,65 @@ sub GetPreparedLetter { > my $module = $params{module} or croak "No module"; > my $letter_code = $params{letter_code} or croak "No letter_code"; > my $branchcode = $params{branchcode} || ''; >+ my $tables = $params{tables}; >+ my $substitute = $params{substitute}; >+ my $repeat = $params{repeat}; > > my $letter = getletter( $module, $letter_code, $branchcode ) > or warn( "No $module $letter_code letter"), > return; > >+ my $prepared_letter = GetProcessedLetter( >+ module => $module, >+ letter_code => $letter_code, >+ letter => $letter, >+ branchcode => $branchcode, >+ tables => $tables, >+ substitute => $substitute, >+ repeat => $repeat >+ ); >+ >+ return $prepared_letter; >+} >+ >+=head2 GetProcessedLetter( %params ) >+ >+ given a letter, with possible pre-processing do standard processing >+ allows one to perform letter template processing beforehand >+ >+ %params hash: >+ module => letter module, mandatory >+ letter_code => letter code, mandatory >+ letter => letter, mandatory >+ branchcode => for letter selection, if missing default system letter taken >+ tables => a hashref with table names as keys. Values are either: >+ - a scalar - primary key value >+ - an arrayref - primary key values >+ - a hashref - full record >+ substitute => custom substitution key/value pairs >+ repeat => records to be substituted on consecutive lines: >+ - an arrayref - tries to guess what needs substituting by >+ taking remaining << >> tokensr; not recommended >+ - a hashref token => @tables - replaces <token> << >> << >> </token> >+ subtemplate for each @tables row; table is a hashref as above >+ want_librarian => boolean, if set to true triggers librarian details >+ substitution from the userenv >+ Return value: >+ letter fields hashref (title & content useful) >+ >+=cut >+ >+sub GetProcessedLetter { >+ my %params = @_; >+ >+ my $module = $params{module} or croak "No module"; >+ my $letter_code = $params{letter_code} or croak "No letter_code"; >+ my $letter = $params{letter} or croak "No letter"; >+ my $branchcode = $params{branchcode} || ''; > my $tables = $params{tables}; > my $substitute = $params{substitute}; > my $repeat = $params{repeat}; >+ > $tables || $substitute || $repeat > or carp( "ERROR: nothing to substitute - both 'tables' and 'substitute' are empty" ), > return; >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 8c0bc12..eda80e3 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -432,6 +432,12 @@ END_SQL > next PERIOD; > } > >+ my $letter_template = C4::Letters::GetLetter ( >+ module => 'circulation', >+ letter_code => $overdue_rules->{"letter$i"}, >+ branchcode => $branchcode >+ ); >+ > # $letter->{'content'} is the text of the mail that is sent. > # this text contains fields that are replaced by their value. Those fields must be written between brackets > # The following fields are available : >@@ -503,6 +509,7 @@ END_SQL > > my $letter = parse_letter( > { letter_code => $overdue_rules->{"letter$i"}, >+ letter => $letter_template, > borrowernumber => $borrowernumber, > branchcode => $branchcode, > items => \@items, >@@ -671,7 +678,7 @@ sub parse_letter { > my $currency_format; > if ($params->{'letter'}->{'content'} =~ m/<fine>(.*)<\/fine>/o) { # process any fine tags... > $currency_format = $1; >- $params->{'letter'}->{'content'} =~ s/<fine>.*<\/fine>/<<item.fine>>/o; >+ $params->{'letter'}->{'content'} =~ s/<fine>.*<\/fine>/<<items.fine>>/o; > } > > my @item_tables; >@@ -696,13 +703,14 @@ sub parse_letter { > } > } > >- return C4::Letters::GetPreparedLetter ( >+ return C4::Letters::GetProcessedLetter ( > module => 'circulation', > letter_code => $params->{'letter_code'}, >+ letter => $params->{'letter'}, > branchcode => $params->{'branchcode'}, > tables => \%tables, > substitute => $substitute, >- repeat => { item => \@item_tables }, >+ repeat => { item => \@item_tables } > ); > } > >-- >1.7.11.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 8378
:
11628
|
11804
|
11805
|
11806
|
11906
|
12286
|
14069
|
16387
|
16388
|
16390
|
16407
|
16408
|
16513
|
16515
|
16518
|
16522
|
16528
|
16529
|
16530
|
16531