Bugzilla – Attachment 118486 Details for
Bug 26734
Convert accounts (monetary) notices to use GetPreparedLetter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26734: (follow-up) Replace db update with backup and default
Bug-26734-follow-up-Replace-db-update-with-backup-.patch (text/plain), 8.86 KB, created by
Marcel de Rooy
on 2021-03-19 07:25:59 UTC
(
hide
)
Description:
Bug 26734: (follow-up) Replace db update with backup and default
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-03-19 07:25:59 UTC
Size:
8.86 KB
patch
obsolete
>From 5dcf70186ae17eb4b10901907785a41fb571a20e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 3 Feb 2021 14:49:04 +0000 >Subject: [PATCH] Bug 26734: (follow-up) Replace db update with backup and > default >Content-Type: text/plain; charset=utf-8 > >The inline update of variable for the notice template was proving >troublesome.. this patch replaces it was a backup of the existing notice >followed by replacing the notice with the default. > >Test plan >1/ Run the database update >2/ Check that the templates have been replaced by the defaults (for all >languages enabled) >3/ Check that a backup of the original notices was made by naviagating >to view the action log (/tools/viewlog.pl) and selecting 'all modules' + >'all actions' > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > installer/data/mysql/atomicupdate/bug_26734.perl | 184 ++++++++++++++++++----- > 1 file changed, 145 insertions(+), 39 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_26734.perl b/installer/data/mysql/atomicupdate/bug_26734.perl >index 5ff88aaa87..faabb6b91b 100644 >--- a/installer/data/mysql/atomicupdate/bug_26734.perl >+++ b/installer/data/mysql/atomicupdate/bug_26734.perl >@@ -1,45 +1,151 @@ > $DBversion = 'XXX'; >-if( CheckVersion( $DBversion ) ) { >+if ( CheckVersion($DBversion) ) { > > # ACCOUNT_CREDIT UPDATES >- # replace patron variable with credit.patron >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% credit.patron') WHERE code = 'ACCOUNT_CREDIT' "); >- # replace library variable with credit.library.branchname >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% credit.library.branchname') WHERE code = 'ACCOUNT_CREDIT' "); >- >- # replace offsets variable with credit.offsets >- $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' credit.offsets %]') WHERE code = 'ACCOUNT_CREDIT' "); >- # replace change_given variable with change >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% change_given', '[% change') WHERE code = 'ACCOUNT_CREDIT' "); >- >- # replace accounts foreach with basic check >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% FOREACH account IN accounts %]', '[% IF credit %]') WHERE code = 'ACCOUNT_CREDIT' "); >- # replace account with credit >- $dbh->do("UPDATE letter SET content = REPLACE(content, 'account.', 'credit.') WHERE code = 'ACCOUNT_CREDIT' "); >- # replace amountcredit with amount >= 0 >- $dbh->do("UPDATE letter SET content = REPLACE(content, '( credit.amountcredit )', '( credit.amount <= 0 )') WHERE code = 'ACCOUNT_CREDIT' "); >+ # backup existing notice to action_logs >+ my $credit_arr = $dbh->selectall_arrayref( >+ "SELECT lang FROM letter WHERE code = 'ACCOUNT_CREDIT'", { Slice => {} }); >+ my $c_sth = $dbh->prepare(q{ >+ INSERT INTO action_logs ( timestamp, module, action, object, info, interface ) >+ SELECT NOW(), 'NOTICES', 'UPGRADE', id, content, 'cli' >+ FROM letter >+ WHERE lang = ? AND code = 'ACCOUNT_CREDIT' >+ }); >+ >+ for my $c ( @{$credit_arr} ) { >+ $c_sth->execute( $c->{lang} ); >+ } >+ >+ # replace notice with default >+ my $c_notice = q{ >+[% USE Price %] >+[% PROCESS 'accounts.inc' %] >+<table> >+[% IF ( LibraryName ) %] >+ <tr> >+ <th colspan="4" class="centerednames"> >+ <h3>[% LibraryName | html %]</h3> >+ </th> >+ </tr> >+[% END %] >+ <tr> >+ <th colspan="4" class="centerednames"> >+ <h2><u>Fee receipt</u></h2> >+ </th> >+ </tr> >+ <tr> >+ <th colspan="4" class="centerednames"> >+ <h2>[% Branches.GetName( credit.patron.branchcode ) | html %]</h2> >+ </th> >+ </tr> >+ <tr> >+ <th colspan="4"> >+ Received with thanks from [% credit.patron.firstname | html %] [% credit.patron.surname | html %] <br /> >+ Card number: [% credit.patron.cardnumber | html %]<br /> >+ </th> >+ </tr> >+ <tr> >+ <th>Date</th> >+ <th>Description of charges</th> >+ <th>Note</th> >+ <th>Amount</th> >+ </tr> >+ >+ <tr class="highlight"> >+ <td>[% credit.date | $KohaDates %]</td> >+ <td> >+ [% PROCESS account_type_description account=credit %] >+ [%- IF credit.description %], [% credit.description | html %][% END %] >+ </td> >+ <td>[% credit.note | html %]</td> >+ <td class="credit">[% credit.amount | $Price %]</td> >+ </tr> >+ >+<tfoot> >+ <tr> >+ <td colspan="3">Total outstanding dues as on date: </td> >+ [% IF ( credit.patron.account.balance >= 0 ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% credit.patron.account.balance | $Price %]</td> >+ </tr> >+</tfoot> >+</table> >+ }; >+ >+ my $c_insert = $dbh->prepare("UPDATE letter SET content = ?, is_html = 1 WHERE code = 'ACCOUNT_CREDIT'"); >+ $c_insert->execute($c_notice); > > # ACCOUNT_DEBIT UPDATES >- # replace patron variable with debit.patron >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% patron', '[% debit.patron') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace library variable with debit.library.branchname >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% library', '[% debit.library.branchname') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace offsets variable with debit.offsets >- $dbh->do("UPDATE letter SET content = REPLACE(content, ' offsets %]', ' debit.offsets %]') WHERE code = 'ACCOUNT_DEBIT' "); >- >- # replace accounts foreach with basic check >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% FOREACH account IN accounts %]', '[% IF debit %]') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace account with debit >- $dbh->do("UPDATE letter SET content = REPLACE(content, 'account.', 'debit.') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace amountcredit with amount >= 0 >- $dbh->do("UPDATE letter SET content = REPLACE(content, '( debit.amountcredit )', '( debit.amount <= 0 )') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace amountoutstandingcredit with amount >= 0 >- $dbh->do("UPDATE letter SET content = REPLACE(content, '( debit.amountoutstandingcredit )', '( debit.amountoutstanding <= 0 )') WHERE code = 'ACCOUNT_DEBIT' "); >- >- # replace total variable with debit.patron.account.balance >- $dbh->do("UPDATE letter SET content = REPLACE(content, '[% total ', '[% debit.patron.account.balance ') WHERE code = 'ACCOUNT_DEBIT' "); >- # replace totalcredit variable with debit.patron.account.balance <= 0 >- $dbh->do("UPDATE letter SET content = REPLACE(content, 'totalcredit', 'debit.patron.account.balance <= 0') WHERE code = 'ACCOUNT_DEBIT' "); >- >- NewVersion( $DBversion, 26734, "Update notices to use standard variables"); >+ # backup existing notice to action_logs >+ my $debit_arr = $dbh->selectall_arrayref( >+ "SELECT lang FROM letter WHERE code = 'ACCOUNT_DEBIT'", { Slice => {} }); >+ my $d_sth = $dbh->prepare(q{ >+ INSERT INTO action_logs ( timestamp, module, action, object, info, interface ) >+ SELECT NOW(), 'NOTICES', 'UPGRADE', id, content, 'cli' >+ FROM letter >+ WHERE lang = ? AND code = 'ACCOUNT_DEBIT' >+ }); >+ >+ for my $d ( @{$debit_arr} ) { >+ $d_sth->execute( $d->{lang} ); >+ } >+ >+ # replace notice with default >+ my $d_notice = q{ >+[% USE Price %] >+[% PROCESS 'accounts.inc' %] >+<table> >+ [% IF ( LibraryName ) %] >+ <tr> >+ <th colspan="5" class="centerednames"> >+ <h3>[% LibraryName | html %]</h3> >+ </th> >+ </tr> >+ [% END %] >+ >+ <tr> >+ <th colspan="5" class="centerednames"> >+ <h2><u>INVOICE</u></h2> >+ </th> >+ </tr> >+ <tr> >+ <th colspan="5" class="centerednames"> >+ <h2>[% Branches.GetName( debit.patron.branchcode ) | html %]</h2> >+ </th> >+ </tr> >+ <tr> >+ <th colspan="5" > >+ Bill to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %] <br /> >+ Card number: [% debit.patron.cardnumber | html %]<br /> >+ </th> >+ </tr> >+ <tr> >+ <th>Date</th> >+ <th>Description of charges</th> >+ <th>Note</th> >+ <th style="text-align:right;">Amount</th> >+ <th style="text-align:right;">Amount outstanding</th> >+ </tr> >+ >+ <tr class="highlight"> >+ <td>[% debit.date | $KohaDates%]</td> >+ <td> >+ [% PROCESS account_type_description account=debit %] >+ [%- IF debit.description %], [% debit.description | html %][% END %] >+ </td> >+ <td>[% debit.note | html %]</td> >+ <td class="debit">[% debit.amount | $Price %]</td> >+ <td class="debit">[% debit.amountoutstanding | $Price %]</td> >+ </tr> >+ >+ <tfoot> >+ <tr> >+ <td colspan="4">Total outstanding dues as on date: </td> >+ [% IF ( debit.patron.account.balance <= 0 ) %]<td class="credit">[% ELSE %]<td class="debit">[% END %][% debit.patron.account.balance | $Price %]</td> >+ </tr> >+ </tfoot> >+</table> >+ }; >+ my $d_insert = $dbh->prepare("UPDATE letter SET content = ?, is_html = 1 WHERE code = 'ACCOUNT_DEBIT'"); >+ $d_insert->execute($d_notice); >+ >+ NewVersion( $DBversion, 26734, "Update notices to use defaults" ); > } >-- >2.11.0
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 26734
:
111976
|
111977
|
111978
|
112023
|
112024
|
112025
|
112026
|
116257
|
116259
|
116260
|
116261
|
116262
|
116263
|
116272
|
116275
|
116276
|
116277
|
116278
|
116279
|
116644
|
116645
|
116646
|
116647
|
116648
|
116655
|
116656
|
116657
|
116658
|
116659
|
116663
|
116664
|
116665
|
116666
|
116667
|
117261
|
117262
|
117263
|
117264
|
117265
|
118191
|
118192
|
118193
|
118194
|
118195
|
118196
|
118197
|
118200
|
118482
|
118483
|
118484
|
118485
|
118486
|
118487
|
118488
|
118489
|
119350
|
119351
|
119352
|
119353
|
119354
|
119355
|
119356
|
119357
|
119358
|
119642
|
120077
|
121446
|
121449