Bugzilla – Attachment 55820 Details for
Bug 15969
Allow use of Template Toolkit syntax for Phone Notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15969 - Allow use of Template Toolkit syntax for Phone Notices
Bug-15969---Allow-use-of-Template-Toolkit-syntax-f.patch (text/plain), 8.99 KB, created by
Kyle M Hall (khall)
on 2016-09-26 11:13:58 UTC
(
hide
)
Description:
Bug 15969 - Allow use of Template Toolkit syntax for Phone Notices
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-09-26 11:13:58 UTC
Size:
8.99 KB
patch
obsolete
>From e3a3cf1c57dd18528cded54d1211faa7ea5d1ad5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 1 Mar 2016 16:34:02 +0000 >Subject: [PATCH] Bug 15969 - Allow use of Template Toolkit syntax for Phone > Notices > >By allowing the use of Template Toolkit for generating the outgoing >Talking Tech CSV files, we can give libaries more control over the data >they send to Itiva. This enhancement would also make it possible to use >the script for other services since the output is no longer fixed to a >single format. > >Test Plan: >1) Apply this patch >2) Set up a waiting hold, and overdue checkout, and a non-overdue checkout >3) Generate the CSV file via the script > misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >4) Enable Template Toolkit for the notices and update the notice text to be: >[% FILTER remove("\r\n") %] >"[% format %]", >"[% language %]", >"[% type %]", >"[% level %]", >"[% borrower.cardnumber %]", >"[% borrower.title %]", >"[% borrower.firstname %]", >"[% borrower.surname %]", >"[% borrower.phone %]", >"[% borrower.email %]", >"[% library_code %]", >"[% branch.id %]", >"[% branch.branchname %]", >"[% item.barcode %]", >"[% due_date %]", >"[% biblio.title %]", >"__MESSAGE_ID__" >[% END %] >5) Regenerate the notices >6) Compare the originals, note the format is the same > >Signed-off-by: Sean McGarvey <seanm@pascolibraries.org> >--- > C4/Letters.pm | 17 +++++++- > .../thirdparty/TalkingTech_itiva_outbound.pl | 50 ++++++++++++++++------ > 2 files changed, 52 insertions(+), 15 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 26f3e46..e85c41b 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -708,6 +708,7 @@ sub GetPreparedLetter { > { > content => $letter->{content}, > tables => $tables, >+ substitute => $substitute, > } > ); > >@@ -949,7 +950,16 @@ ENDSQL > $params->{'from_address'}, # from_address > $params->{'letter'}->{'content-type'}, # content_type > ); >- return $dbh->last_insert_id(undef,undef,'message_queue', undef); >+ >+ my $id = $dbh->last_insert_id(undef,undef,'message_queue', undef); >+ >+ $content = $params->{letter}->{content}; >+ if ( $content =~ /__MESSAGE_ID__/ ) { >+ $content =~ s/__MESSAGE_ID__/$id/g; >+ $dbh->do( "UPDATE message_queue SET content = ? WHERE message_id = ?", undef, ($content, $id) ); >+ } >+ >+ return $id; > } > > =head2 SendQueuedMessages ([$hashref]) >@@ -1374,6 +1384,7 @@ sub _process_tt { > > my $content = $params->{content}; > my $tables = $params->{tables}; >+ my $substitute = $params->{substitute}; > > my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE}; > my $template = Template->new( >@@ -1388,7 +1399,9 @@ sub _process_tt { > } > ) or die Template->error(); > >- my $tt_params = _get_tt_params( $tables ); >+ my $table_params = _get_tt_params( $tables ); >+ >+ my $tt_params = $substitute ? { %$substitute, %$table_params } : $table_params; > > my $output; > $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error(); >diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >index 1299b7d..7a4e158 100755 >--- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >+++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl >@@ -57,6 +57,7 @@ my @holds_waiting_days_to_call; > my $library_code; > my $help; > my $outfile; >+my $use_tt; > > # maps to convert I-tiva terms to Koha terms > my $type_module_map = { >@@ -73,12 +74,13 @@ my $type_notice_map = { > > GetOptions( > 'o|output:s' => \$outfile, >- 'v' => \$verbose, >- 'lang:s' => \$language, >- 'type:s' => \@types, >+ 'v|verbose' => \$verbose, >+ 'l|lang:s' => \$language, >+ 't|type:s' => \@types, > 'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, > 'c|code|library-code:s' => \$library_code, >- 'help|h' => \$help, >+ 'tt|template-toolkit' => \$use_tt, >+ 'h|help' => \$help, > ); > > $language = uc($language); >@@ -124,9 +126,20 @@ foreach my $type (@types) { > module => $module, > letter_code => $code, > tables => { >- borrowers => $issues->{'borrowernumber'}, >- biblio => $issues->{'biblionumber'}, >- biblioitems => $issues->{'biblionumber'}, >+ borrowers => $issues->{borrowernumber}, >+ biblio => $issues->{biblionumber}, >+ biblioitems => $issues->{biblionumber}, >+ items => $issues->{itemnumber}, >+ issues => $issues->{itemnumber}, >+ branches => $issues->{site}, >+ }, >+ substitute => { >+ format => $format, >+ language => $language, >+ type => $type, >+ level => $issues->{level}, >+ library_code => $library_code, >+ due_date => $due_date, > }, > message_transport_type => 'phone', > ); >@@ -143,9 +156,14 @@ foreach my $type (@types) { > ); > } > >- print $OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\","; >- print $OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\","; >- print $OUT "\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n"; >+ if ( $use_tt ) { >+ $letter->{content} =~ s/__MESSAGE_ID__/$message_id/g; >+ print $OUT $letter->{content}; >+ } else { >+ print $OUT "\"$format\",\"$language\",\"$type\",\"$issues->{level}\",\"$issues->{cardnumber}\",\"$issues->{patron_title}\",\"$issues->{firstname}\","; >+ print $OUT "\"$issues->{surname}\",\"$issues->{phone}\",\"$issues->{email}\",\"$library_code\","; >+ print $OUT "\"$issues->{site}\",\"$issues->{site_name}\",\"$issues->{barcode}\",\"$due_date\",\"$issues->{title}\",\"$message_id\"\n"; >+ } > } > } > >@@ -206,6 +224,12 @@ consortium purposes and apply library specific settings, such as > prompts, to those notices. > This field can be blank if all messages are from a single library. > >+=item B<--template-toolkit> >+ >+OPTIONAL. If set, processes the notice content as Template Toolkit syntax and sends the content as the CSV line instead >+of generated a fixed CSV line. This allows the contents of the CSV file to be created dynamically instead of using the >+fixed format that is outputted without this flag. >+ > =back > > =cut >@@ -214,7 +238,7 @@ sub GetOverdueIssues { > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, > max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3, >- issues.branchcode as site, branches.branchname as site_name >+ issues.branchcode as site, branches.branchname as site_name, items.itemnumber > FROM borrowers JOIN issues USING (borrowernumber) > JOIN items USING (itemnumber) > JOIN biblio USING (biblionumber) >@@ -248,7 +272,7 @@ sub GetOverdueIssues { > sub GetPredueIssues { > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, >- issues.branchcode as site, branches.branchname as site_name >+ issues.branchcode as site, branches.branchname as site_name, items.itemnumber > FROM borrowers JOIN issues USING (borrowernumber) > JOIN items USING (itemnumber) > JOIN biblio USING (biblionumber) >@@ -273,7 +297,7 @@ sub GetPredueIssues { > sub GetWaitingHolds { > my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, > borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, >- reserves.branchcode AS site, branches.branchname AS site_name, >+ reserves.branchcode AS site, branches.branchname AS site_name, items.itemnumber, > TO_DAYS(NOW())-TO_DAYS(reserves.waitingdate) AS days_since_waiting > FROM borrowers JOIN reserves USING (borrowernumber) > JOIN items USING (itemnumber) >-- >2.1.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 15969
:
48618
|
48811
|
55819
|
55820
|
57931
|
57933
|
57934
|
57935
|
59923
|
59924
|
59925
|
59926
|
59937
|
59940
|
59941
|
59942
|
59943
|
59944
|
59945
|
59962
|
59963
|
59964
|
59965
|
71141
|
71142
|
71143
|
71144
|
103181
|
103182
|
103183
|
103184
|
114413
|
114414
|
114415
|
114416
|
118207
|
118208
|
118209
|
118210