CRM-13965 : email template handling for refund payment and partial payment
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 27 Jan 2014 08:29:58 +0000 (13:59 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Mon, 27 Jan 2014 08:29:58 +0000 (13:59 +0530)
CRM/Contribute/Form/AdditionalPayment.php
CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl [new file with mode: 0644]
CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_html.tpl [new file with mode: 0644]
CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_subject.tpl [new file with mode: 0644]
CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_text.tpl [new file with mode: 0644]
CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
templates/CRM/Contribute/Form/AdditionalPayment.tpl
xml/templates/civicrm_msg_template.tpl
xml/templates/message_templates/payment_or_refund_notification_html.tpl [new file with mode: 0644]
xml/templates/message_templates/payment_or_refund_notification_subject.tpl [new file with mode: 0644]
xml/templates/message_templates/payment_or_refund_notification_text.tpl [new file with mode: 0644]

index 27666925f1c587ce82a29b04b56614b14c33c02f..f9112f295632a5d49ec93aae72f8e9ad02f10e58 100644 (file)
@@ -72,6 +72,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
   protected $fromEmailId = NULL;
 
+  protected $_fromEmails = NULL;
+
   public function preProcess() {
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
@@ -86,6 +88,10 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
 
     $paymentInfo = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($this->_id, $enitityType);
+    $paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component);
+
+    $this->_amtPaid = $paymentDetails['paid'];
+    $this->_amtTotal = $paymentDetails['total'];
 
     if (!empty($paymentInfo['refund_due'])) {
       $paymentAmt = $this->_refund = $paymentInfo['refund_due'];
@@ -108,11 +114,12 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
     list($this->_contributorDisplayName, $this->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactId);
 
-    $this->assignProcessors();
-
-    // also check for billing information
-    // get the billing location type
-    $this->assignBillingType();
+    if (!$this->_refund) {
+      $this->assignProcessors();
+      // also check for billing information
+      // get the billing location type
+      $this->assignBillingType();
+    }
 
     $this->assign('contributionMode', $this->_mode);
     $this->assign('contactId', $this->_contactId);
@@ -243,6 +250,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
     $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails);
 
+    $this->add('textarea', 'receipt_text', ts('Confirmation Message'));
+
     // add various dates
     $this->addDateTime('trxn_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
 
@@ -318,8 +327,9 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       $participantId = $this->_id;
     }
     $submittedValues = $this->controller->exportValues($this->_name);
-    $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
+    $submittedValues['confirm_email_text'] = CRM_Utils_Array::value('receipt_text', $submittedValues);
 
+    $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
     if ($this->_mode) {
       // process credit card
       $this->processCreditCard($submittedValues);
@@ -334,7 +344,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
 
         // to get 'from email id' for send receipt
         $this->fromEmailId = $submittedValues['from_email_address'];
-        $sendReceipt = self::emailReceipt($this, $submittedValues);
+        $sendReceipt = $this->emailReceipt($submittedValues);
       }
 
       $statusMsg = ts('The payment record has been processed.');
@@ -510,8 +520,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     $this->_params['receive_date'] = $now;
 
     $this->set('params', $this->_params);
-    $this->assign('trxn_id', $result['trxn_id']);
-    $this->assign('receive_date', $this->_params['receive_date']);
 
     // set source if not set
     if (empty($this->_params['source'])) {
@@ -526,7 +534,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     $trxnRecord = CRM_Contribute_BAO_Contribution::recordAdditionPayment($this->_contributionId, $submittedValues, $this->_paymentType, $participantId);
 
     if ($trxnRecord->id && !empty($this->_params['is_email_receipt'])) {
-      $sendReceipt = self::emailReceipt($this, $this->_params);
+      $sendReceipt = $this->emailReceipt($this->_params);
     }
 
     if ($trxnRecord->id) {
@@ -541,7 +549,81 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
   }
 
-  static function emailReceipt(&$form, &$params) {
+  function emailReceipt(&$params) {
     // email receipt sending
+    // send message template
+    if ($this->_component == 'event') {
+      $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
+
+      $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
+      CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $eventId, $events, $returnProperties);
+      $event = $events[$eventId];
+      unset($event['start_date']);
+      unset($event['end_date']);
+
+      //$this-assign('component', $this->_component);
+      $this->assign('isShowLocation', $event['is_show_location']);
+      if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
+        $locationParams = array(
+          'entity_id' => $eventId,
+          'entity_table' => 'civicrm_event',
+        );
+        $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
+        $this->assign('location', $location);
+      }
+    }
+
+    // assign payment info here
+    $paymentConfig['confirm_email_text'] = CRM_Utils_Array::value('confirm_email_text', $params);
+    $this->assign('paymentConfig', $paymentConfig);
+    $isRefund = ($this->_paymentType == 'refund') ? TRUE : FALSE;
+    $this->assign('isRefund', $isRefund);
+    if ($isRefund) {
+      $this->assign('totalPaid', $this->_amtPaid);
+      $this->assign('totalAmount', $this->_amtTotal);
+      $this->assign('refundAmount', $params['total_amount']);
+    }
+    else {
+      $balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
+      $this->assign('amountOwed', $balance);
+      $this->assign('totalAmount', $this->_amtTotal);
+      $this->assign('paymentAmount', $params['total_amount']);
+    }
+    $this->assign('contactDisplayName', $this->_contributorDisplayName);
+
+    // assign trxn details
+    $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
+    $this->assign('receive_date', CRM_Utils_Array::value('receive_date', $params));
+    $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
+    if (array_key_exists('payment_instrument_id', $params)) {
+      $this->assign('paidBy',
+        CRM_Utils_Array::value($params['payment_instrument_id'],
+          $paymentInstrument
+        )
+      );
+    }
+    $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
+
+    $sendTemplateParams = array(
+      'groupName' => 'msg_tpl_workflow_contribution',
+      'valueName' => 'payment_or_refund_notification',
+      'contactId' => $this->_contactId,
+      'PDFFilename' => ts('notification').'.pdf',
+    );
+
+    // try to send emails only if email id is present
+    // and the do-not-email option is not checked for that contact
+    if ($this->_contributorEmail && !$this->_toDoNotEmail) {
+      if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
+        $receiptFrom = $params['from_email_address'];
+      }
+
+      $sendTemplateParams['from'] = $receiptFrom;
+      $sendTemplateParams['toName'] = $this->_contributorDisplayName;
+      $sendTemplateParams['toEmail'] = $this->_contributorEmail;
+      $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails);
+      $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails);
+    }
+    list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
   }
-}
+}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl
new file mode 100644 (file)
index 0000000..6003bf8
--- /dev/null
@@ -0,0 +1,42 @@
+{php}
+  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates';
+
+  $ovNames = array(
+    'contribution' => array(
+      'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification',             array('escape' => 'sql')),
+    ),
+  );
+
+  $this->assign('ovNames', $ovNames);
+  $this->assign('dir', $dir);
+{/php}
+
+{foreach from=$ovNames key=name item=ignore}
+  SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
+{/foreach}
+
+INSERT INTO civicrm_option_value
+  (option_group_id,        name,       {localize field='label'}label{/localize},   value,                                  weight) VALUES
+{foreach from=$ovNames key=gName item=ovs name=for_groups}
+{foreach from=$ovs key=vName item=label name=for_values}
+      (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize},            {$smarty.foreach.for_values.iteration}, {$smarty.foreach.for_values.iteration}) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
+{/foreach}
+{/foreach}
+
+{foreach from=$ovNames key=gName item=ovs}
+{foreach from=$ovs key=vName item=label}
+    SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
+{/foreach}
+{/foreach}
+
+INSERT INTO civicrm_msg_template
+  (msg_title,      msg_subject,                  msg_text,                  msg_html,                  workflow_id,        is_default, is_reserved) VALUES
+{foreach from=$ovNames key=gName item=ovs name=for_groups}
+{foreach from=$ovs key=vName item=title name=for_values}
+      {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_subject.tpl"}
+      {fetch assign=text    file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_text.tpl"}
+      {fetch assign=html    file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.5.alpha1.msg_template/message_templates/`$vName`_html.tpl"}
+      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1,          0),
+      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0,          1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
+{/foreach}
+{/foreach}
diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_html.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_html.tpl
new file mode 100644 (file)
index 0000000..a1def6b
--- /dev/null
@@ -0,0 +1,250 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+</head>
+<body>
+
+{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
+{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
+{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
+
+<p>Dear {$contactDisplayName}</p>
+<center>
+ <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
+
+  <!-- BEGIN HEADER -->
+  <!-- You can add table row(s) here with logo or other header elements -->
+  <!-- END HEADER -->
+
+  <!-- BEGIN CONTENT -->
+
+  <tr>
+    <td>
+      {if $paymentConfig.confirm_email_text}
+      <p>{$paymentConfig.confirm_email_text|htmlize}</p>
+      {elseif $isRefund}
+      <p>{ts}A refund has been issued based on changes in your registration selections.{/ts}</p>
+      {else}
+      <p>{ts}A payment has been received.{/ts}</p>
+      {/if}
+      <p>{ts}Please print this confirmation for your records.{/ts}</p>
+    </td>
+  </tr>
+  
+  {if $isRefund}
+  <tr>
+    <th {$headerStyle}>{ts}Refund Details{/ts}</th>
+  </tr>
+  <tr>
+    <td {$labelStyle}>
+      {ts}Total Fees{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$totalAmount|crmMoney}
+    </td>
+    <td {$labelStyle}>
+      {ts}You Paid{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$totalPaid|crmMoney}
+    </td>
+    <td {$labelStyle}>
+      {ts}Refund Amount{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$refundAmount|crmMoney}
+    <td>
+  </tr>
+  {else}
+    <tr>
+      <th {$headerStyle}>{ts}Payment Details{/ts}</th>
+    </tr>
+    <tr>
+      <td {$labelStyle}>
+       {ts}{if $component eq 'event'}Total Fees{/if}{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$totalAmount|crmMoney}
+      </td>
+      <td {$labelStyle}>
+       {ts}This Payment Amount{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$paymentAmount|crmMoney}
+      </td>
+      <td {$labelStyle}>
+       {ts}Balance Owed{/ts}
+      </td>
+      <td>
+       {$amountOwed|crmMoney}
+      </td> {* This will be zero after final payment. *}
+      {if $paymentsComplete}
+      <td colspan='2' {$valueStyle}>
+       {ts}Thank-you. This completes your payment for {if $component eq 'event'}{$event.event_title}{/if}.{/ts}
+      </td>
+      {/if}
+    </tr>
+  {/if}
+  {if $receive_date}
+    <tr>
+      <td {$labelStyle}>
+       {ts}Transaction Date{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$receive_date|crmDate}
+      </td>
+    </tr>
+  {/if}
+  {if $trxn_id}
+    <tr>
+      <td {$labelStyle}>
+       {ts}Transaction #{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$trxn_id}
+      </td>
+    </tr>
+  {/if}
+  {if $paidBy}
+    <tr>
+      <td {$labelStyle}>
+        {ts}Paid By{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$paidBy}
+      </td>
+    </tr>
+  {/if}
+  {if $checkNumber}
+    <tr>
+      <td {$labelStyle}>
+        {ts}Check Number{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$checkNumber}
+      </td>
+    </tr>
+  {/if}
+    <tr>
+      <td>
+       <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
+         {if $contributeMode ne 'notify' and !$isAmountzero}
+          <tr>
+            <th {$headerStyle}>
+             {ts}Billing Name and Address{/ts}
+            </th>
+          </tr>
+          <tr>
+            <td colspan="2" {$valueStyle}>
+             {$billingName}<br />
+             {$address|nl2br}
+            </td>
+          </tr>
+         {/if}
+         {if $contributeMode eq'direct' and !$isAmountzero}
+          <tr>
+            <th {$headerStyle}>
+             {ts}Credit Card Information{/ts}
+            </th>
+          </tr>
+          <tr>
+            <td colspan="2" {$valueStyle}>
+             {$credit_card_type}<br />
+             {$credit_card_number}<br />
+             {ts 1=$credit_card_exp_date|truncate:7:''|crmDate}Expires: %1{/ts}
+            </td>
+          </tr>
+         {/if}
+         {if $component eq 'event'}
+         <tr>
+           <th {$headerStyle}>
+             {ts}Event Information and Location{/ts}
+           </th>
+         </tr>
+         <tr>
+           <td colspan="2" {$valueStyle}>
+             {$event.event_title}<br />
+             {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+           </td>
+         </tr>
+
+         {if $event.participant_role neq 'Attendee' and $defaultRole}
+         <tr>
+           <td {$labelStyle}>
+             {ts}Participant Role{/ts}
+           </td>
+           <td {$valueStyle}>
+             {$event.participant_role}
+           </td>
+         </tr>
+         {/if}
+
+         {if $isShowLocation}
+         <tr>
+           <td colspan="2" {$valueStyle}>
+             {if $location.address.1.name}
+             {$location.address.1.name}<br />
+             {/if}
+             {if $location.address.1.street_address}
+             {$location.address.1.street_address}<br />
+             {/if}
+             {if $location.address.1.supplemental_address_1}
+             {$location.address.1.supplemental_address_1}<br />
+             {/if}
+             {if $location.address.1.supplemental_address_2}
+             {$location.address.1.supplemental_address_2}<br />
+             {/if}
+             {if $location.address.1.city}
+             {$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
+             {/if}
+           </td>
+         </tr>
+         {/if}
+
+         {if $location.phone.1.phone || $location.email.1.email}
+         <tr>
+           <td colspan="2" {$labelStyle}>
+             {ts}Event Contacts:{/ts}
+           </td>
+         </tr>
+         {foreach from=$location.phone item=phone}
+         {if $phone.phone}
+          <tr>
+            <td {$labelStyle}>
+             {if $phone.phone_type}
+             {$phone.phone_type_display}
+             {else}
+             {ts}Phone{/ts}
+             {/if}
+            </td>
+            <td {$valueStyle}>
+             {$phone.phone} {if $phone.phone_ext}&nbsp;{ts}ext.{/ts} {$phone.phone_ext}{/if}
+            </td>
+          </tr>
+         {/if}
+         {/foreach}
+         {foreach from=$location.email item=eventEmail}
+         {if $eventEmail.email}
+          <tr>
+            <td {$labelStyle}>
+             {ts}Email{/ts}
+            </td>
+            <td {$valueStyle}>
+             {$eventEmail.email}
+            </td>
+          </tr>
+         {/if}
+         {/foreach}
+         {/if} {*phone block close*}
+         {/if}
+       </table>
+      </td>
+    </tr>
+
+    </table>
+  </center>
+
+ </body>
+</html>
diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_subject.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_subject.tpl
new file mode 100644 (file)
index 0000000..ef17a4c
--- /dev/null
@@ -0,0 +1 @@
+{if $isRefund}{ts}Refund Notification{/ts}{else}{ts}Payment Receipt{/ts}{/if} - {if $component eq 'event'}{$event.title}{/if}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_text.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_text.tpl
new file mode 100644 (file)
index 0000000..5b9a7b1
--- /dev/null
@@ -0,0 +1,119 @@
+Dear {$contactDisplayName}
+{if $paymentConfig.confirm_email_text}
+{$paymentConfig.confirm_email_text}
+{else}
+{if $isRefund}
+{ts}A refund has been issued based on changes in your registration selections.{/ts}
+{else}
+{ts}A payment has been received.{/ts}
+{/if}
+{/if}
+
+{ts}Please print this confirmation for your records.{/ts}
+
+{if $isRefund}
+===============================================================================
+
+{ts}Refund Details{/ts}
+
+===============================================================================
+{ts}Total Fees{/ts}: {$totalAmount|crmMoney}
+{ts}You Paid{/ts}: {$totalPaid|crmMoney}
+------------------------------------------------------------------------------------
+{ts}Refund Amount{/ts}: {$refundAmount|crmMoney}
+
+{else}
+===============================================================================
+
+{ts}Payment Details{/ts}
+
+===============================================================================
+{ts}Total Fees{/ts}: {$totalAmount|crmMoney}
+{ts}This Payment Amount{/ts}: {$paymentAmount|crmMoney}
+------------------------------------------------------------------------------------
+{ts}Balance Owed{/ts}: {$amountOwed|crmMoney} {* This will be zero after final payment. *}
+{if $paymentsComplete}
+
+{ts}Thank-you. This completes your payment for {/ts}{if $component eq 'event'}{$event.event_title}{/if}.
+{/if}
+
+{if $receive_date}
+{ts}Transaction Date{/ts}: {$receive_date|crmDate}
+{/if}
+{if $trxn_id}
+{ts}Transaction #{/ts}: {$trxn_id}
+{/if}
+{if $paidBy}
+{ts}Paid By{/ts}: {$paidBy}
+{/if}
+{if $checkNumber}
+{ts}Check Number{/ts}: {$checkNumber}
+{/if}
+{if $contributeMode ne 'notify' and !$isAmountzero}
+
+===============================================================================
+
+{ts}Billing Name and Address{/ts}
+
+===============================================================================
+
+{$billingName}
+{$address}
+{/if}
+
+{if $contributeMode eq 'direct' and !$isAmountzero}
+===========================================================
+{ts}Credit Card Information{/ts}
+
+===============================================================================
+
+{$credit_card_type}
+{$credit_card_number}
+{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+{/if}
+{/if}
+{/if}
+{if $component eq 'event'}
+===============================================================================
+
+{ts}Event Information and Location{/ts}
+
+===============================================================================
+
+{$event.event_title}
+{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+
+{if $event.participant_role neq 'Attendee' and $defaultRole}
+{ts}Participant Role{/ts}: {$event.participant_role}
+{/if}
+
+{if $isShowLocation}
+{if $location.address.1.name}
+
+{$location.address.1.name}
+{/if}
+{if $location.address.1.street_address}{$location.address.1.street_address}
+{/if}
+{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
+{/if}
+{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
+{/if}
+{if $location.address.1.city}{$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
+{/if}
+
+{/if}{*End of isShowLocation condition*}
+
+{if $location.phone.1.phone || $location.email.1.email}
+
+{ts}Event Contacts:{/ts}
+{foreach from=$location.phone item=phone}
+{if $phone.phone}
+
+{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if} {if $phone.phone_ext} {ts}ext.{/ts} {$phone.phone_ext}{/if}
+{/foreach}
+{foreach from=$location.email item=eventEmail}
+{if $eventEmail.email}
+
+{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
+{/if}
+{/if}
\ No newline at end of file
index ab49122df86fd96342b55793ab39c8632ec98d1d..324852a6473ffb800556066a1c71d29ec799b399 100644 (file)
@@ -1,4 +1,5 @@
 {* file to handle db changes in 4.5.alpha1 during upgrade *}
+{include file='../CRM/Upgrade/4.4.alpha1.msg_template/civicrm_msg_template.tpl'}
 
 ALTER TABLE `civicrm_contact`
   ADD COLUMN `formal_title` varchar(64) COMMENT 'Formal (academic or similar) title in front of name. (Prof., Dr. etc.)' AFTER `suffix_id`;
index 83d4922f3d530ab79eec1e0b06020ecfbe736adf..39944841a2c4f9eecffb068e39034d9d5d1219d4 100644 (file)
                 <span class="description">{ts 1=$email}Automatically email a receipt for this payment to %1?{/ts}</span>
               </td>
             </tr>
-            {elseif $context eq 'standalone' and $outBound_option != 2 }
-            <tr id="email-receipt" style="display:none;" class="crm-payment-form-block-is_email_receipt">
-              <td class="label">{$form.is_email_receipt.label}</td>
-              <td>{$form.is_email_receipt.html} <span class="description">{ts}Automatically email a receipt for this payment to {/ts}<span id="email-address"></span>?</span>
-              </td>
-            </tr>
           {/if}
           <tr id="fromEmail" class="crm-payment-form-block-receipt_date" style="display:none;">
             <td class="label">{$form.from_email_address.label}</td>
             <td>{$form.from_email_address.html}</td>
           </tr>
-          <tr class="crm-payment-form-block-fee_amount"><td class="label">{$form.fee_amount.label}</td><td{$valueStyle}>{$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}<br />
+          <tr id='notice' class="crm-event-eventfees-form-block-receipt_text">
+            <td class="label">{$form.receipt_text.label}</td>
+            <td><span class="description">
+                {ts}Enter a message you want included at the beginning of the confirmation email. EXAMPLE: 'Thanks for registering for this event.'{/ts}
+                </span><br />
+                {$form.receipt_text.html|crmAddClass:huge}
+            </td>
+          </tr>   
+           <tr class="crm-payment-form-block-fee_amount"><td class="label">{$form.fee_amount.label}</td><td{$valueStyle}>{$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}<br />
             <span class="description">{ts}Processing fee for this transaction (if applicable).{/ts}</span></td></tr>
-          <tr class="crm-payment-form-block-net_amount"><td class="label">{$form.net_amount.label}</td><td{$valueStyle}>{$form.net_amount.html|crmMoney:$currency:'':1}<br />
+           <tr class="crm-payment-form-block-net_amount"><td class="label">{$form.net_amount.label}</td><td{$valueStyle}>{$form.net_amount.html|crmMoney:$currency:'':1}<br />
             <span class="description">{ts}Net value of the payment (Total Amount minus Fee).{/ts}</span></td></tr>
         </table>
       </div>
     {literal}
     <script type="text/javascript">
 
-  var url = "{/literal}{$dataUrl}{literal}";
+    var url = "{/literal}{$dataUrl}{literal}";
 
       cj( function( ) {
+        showHideByValue( 'is_email_receipt', '', 'notice', 'table-row', 'radio', false );
         showHideByValue( 'is_email_receipt', '', 'fromEmail', 'table-row', 'radio', false );
       });
     {/literal}
 <br />
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
-
   {literal}
   <script type="text/javascript">
   function verify( ) {
         if (cj('#is_email_receipt').attr( 'checked' )) {
           cj('#fromEmail').show( );
           cj('#receiptDate').hide( );
+          cj('#notice').show( );
         }
         else {
           cj('#fromEmail').hide( );
+          cj('#notice').hide( );
           cj('#receiptDate').show( );
         }
       }
 
-  // bind first click of accordion header to load crm-accordion-body with snippet
+    // bind first click of accordion header to load crm-accordion-body with snippet
     // everything else taken care of by cj().crm-accordions()
     cj(function() {
       cj('#adjust-option-type').hide();
index 2a847eee08fd4af136a79c7c3ceb3fdace09d5b1..a3c6c2cee161b4e6a9f6397fdcbbf554ac49bbb8 100644 (file)
       'contribution_recurring_notify' => ts('Contributions - Recurring Start and End Notification',           array('escape' => 'sql')),
       'contribution_recurring_cancelled' => ts('Contributions - Recurring Cancellation Notification',         array('escape' => 'sql')),
       'contribution_recurring_billing' => ts('Contributions - Recurring Billing Updates',                     array('escape' => 'sql')),
-      'contribution_recurring_edit'    => ts('Contributions - Recurring Updates',                           array('escape' => 'sql')),
+      'contribution_recurring_edit'    => ts('Contributions - Recurring Updates',                             array('escape' => 'sql')),
       'pcp_notify'                    => ts('Personal Campaign Pages - Admin Notification',                   array('escape' => 'sql')),
       'pcp_status_change'             => ts('Personal Campaign Pages - Supporter Status Change Notification', array('escape' => 'sql')),
       'pcp_supporter_notify'          => ts('Personal Campaign Pages - Supporter Welcome',                    array('escape' => 'sql')),
+      'payment_or_refund_notification' => ts('Additional Payment Receipt or Refund Notification',             array('escape' => 'sql')),
     ),
     'event' => array(
       'event_offline_receipt' => ts('Events - Registration Confirmation and Receipt (off-line)', array('escape' => 'sql')),
diff --git a/xml/templates/message_templates/payment_or_refund_notification_html.tpl b/xml/templates/message_templates/payment_or_refund_notification_html.tpl
new file mode 100644 (file)
index 0000000..a1def6b
--- /dev/null
@@ -0,0 +1,250 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title></title>
+</head>
+<body>
+
+{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
+{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
+{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
+
+<p>Dear {$contactDisplayName}</p>
+<center>
+ <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
+
+  <!-- BEGIN HEADER -->
+  <!-- You can add table row(s) here with logo or other header elements -->
+  <!-- END HEADER -->
+
+  <!-- BEGIN CONTENT -->
+
+  <tr>
+    <td>
+      {if $paymentConfig.confirm_email_text}
+      <p>{$paymentConfig.confirm_email_text|htmlize}</p>
+      {elseif $isRefund}
+      <p>{ts}A refund has been issued based on changes in your registration selections.{/ts}</p>
+      {else}
+      <p>{ts}A payment has been received.{/ts}</p>
+      {/if}
+      <p>{ts}Please print this confirmation for your records.{/ts}</p>
+    </td>
+  </tr>
+  
+  {if $isRefund}
+  <tr>
+    <th {$headerStyle}>{ts}Refund Details{/ts}</th>
+  </tr>
+  <tr>
+    <td {$labelStyle}>
+      {ts}Total Fees{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$totalAmount|crmMoney}
+    </td>
+    <td {$labelStyle}>
+      {ts}You Paid{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$totalPaid|crmMoney}
+    </td>
+    <td {$labelStyle}>
+      {ts}Refund Amount{/ts}
+    </td>
+    <td {$valueStyle}>
+      {$refundAmount|crmMoney}
+    <td>
+  </tr>
+  {else}
+    <tr>
+      <th {$headerStyle}>{ts}Payment Details{/ts}</th>
+    </tr>
+    <tr>
+      <td {$labelStyle}>
+       {ts}{if $component eq 'event'}Total Fees{/if}{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$totalAmount|crmMoney}
+      </td>
+      <td {$labelStyle}>
+       {ts}This Payment Amount{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$paymentAmount|crmMoney}
+      </td>
+      <td {$labelStyle}>
+       {ts}Balance Owed{/ts}
+      </td>
+      <td>
+       {$amountOwed|crmMoney}
+      </td> {* This will be zero after final payment. *}
+      {if $paymentsComplete}
+      <td colspan='2' {$valueStyle}>
+       {ts}Thank-you. This completes your payment for {if $component eq 'event'}{$event.event_title}{/if}.{/ts}
+      </td>
+      {/if}
+    </tr>
+  {/if}
+  {if $receive_date}
+    <tr>
+      <td {$labelStyle}>
+       {ts}Transaction Date{/ts}
+      </td>
+      <td {$valueStyle}>
+       {$receive_date|crmDate}
+      </td>
+    </tr>
+  {/if}
+  {if $trxn_id}
+    <tr>
+      <td {$labelStyle}>
+       {ts}Transaction #{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$trxn_id}
+      </td>
+    </tr>
+  {/if}
+  {if $paidBy}
+    <tr>
+      <td {$labelStyle}>
+        {ts}Paid By{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$paidBy}
+      </td>
+    </tr>
+  {/if}
+  {if $checkNumber}
+    <tr>
+      <td {$labelStyle}>
+        {ts}Check Number{/ts}
+      </td>
+      <td {$valueStyle}>
+        {$checkNumber}
+      </td>
+    </tr>
+  {/if}
+    <tr>
+      <td>
+       <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
+         {if $contributeMode ne 'notify' and !$isAmountzero}
+          <tr>
+            <th {$headerStyle}>
+             {ts}Billing Name and Address{/ts}
+            </th>
+          </tr>
+          <tr>
+            <td colspan="2" {$valueStyle}>
+             {$billingName}<br />
+             {$address|nl2br}
+            </td>
+          </tr>
+         {/if}
+         {if $contributeMode eq'direct' and !$isAmountzero}
+          <tr>
+            <th {$headerStyle}>
+             {ts}Credit Card Information{/ts}
+            </th>
+          </tr>
+          <tr>
+            <td colspan="2" {$valueStyle}>
+             {$credit_card_type}<br />
+             {$credit_card_number}<br />
+             {ts 1=$credit_card_exp_date|truncate:7:''|crmDate}Expires: %1{/ts}
+            </td>
+          </tr>
+         {/if}
+         {if $component eq 'event'}
+         <tr>
+           <th {$headerStyle}>
+             {ts}Event Information and Location{/ts}
+           </th>
+         </tr>
+         <tr>
+           <td colspan="2" {$valueStyle}>
+             {$event.event_title}<br />
+             {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+           </td>
+         </tr>
+
+         {if $event.participant_role neq 'Attendee' and $defaultRole}
+         <tr>
+           <td {$labelStyle}>
+             {ts}Participant Role{/ts}
+           </td>
+           <td {$valueStyle}>
+             {$event.participant_role}
+           </td>
+         </tr>
+         {/if}
+
+         {if $isShowLocation}
+         <tr>
+           <td colspan="2" {$valueStyle}>
+             {if $location.address.1.name}
+             {$location.address.1.name}<br />
+             {/if}
+             {if $location.address.1.street_address}
+             {$location.address.1.street_address}<br />
+             {/if}
+             {if $location.address.1.supplemental_address_1}
+             {$location.address.1.supplemental_address_1}<br />
+             {/if}
+             {if $location.address.1.supplemental_address_2}
+             {$location.address.1.supplemental_address_2}<br />
+             {/if}
+             {if $location.address.1.city}
+             {$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
+             {/if}
+           </td>
+         </tr>
+         {/if}
+
+         {if $location.phone.1.phone || $location.email.1.email}
+         <tr>
+           <td colspan="2" {$labelStyle}>
+             {ts}Event Contacts:{/ts}
+           </td>
+         </tr>
+         {foreach from=$location.phone item=phone}
+         {if $phone.phone}
+          <tr>
+            <td {$labelStyle}>
+             {if $phone.phone_type}
+             {$phone.phone_type_display}
+             {else}
+             {ts}Phone{/ts}
+             {/if}
+            </td>
+            <td {$valueStyle}>
+             {$phone.phone} {if $phone.phone_ext}&nbsp;{ts}ext.{/ts} {$phone.phone_ext}{/if}
+            </td>
+          </tr>
+         {/if}
+         {/foreach}
+         {foreach from=$location.email item=eventEmail}
+         {if $eventEmail.email}
+          <tr>
+            <td {$labelStyle}>
+             {ts}Email{/ts}
+            </td>
+            <td {$valueStyle}>
+             {$eventEmail.email}
+            </td>
+          </tr>
+         {/if}
+         {/foreach}
+         {/if} {*phone block close*}
+         {/if}
+       </table>
+      </td>
+    </tr>
+
+    </table>
+  </center>
+
+ </body>
+</html>
diff --git a/xml/templates/message_templates/payment_or_refund_notification_subject.tpl b/xml/templates/message_templates/payment_or_refund_notification_subject.tpl
new file mode 100644 (file)
index 0000000..ef17a4c
--- /dev/null
@@ -0,0 +1 @@
+{if $isRefund}{ts}Refund Notification{/ts}{else}{ts}Payment Receipt{/ts}{/if} - {if $component eq 'event'}{$event.title}{/if}
\ No newline at end of file
diff --git a/xml/templates/message_templates/payment_or_refund_notification_text.tpl b/xml/templates/message_templates/payment_or_refund_notification_text.tpl
new file mode 100644 (file)
index 0000000..5b9a7b1
--- /dev/null
@@ -0,0 +1,119 @@
+Dear {$contactDisplayName}
+{if $paymentConfig.confirm_email_text}
+{$paymentConfig.confirm_email_text}
+{else}
+{if $isRefund}
+{ts}A refund has been issued based on changes in your registration selections.{/ts}
+{else}
+{ts}A payment has been received.{/ts}
+{/if}
+{/if}
+
+{ts}Please print this confirmation for your records.{/ts}
+
+{if $isRefund}
+===============================================================================
+
+{ts}Refund Details{/ts}
+
+===============================================================================
+{ts}Total Fees{/ts}: {$totalAmount|crmMoney}
+{ts}You Paid{/ts}: {$totalPaid|crmMoney}
+------------------------------------------------------------------------------------
+{ts}Refund Amount{/ts}: {$refundAmount|crmMoney}
+
+{else}
+===============================================================================
+
+{ts}Payment Details{/ts}
+
+===============================================================================
+{ts}Total Fees{/ts}: {$totalAmount|crmMoney}
+{ts}This Payment Amount{/ts}: {$paymentAmount|crmMoney}
+------------------------------------------------------------------------------------
+{ts}Balance Owed{/ts}: {$amountOwed|crmMoney} {* This will be zero after final payment. *}
+{if $paymentsComplete}
+
+{ts}Thank-you. This completes your payment for {/ts}{if $component eq 'event'}{$event.event_title}{/if}.
+{/if}
+
+{if $receive_date}
+{ts}Transaction Date{/ts}: {$receive_date|crmDate}
+{/if}
+{if $trxn_id}
+{ts}Transaction #{/ts}: {$trxn_id}
+{/if}
+{if $paidBy}
+{ts}Paid By{/ts}: {$paidBy}
+{/if}
+{if $checkNumber}
+{ts}Check Number{/ts}: {$checkNumber}
+{/if}
+{if $contributeMode ne 'notify' and !$isAmountzero}
+
+===============================================================================
+
+{ts}Billing Name and Address{/ts}
+
+===============================================================================
+
+{$billingName}
+{$address}
+{/if}
+
+{if $contributeMode eq 'direct' and !$isAmountzero}
+===========================================================
+{ts}Credit Card Information{/ts}
+
+===============================================================================
+
+{$credit_card_type}
+{$credit_card_number}
+{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+{/if}
+{/if}
+{/if}
+{if $component eq 'event'}
+===============================================================================
+
+{ts}Event Information and Location{/ts}
+
+===============================================================================
+
+{$event.event_title}
+{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
+
+{if $event.participant_role neq 'Attendee' and $defaultRole}
+{ts}Participant Role{/ts}: {$event.participant_role}
+{/if}
+
+{if $isShowLocation}
+{if $location.address.1.name}
+
+{$location.address.1.name}
+{/if}
+{if $location.address.1.street_address}{$location.address.1.street_address}
+{/if}
+{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
+{/if}
+{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
+{/if}
+{if $location.address.1.city}{$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
+{/if}
+
+{/if}{*End of isShowLocation condition*}
+
+{if $location.phone.1.phone || $location.email.1.email}
+
+{ts}Event Contacts:{/ts}
+{foreach from=$location.phone item=phone}
+{if $phone.phone}
+
+{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if} {if $phone.phone_ext} {ts}ext.{/ts} {$phone.phone_ext}{/if}
+{/foreach}
+{foreach from=$location.email item=eventEmail}
+{if $eventEmail.email}
+
+{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
+{/if}
+{/if}
\ No newline at end of file