From 57bb6c0322cd764cee2f786c3bff0750b9dc989e Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 23 Sep 2023 22:06:38 +1200 Subject: [PATCH] Swap out some tpl variables for tokens These ones are all pretty routine / been done in other templates --- .../CRM/Contribute/Form/ContributionTest.php | 10 +++---- .../CRM/Event/Form/ParticipantTest.php | 1 - .../event_offline_receipt_text.tpl | 8 ++--- .../contribution_offline_receipt_html.tpl | 4 +-- .../contribution_offline_receipt_text.tpl | 4 +-- .../event_offline_receipt_html.tpl | 30 +++++++++---------- .../event_offline_receipt_text.tpl | 27 ++++++++--------- .../event_online_receipt_html.tpl | 4 +-- .../event_online_receipt_text.tpl | 4 +-- .../membership_offline_receipt_html.tpl | 2 +- 10 files changed, 45 insertions(+), 49 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 47f6cca670..0ed9782944 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -700,7 +700,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { if ($isTaxed) { $mailUtil->checkMailLog([ 'Dear Anthony, -Below you will find a receipt for this contribution. + =========================================================== Contribution Information =========================================================== @@ -718,14 +718,13 @@ Sales Tax 10.00% : $10.00 Total Tax Amount : $10.00 Total Amount : $110.00 Contribution Date: ' . date('m/d/Y') . ' -Receipt Date: ' . date('m/d/Y') . ' -Paid By: Check', +Receipt Date: ' . date('m/d/Y'), ]); } else { $mailUtil->checkMailLog([ 'Dear Anthony, -Below you will find a receipt for this contribution. + =========================================================== Contribution Information =========================================================== @@ -740,8 +739,7 @@ Price Field - Price Field 1 1 $100.00 $100.00 Total Amount : $100.00 Contribution Date: ' . date('m/d/Y') . ' -Receipt Date: ' . date('m/d/Y') . ' -Paid By: Check', +Receipt Date: ' . date('m/d/Y'), ], ['Amount before Tax', 'Tax Amount']); } diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index d4832245ed..44f17d43b0 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -675,7 +675,6 @@ London,', $isAmountPaidOnForm ? 'Total Paid: $20.00' : 'Total Paid: ', $isAmountPaidOnForm ? 'Balance: $1,530.55' : 'Balance: $1,550.55', 'Financial Type: Event Fee', - 'Paid By: Check', 'February 15th, 2023 3:00 PM- 6:00 PM', 'Check Number: 879', ]); diff --git a/tests/templates/message_templates/event_offline_receipt_text.tpl b/tests/templates/message_templates/event_offline_receipt_text.tpl index dfce54967c..0745e5eb7c 100644 --- a/tests/templates/message_templates/event_offline_receipt_text.tpl +++ b/tests/templates/message_templates/event_offline_receipt_text.tpl @@ -1,6 +1,6 @@ -contactID:::{$contactID} -eventID:::{$eventID} -participantID:::{$participantID} +contactID:::{contact.id} +eventID:::{event.id} +participantID:::{participant.id} contact.id:::{contact.id} event.id:::{event.id} participant.id:::{participant.id} @@ -17,7 +17,7 @@ event.is_show_location|boolean::{event.is_show_location|boolean} event.is_public|boolean::{event.is_public|boolean} participant.participant_role_id:name::{participant.participant_role_id:name} participant.status_id:name:::{participant.status_id:name} -email:::{$email} +email:::{contact.email_primary.email} event.pay_later_receipt:::{event.pay_later_receipt} contribution.total_amount:::{contribution.total_amount|crmMoney} contribution.total_amount|raw:::{contribution.total_amount|raw} diff --git a/xml/templates/message_templates/contribution_offline_receipt_html.tpl b/xml/templates/message_templates/contribution_offline_receipt_html.tpl index 7a4a10778f..7f6479a6cf 100644 --- a/xml/templates/message_templates/contribution_offline_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_offline_receipt_html.tpl @@ -23,7 +23,7 @@ {assign var="greeting" value="{contact.email_greeting_display}"}{if $greeting}

{$greeting},

{/if}

{if {contribution.contribution_page_id.receipt_text|boolean}}{contribution.contribution_page_id.receipt_text} - {else}{ts}Below you will find a receipt for this contribution.{/ts}{/if} + {elseif {contribution.paid_amount|boolean}}{ts}Below you will find a receipt for this contribution.{/ts}{/if}

@@ -166,7 +166,7 @@ {/if} - {if {contribution.payment_instrument_id|boolean}} + {if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} {ts}Paid By{/ts} diff --git a/xml/templates/message_templates/contribution_offline_receipt_text.tpl b/xml/templates/message_templates/contribution_offline_receipt_text.tpl index 4e48d1357c..a4971e9181 100644 --- a/xml/templates/message_templates/contribution_offline_receipt_text.tpl +++ b/xml/templates/message_templates/contribution_offline_receipt_text.tpl @@ -2,7 +2,7 @@ {if {contribution.contribution_page_id.receipt_text|boolean}} {contribution.contribution_page_id.receipt_text} -{else}{ts}Below you will find a receipt for this contribution.{/ts} +{elseif {contribution.paid_amount|boolean}} {ts}Below you will find a receipt for this contribution.{/ts} {/if} =========================================================== @@ -49,7 +49,7 @@ {if '{contribution.receipt_date}'} {ts}Receipt Date{/ts}: {contribution.receipt_date|crmDate:"shortdate"} {/if} -{if {contribution.payment_instrument_id|boolean}} +{if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} {ts}Paid By{/ts}: {contribution.payment_instrument_id:label} {if '{contribution.check_number}'} {ts}Check Number{/ts}: {contribution.check_number} diff --git a/xml/templates/message_templates/event_offline_receipt_html.tpl b/xml/templates/message_templates/event_offline_receipt_html.tpl index ef4cb9c201..75654e606f 100644 --- a/xml/templates/message_templates/event_offline_receipt_html.tpl +++ b/xml/templates/message_templates/event_offline_receipt_html.tpl @@ -64,7 +64,7 @@ {/if} - {if !empty($isShowLocation)} + {if {event.is_show_location|boolean}} {$location.address.1.display|nl2br} @@ -148,7 +148,7 @@ {/if} - {if $email} + {if {contact.email_primary.email|boolean}} {ts}Registered Email{/ts} @@ -156,7 +156,7 @@ - {$email} + {contact.email_primary.email|boolean} {/if} @@ -188,7 +188,7 @@ {ts}Item{/ts} {ts}Qty{/ts} {ts}Each{/ts} - {if !empty($dataArray)} + {if $isShowTax && {contribution.tax_amount|boolean}} {ts}SubTotal{/ts} {ts}Tax Rate{/ts} {ts}Tax Amount{/ts} @@ -321,7 +321,7 @@ {/if} - {if $is_pay_later} + {if {contribution.is_pay_later|boolean} && {contribution.balance_amount|boolean}} {$pay_later_receipt} @@ -340,57 +340,57 @@ {/if} - {if !empty($receive_date)} + {if {contribution.receive_date|boolean}} {ts}Transaction Date{/ts} - {$receive_date|crmDate} + {contribution.receive_date} {/if} - {if !empty($financialTypeName)} + {if {contribution.financial_type_id|boolean}} {ts}Financial Type{/ts} - {$financialTypeName} + {contribution.financial_type_id:label} {/if} - {if !empty($trxn_id)} + {if {contribution.financial_trxn_id|boolean}} {ts}Transaction #{/ts} - {$trxn_id} + {contribution.financial_trxn_id} {/if} - {if !empty($paidBy)} + {if {contribution.payment_instrument_id|boolean}} {ts}Paid By{/ts} - {$paidBy} + {contribution.payment_instrument_id:label} {/if} - {if !empty($checkNumber)} + {if {contribution.check_number|boolean}} {ts}Check Number{/ts} - {$checkNumber} + {contribution.check_number} {/if} diff --git a/xml/templates/message_templates/event_offline_receipt_text.tpl b/xml/templates/message_templates/event_offline_receipt_text.tpl index 966d9d8e6a..c110c5f1b3 100644 --- a/xml/templates/message_templates/event_offline_receipt_text.tpl +++ b/xml/templates/message_templates/event_offline_receipt_text.tpl @@ -74,7 +74,7 @@ {ts}Add event to Google Calendar{/ts} {$gCalendar} {/if} -{if !empty($email)} +{if {contact.email_primary.email|boolean}} =============================================================================== @@ -82,7 +82,7 @@ =============================================================================== -{$email} +{contact.email_primary.email} {/if} {if {event.is_monetary|boolean}} {* This section for Paid events only.*} @@ -104,15 +104,14 @@ {capture assign=ts_item}{ts}Item{/ts}{/capture} {capture assign=ts_qty}{ts}Qty{/ts}{/capture} {capture assign=ts_each}{ts}Each{/ts}{/capture} -{if !empty($dataArray)} +{if $isShowTax && {contribution.tax_amount|boolean}} {capture assign=ts_subtotal}{ts}Subtotal{/ts}{/capture} {capture assign=ts_taxRate}{ts}Tax Rate{/ts}{/capture} {capture assign=ts_taxAmount}{ts}Tax Amount{/ts}{/capture} {/if} {capture assign=ts_total}{ts}Total{/ts}{/capture} {capture assign=ts_participant_total}{if !empty($pricesetFieldsCount)}{ts}Total Participants{/ts}{/if}{/capture} -{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if !empty($dataArray)} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"} {if !empty($ts_participant_total)}{$ts_participant_total|string_format:"%10s"}{/if} ------------------------------------------------------------------------------- +{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {if $isShowTax && {contribution.tax_amount|boolean}} {$ts_subtotal|string_format:"%10s"} {$ts_taxRate|string_format:"%10s"} {$ts_taxAmount|string_format:"%10s"} {/if} {$ts_total|string_format:"%10s"} {if !empty($ts_participant_total)}{$ts_participant_total|string_format:"%10s"}{/if} {foreach from=$value item=line} {if !empty($pricesetFieldsCount)}{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if} @@ -121,7 +120,7 @@ {/if} {/foreach} -{if !empty($dataArray)} +{if $isShowTax && {contribution.tax_amount|boolean}} {if $totalAmount and $totalTaxAmount} {ts}Amount before Tax:{/ts} {$totalAmount-$totalTaxAmount|crmMoney:$currency} {/if} @@ -181,17 +180,17 @@ {if {contribution.receive_date|boolean}} {ts}Transaction Date{/ts}: {contribution.receive_date} {/if} -{if !empty($financialTypeName)} -{ts}Financial Type{/ts}: {$financialTypeName} +{if {contribution.financial_type_id|boolean}} +{ts}Financial Type{/ts}: {contribution.financial_type_id:label} {/if} -{if !empty($trxn_id)} -{ts}Transaction #{/ts}: {$trxn_id} +{if {contribution.trxn_id|boolean}} +{ts}Transaction #{/ts}: {contribution.trxn_id} {/if} -{if !empty($paidBy)} -{ts}Paid By{/ts}: {$paidBy} +{if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} +{ts}Paid By{/ts}: {contribution.payment_instrument_id:label} {/if} -{if !empty($checkNumber)} -{ts}Check Number{/ts}: {$checkNumber} +{if {contribution.check_number|boolean}} +{ts}Check Number{/ts}: {contribution.check_number} {/if} {if !empty($billingName)} diff --git a/xml/templates/message_templates/event_online_receipt_html.tpl b/xml/templates/message_templates/event_online_receipt_html.tpl index a18fd97da7..58c49181f6 100644 --- a/xml/templates/message_templates/event_online_receipt_html.tpl +++ b/xml/templates/message_templates/event_online_receipt_html.tpl @@ -361,13 +361,13 @@ {/if} - {if !empty($paidBy)} + {if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} {ts}Paid By{/ts} - {$paidBy} + {contribution.payment_instrument_id:label} {/if} diff --git a/xml/templates/message_templates/event_online_receipt_text.tpl b/xml/templates/message_templates/event_online_receipt_text.tpl index 8ea903cb26..19b9c98967 100644 --- a/xml/templates/message_templates/event_online_receipt_text.tpl +++ b/xml/templates/message_templates/event_online_receipt_text.tpl @@ -173,8 +173,8 @@ You were registered by: {$payer.name} {if !empty($trxn_id)} {ts}Transaction #{/ts}: {$trxn_id} {/if} -{if !empty($paidBy)} -{ts}Paid By{/ts}: {$paidBy} +{if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} +{ts}Paid By{/ts}: {contribution.payment_instrument_id:label} {/if} {if !empty($checkNumber)} {ts}Check Number{/ts}: {$checkNumber} diff --git a/xml/templates/message_templates/membership_offline_receipt_html.tpl b/xml/templates/message_templates/membership_offline_receipt_html.tpl index b95821a37f..fbe26ba490 100644 --- a/xml/templates/message_templates/membership_offline_receipt_html.tpl +++ b/xml/templates/message_templates/membership_offline_receipt_html.tpl @@ -182,7 +182,7 @@ {/if} - {if {contribution.payment_instrument_id|boolean}} + {if {contribution.payment_instrument_id|boolean} && {contribution.paid_amount|boolean}} {ts}Paid By{/ts} -- 2.25.1