CRM-13965-qa-fixes : email message template fixes
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 6 Mar 2014 07:55:14 +0000 (13:25 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Thu, 6 Mar 2014 07:55:14 +0000 (13:25 +0530)
CRM/Contribute/Form/AdditionalPayment.php
CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_html.tpl
CRM/Upgrade/4.5.alpha1.msg_template/message_templates/payment_or_refund_notification_text.tpl
xml/templates/message_templates/payment_or_refund_notification_html.tpl
xml/templates/message_templates/payment_or_refund_notification_text.tpl

index b368ab270857c39e9e8ad852d57b4aaddbc4fa03..61238510ca2801cdd307ef1bdad4521331a944d3 100644 (file)
@@ -191,6 +191,10 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       );
     }
 
+    if ($this->_refund) {
+      $defaults['total_amount'] = abs($this->_refund);
+    }
+
     // Set $newCredit variable in template to control whether link to credit card mode is included
     CRM_Core_Payment::allowBackofficeCreditCard($this);
     return $defaults;
@@ -276,13 +280,11 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       TRUE, 'currency', NULL
     );
 
-    if (!$this->_mode) {
-      $this->add('select', 'payment_instrument_id',
-        ts('Paid By'),
-        array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
-        TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
-      );
-    }
+    $this->add('select', 'payment_instrument_id',
+      ts('Paid By'),
+      array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
+      TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+    );
 
     $this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']);
     $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), $attributes['trxn_id']);
@@ -375,6 +377,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     $submittedValues['trxn_date'] = CRM_Utils_Date::processDate($submittedValues['trxn_date'], $submittedValues['trxn_date_time']);
     if ($this->_mode) {
       // process credit card
+      $this->assign('contributeMode', 'direct');
       $this->processCreditCard($submittedValues);
     }
     else {
@@ -495,7 +498,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     );
     $this->_params['payment_action'] = 'Sale';
     if (!empty($this->_params['trxn_date'])) {
-      $this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['receive_date_time']);
+      $this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['trxn_date'], $this->_params['trxn_date_time']);
     }
 
     if (empty($this->_params['invoice_id'])) {
@@ -505,6 +508,36 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       $this->_params['invoiceID'] = $this->_params['invoice_id'];
     }
 
+    // billing name and Address
+    $name = CRM_Utils_Array::value('billing_first_name', $params);
+    if (!empty($params['billing_middle_name'])) {
+      $name .= " {$params['billing_middle_name']}";
+    }
+    $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params);
+    $name = trim($name);
+    $this->assign('billingName', $name);
+
+    //assign the address formatted up for display
+    $addressParts = array(
+      "street_address" => "billing_street_address-{$this->_bltID}",
+      "city" => "billing_city-{$this->_bltID}",
+      "postal_code" => "billing_postal_code-{$this->_bltID}",
+      "state_province" => "state_province-{$this->_bltID}",
+      "country" => "country-{$this->_bltID}",
+    );
+    $addressFields = array();
+    foreach ($addressParts as $name => $field) {
+      $addressFields[$name] = CRM_Utils_Array::value($field, $params);
+    }
+    $this->assign('address', CRM_Utils_Address::format($addressFields));
+    $date = CRM_Utils_Date::format($params['credit_card_exp_date']);
+    $date = CRM_Utils_Date::mysqlToIso($date);
+    $this->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
+    $this->assign('credit_card_exp_date', $date);
+    $this->assign('credit_card_number',
+      CRM_Utils_System::mungeCreditCard($params['credit_card_number'])
+    );
+
     //Add common data to formatted params
     CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this);
     // at this point we've created a contact and stored its address etc
@@ -555,7 +588,9 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       $this->_params = array_merge($this->_params, $result);
     }
 
-    $this->_params['receive_date'] = $now;
+    if (empty($this->_params['receive_date'])) {
+      $this->_params['receive_date'] = $now;
+    }
 
     $this->set('params', $this->_params);
 
@@ -580,9 +615,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       if (!empty($this->_params['is_email_receipt']) && $sendReceipt) {
         $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
       }
-      if ($sendReceipt) {
-        $statusMsg .= ' ' . ts('Email has been sent successfully');
-      }
 
       CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
       $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view',
@@ -603,7 +635,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       unset($event['start_date']);
       unset($event['end_date']);
 
-      //$this-assign('component', $this->_component);
+      $this->assign('event', $event);
       $this->assign('isShowLocation', $event['is_show_location']);
       if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
         $locationParams = array(
@@ -627,15 +659,17 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
     else {
       $balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
+      $paymentsComplete = ($balance == 0) ? 1 : 0;
       $this->assign('amountOwed', $balance);
       $this->assign('totalAmount', $this->_amtTotal);
       $this->assign('paymentAmount', $params['total_amount']);
+      $this->assign('paymentsComplete', $paymentsComplete);
     }
     $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));
+    $this->assign('receive_date', CRM_Utils_Array::value('trxn_date', $params));
     $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
     if (array_key_exists('payment_instrument_id', $params)) {
       $this->assign('paidBy',
index d7b143ffa1d36ffe44a8c983d52672f46b970834..d69b32ff7dba9ca3850e56f51c1730e9e9522e8e 100644 (file)
@@ -9,6 +9,8 @@
 {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}
+{capture assign=emptyBlockStyle }style="padding: 10px; border-bottom: 1px solid #999;background-color: #f7f7f7;"{/capture}
+{capture assign=emptyBlockValueStyle }style="padding: 10px; border-bottom: 1px solid #999;"{/capture}
 
 <p>Dear {$contactDisplayName}</p>
 <center>
@@ -32,7 +34,9 @@
       <p>{ts}Please print this confirmation for your records.{/ts}</p>
     </td>
   </tr>
-  
+  <tr>
+   <td>
+    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
   {if $isRefund}
   <tr>
     <th {$headerStyle}>{ts}Refund Details{/ts}</th>
       <td {$valueStyle}>
        {$totalAmount|crmMoney}
       </td>
+      </tr>
+      <tr>
       <td {$labelStyle}>
        {ts}This Payment Amount{/ts}
       </td>
       <td {$valueStyle}>
        {$paymentAmount|crmMoney}
       </td>
+      </tr>
+     <tr>
       <td {$labelStyle}>
        {ts}Balance Owed{/ts}
       </td>
-      <td>
+       <td {$valueStyle}>
        {$amountOwed|crmMoney}
       </td> {* This will be zero after final payment. *}
+     </tr>
+     <tr> <td {$emptyBlockStyle}></td>
+     <td {$emptyBlockValueStyle}></td></tr>
       {if $paymentsComplete}
+      <tr>
       <td colspan='2' {$valueStyle}>
        {ts}Thank-you. This completes your payment for {if $component eq 'event'}{$event.event_title}{/if}.{/ts}
       </td>
+     </tr>
       {/if}
-    </tr>
   {/if}
   {if $receive_date}
     <tr>
       </td>
     </tr>
   {/if}
+  </table>
+  </td>
+  </tr>
     <tr>
       <td>
        <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-         {if $contributeMode ne 'notify' and !$isAmountzero}
+         {if $contributeMode eq 'direct' and !$isAmountzero}
           <tr>
             <th {$headerStyle}>
              {ts}Billing Name and Address{/ts}
index 938fd8a33327699f07ba358366c8c2e601921f79..35a37f5e5f7ed12b6ee15a67bcf4c3007e43a334 100644 (file)
@@ -30,6 +30,7 @@ Dear {$contactDisplayName}
 {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}.
@@ -47,7 +48,7 @@ Dear {$contactDisplayName}
 {if $checkNumber}
 {ts}Check Number{/ts}: {$checkNumber}
 {/if}
-{if $contributeMode ne 'notify' and !$isAmountzero}
+{if $contributeMode eq 'direct' and !$isAmountzero}
 
 ===============================================================================
 
@@ -112,4 +113,4 @@ Dear {$contactDisplayName}
 
 {ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
 {/if}
-{/if}
\ No newline at end of file
+{/if}
index d7b143ffa1d36ffe44a8c983d52672f46b970834..d69b32ff7dba9ca3850e56f51c1730e9e9522e8e 100644 (file)
@@ -9,6 +9,8 @@
 {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}
+{capture assign=emptyBlockStyle }style="padding: 10px; border-bottom: 1px solid #999;background-color: #f7f7f7;"{/capture}
+{capture assign=emptyBlockValueStyle }style="padding: 10px; border-bottom: 1px solid #999;"{/capture}
 
 <p>Dear {$contactDisplayName}</p>
 <center>
@@ -32,7 +34,9 @@
       <p>{ts}Please print this confirmation for your records.{/ts}</p>
     </td>
   </tr>
-  
+  <tr>
+   <td>
+    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
   {if $isRefund}
   <tr>
     <th {$headerStyle}>{ts}Refund Details{/ts}</th>
       <td {$valueStyle}>
        {$totalAmount|crmMoney}
       </td>
+      </tr>
+      <tr>
       <td {$labelStyle}>
        {ts}This Payment Amount{/ts}
       </td>
       <td {$valueStyle}>
        {$paymentAmount|crmMoney}
       </td>
+      </tr>
+     <tr>
       <td {$labelStyle}>
        {ts}Balance Owed{/ts}
       </td>
-      <td>
+       <td {$valueStyle}>
        {$amountOwed|crmMoney}
       </td> {* This will be zero after final payment. *}
+     </tr>
+     <tr> <td {$emptyBlockStyle}></td>
+     <td {$emptyBlockValueStyle}></td></tr>
       {if $paymentsComplete}
+      <tr>
       <td colspan='2' {$valueStyle}>
        {ts}Thank-you. This completes your payment for {if $component eq 'event'}{$event.event_title}{/if}.{/ts}
       </td>
+     </tr>
       {/if}
-    </tr>
   {/if}
   {if $receive_date}
     <tr>
       </td>
     </tr>
   {/if}
+  </table>
+  </td>
+  </tr>
     <tr>
       <td>
        <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-         {if $contributeMode ne 'notify' and !$isAmountzero}
+         {if $contributeMode eq 'direct' and !$isAmountzero}
           <tr>
             <th {$headerStyle}>
              {ts}Billing Name and Address{/ts}
index 938fd8a33327699f07ba358366c8c2e601921f79..35a37f5e5f7ed12b6ee15a67bcf4c3007e43a334 100644 (file)
@@ -30,6 +30,7 @@ Dear {$contactDisplayName}
 {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}.
@@ -47,7 +48,7 @@ Dear {$contactDisplayName}
 {if $checkNumber}
 {ts}Check Number{/ts}: {$checkNumber}
 {/if}
-{if $contributeMode ne 'notify' and !$isAmountzero}
+{if $contributeMode eq 'direct' and !$isAmountzero}
 
 ===============================================================================
 
@@ -112,4 +113,4 @@ Dear {$contactDisplayName}
 
 {ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
 {/if}
-{/if}
\ No newline at end of file
+{/if}