@@ -, +, @@ default --- .../data/mysql/atomicupdate/bug_26734.perl | 178 ++++++++++++++---- 1 file changed, 139 insertions(+), 39 deletions(-) --- a/installer/data/mysql/atomicupdate/bug_26734.perl +++ a/installer/data/mysql/atomicupdate/bug_26734.perl @@ -1,45 +1,145 @@ $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( +"INSERT INTO action_logs ( timestamp, module, action, info, interface ) VALUES ( NOW(), 'NOTICES', ?, (SELECT content FROM letter WHERE lang = ? AND code = 'ACCOUNT_CREDIT' ), 'cli' )" + ); + + for my $c ( @{$credit_arr} ) { + $c_sth->execute( 'ACCOUNT_CREDIT_' . $c->{lang}, $c->{lang} ); + } + + # replace notice with default + my $c_notice = q{ +[% USE Price %] +[% PROCESS 'accounts.inc' %] +
+ [% LibraryName | html %]+ |
+ ||||
---|---|---|---|---|
+ Fee receipt+ |
+ ||||
+ [% Branches.GetName( credit.patron.branchcode ) | html %]+ |
+ ||||
+ Received with thanks from [% credit.patron.firstname | html %] [% credit.patron.surname | html %] + Card number: [% credit.patron.cardnumber | html %] + |
+ ||||
Date | +Description of charges | +Note | +Amount | +|
[% credit.date | $KohaDates %] | ++ [% PROCESS account_type_description account=credit %] + [%- IF credit.description %], [% credit.description | html %][% END %] + | +[% credit.note | html %] | +[% credit.amount | $Price %] | +|
Total outstanding dues as on date: | + [% IF ( credit.patron.account.balance >= 0 ) %][% ELSE %] | [% END %][% credit.patron.account.balance | $Price %] | +
+ [% LibraryName | html %]+ |
+ |||||
---|---|---|---|---|---|
+ INVOICE+ |
+ |||||
+ [% Branches.GetName( debit.patron.branchcode ) | html %]+ |
+ |||||
+ Bill to: [% debit.patron.firstname | html %] [% debit.patron.surname | html %] + Card number: [% debit.patron.cardnumber | html %] + |
+ |||||
Date | +Description of charges | +Note | +Amount | +Amount outstanding | +|
[% debit.date | $KohaDates%] | ++ [% PROCESS account_type_description account=debit %] + [%- IF debit.description %], [% debit.description | html %][% END %] + | +[% debit.note | html %] | +[% debit.amount | $Price %] | +[% debit.amountoutstanding | $Price %] | +|
Total outstanding dues as on date: | + [% IF ( debit.patron.account.balance <= 0 ) %][% ELSE %] | [% END %][% debit.patron.account.balance | $Price %] | +