From 5a29be8a12f860507fab21f083e26252b45030f4 Mon Sep 17 00:00:00 2001 From: Guanhuan Chen Date: Mon, 7 Sep 2015 12:47:11 +0100 Subject: [PATCH] Setup upgrade script for default invoice msg template modification --- .../civicrm_msg_template.tpl | 16 + .../contribution_invoice_receipt_html.tpl | 434 ++++++++++++++++++ CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl | 3 + 3 files changed, 453 insertions(+) create mode 100644 CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl create mode 100644 CRM/Upgrade/4.6.9.msg_template/message_templates/contribution_invoice_receipt_html.tpl diff --git a/CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl new file mode 100644 index 0000000000..afe8784f36 --- /dev/null +++ b/CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl @@ -0,0 +1,16 @@ +{php} + $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.6.9.msg_template/message_templates'; + $templates = array(); + foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) { + $parts = explode('_', basename($filename, '.tpl')); + $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename"); + } + $this->assign('templates', $templates); +{/php} + +{foreach from=$templates item=tpl} + {fetch assign=content file=$tpl.filename} + SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}'; + SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1; + UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content)); +{/foreach} diff --git a/CRM/Upgrade/4.6.9.msg_template/message_templates/contribution_invoice_receipt_html.tpl b/CRM/Upgrade/4.6.9.msg_template/message_templates/contribution_invoice_receipt_html.tpl new file mode 100644 index 0000000000..e51ffe6bcb --- /dev/null +++ b/CRM/Upgrade/4.6.9.msg_template/message_templates/contribution_invoice_receipt_html.tpl @@ -0,0 +1,434 @@ + + + + + + + + + + + +
+
+ + + + + + + + + {if $organization_name} + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
INVOICEInvoice Date:{$domain_organization}
{$display_name} ({$organization_name}){$display_name}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 }{$domain_supplemental_address_1}{/if}
{$street_address} {$supplemental_address_1}Invoice Number:{if $domain_supplemental_address_2 }{$domain_supplemental_address_2}{/if} + {if $domain_state }{$domain_state}{/if}
{$supplemental_address_2} {$stateProvinceAbbreviation}{$invoice_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}Reference: {if $domain_country} + {$domain_country} + {/if}
{$source} {if $domain_phone}{$domain_phone}{/if}
{if $domain_email} + {$domain_email} + {/if}
+ + + + +
+ {* FIXME: style this table so that it looks like the text version (justification, etc.) *} + + + + + + + + {foreach from=$lineItem item=value key=priceset name=taxpricevalue} + {if $smarty.foreach.taxpricevalue.index eq 0} + + {else} + + {/if} + + + + + {if $value.tax_amount != ''} + + {else} + + {/if} + + + {/foreach} + + + + + + + {foreach from = $dataArray item = value key = priceset} + + + {if $priceset} + + + {elseif $priceset == 0} + + + + {/if} + {/foreach} + + + + + + + + + + + + {if $is_pay_later == 0} + + + + + + + + + + + + + + + {/if} +


+ + + + + + + +
DescriptionQuantityUnit Price{$taxTerm} Amount {$defaultCurrency}


+ {if $value.html_type eq 'Text'}{$value.label}{else}{$value.field_title} - {$value.label}{/if} {if $value.description}
{$value.description|truncate:30:"..."}
{/if} +
{$value.qty} {$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}{$value.subTotal|crmMoney:$currency}

Sub Total {$subTotal|crmMoney:$currency}
TOTAL {$taxTerm} {$priceset}%{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}

TOTAL {$defaultCurrency}{$amount|crmMoney:$currency}
+ {if $contribution_status_id == $refundedStatusId} + LESS Amount Credited + {else} + LESS Amount Paid + {/if} + {$amount|crmMoney:$currency}

AMOUNT DUE: {$amountDue|crmMoney:$currency}
DUE DATE: {$dueDate}
+
+ + + + +
+ + + + + +
PAYMENT ADVICE

To:
+ {$domain_organization}
+ {$domain_street_address} {$domain_supplemental_address_1}
+ {$domain_supplemental_address_2} {$domain_state}
+ {$domain_city} {$domain_postal_code}
+ {$domain_country}
+ {$domain_phone}
+ {$domain_email}
+


{$notes} +
+ + + + + + + + + + + + + {if $is_pay_later == 1} + + + + + + {else} + + + + + + {/if} + + + + + + + + +
Customer: {$display_name}
Invoice Number: {$invoice_id}

Amount Due:{$amount|crmMoney:$currency}
Amount Due: {$amountDue|crmMoney:$currency}
Due Date: {$dueDate}

+
+ + + {if $contribution_status_id == $refundedStatusId} + + + + +
+
+ + + + + + + + + + {if $organization_name} + + {else} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CREDIT NOTEDate:{$domain_organization}
{$display_name} ({$organization_name}){$display_name}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 } + {$domain_supplemental_address_1} + {/if}
{$street_address} {$supplemental_address_1}Credit Note Number:{if $domain_supplemental_address_2 } + {$domain_supplemental_address_2} + {/if} + {if $domain_state } + {$domain_state} + {/if} +
{$supplemental_address_2} {$stateProvinceAbbreviation}{$creditnote_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}Reference: {if $domain_country} + {$domain_country} + {/if}
{$source} {if $domain_phone} + {$domain_phone} + {/if}
{if $domain_email} + {$domain_email} + {/if}
+ + + + + +
+ {* FIXME: style this table so that it looks like the text version (justification, etc.) *} + + + + + + + + {foreach from=$lineItem item=value key=priceset name=pricevalue} + {if $smarty.foreach.pricevalue.index eq 0} + + {else} + + {/if} + + + + + {if $value.tax_amount != ''} + + {else} + + {/if} + + + {/foreach} + + + + + + + {foreach from = $dataArray item = value key = priceset} + + + {if $priceset} + + + {elseif $priceset == 0} + + + + {/if} + {/foreach} + + + + + + + + + + + + {if $is_pay_later == 0} + + + + + + + + + + + + + + + + {/if} +


+ + + + + + + +
DescriptionQuantityUnit Price{$taxTerm} Amount {$defaultCurrency}


+ {if $value.html_type eq 'Text'}{$value.label}{else}{$value.field_title} - {$value.label}{/if} {if $value.description}
{$value.description|truncate:30:"..."}
{/if} +
{$value.qty} {$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}{$value.subTotal|crmMoney:$currency}

Sub Total {$subTotal|crmMoney:$currency}
TOTAL {$taxTerm} {$priceset}%{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}

TOTAL {$defaultCurrency}{$amount|crmMoney:$currency}
LESS Credit to invoice(s){$amount|crmMoney:$currency}

REMAINING CREDIT{$amountDue|crmMoney:$currency}
+
+ + + + + +
+ + + + + + +
CREDIT ADVICE

Please do not pay on this advice. Deduct the amount of this Credit Note +from your next payment to us

+ + + + + + + + + + + + + + + + + +
Customer: {$display_name}
Credit Note#: {$creditnote_id}

Credit Amount:{$amount|crmMoney:$currency}
+
+ {/if} +
+ + diff --git a/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl index ddf87d2f0a..609af49d14 100644 --- a/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.6.9.mysql.tpl @@ -3,3 +3,6 @@ -- CRM-17112 - Add Missing countries Saint Barthélemy and Saint Martin INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Saint Barthélemy", "BL", "2", "0"); INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Saint Martin (French part)", "MF", "2", "0"); + +-- CRM-17039 - Add credit note for cancelled payments +{include file='../CRM/Upgrade/4.6.9.msg_template/civicrm_msg_template.tpl'} \ No newline at end of file -- 2.25.1