CRM-20610 make it possible to enable the payment form
authoreileen <emcnaughton@wikimedia.org>
Fri, 2 Mar 2018 03:15:28 +0000 (16:15 +1300)
committereileen <emcnaughton@wikimedia.org>
Fri, 2 Mar 2018 03:17:37 +0000 (16:17 +1300)
CRM/Contribute/Form/Contribution.php
CRM/Financial/Form/PaymentEdit.php
templates/CRM/Contribute/Form/Contribution.tpl

index 535cfc4c4e4ae61233fe5aebd6aea57cdb7fdf8b..1a3ac14f9aff00583935d207d3fee9303e380e8d 100644 (file)
@@ -237,6 +237,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     // Get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!empty($this->_id)) {
+      $this->assignPaymentInfoBlock();
       $this->assign('contribID', $this->_id);
     }
 
@@ -627,11 +628,13 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     $paymentInstrument = FALSE;
     if (!$this->_mode) {
+      // payment_instrument isn't required in edit and will not be present when payment block is enabled.
+      $required = $this->_id ? FALSE : TRUE;
       $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
       $paymentInstrument = $this->add('select', 'payment_instrument_id',
         ts('Payment Method'),
         array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
-        TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);")
+        $required, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);")
       );
     }
 
index 84f0a0d0de57d823e1efd8d70f549784a589c257..1a439aa03b4d0143009c9f7755f6aab9e1e0456c 100644 (file)
@@ -71,7 +71,7 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form {
 
     $this->_values = civicrm_api3('FinancialTrxn', 'getsingle', array('id' => $this->_id));
     if (!empty($this->_values['payment_processor_id'])) {
-      CRM_Core_Error::statusBounce(ts('You cannot update this payment'));
+      CRM_Core_Error::statusBounce(ts('You cannot update this payment as it is tied to a payment processor'));
     }
   }
 
index 78b55f37a630aab454ce1ae911973dce397a847f..9f47e46eaead9a61523a0acbcbb18b573326e1cc 100644 (file)
         {if $contribution_status_id eq 2}{if $is_pay_later }: {ts}Pay Later{/ts} {else}: {ts}Incomplete Transaction{/ts}{/if}{/if}
         </td>
         <td>
-        {if $contactId && $contribID && $contributionMode EQ null && $contribution_status_id eq 2}
+        {if !$isUsePaymentBlock && $contactId && $contribID && $contributionMode EQ null && $contribution_status_id eq 2}
           {capture assign=payNowLink}{crmURL p='civicrm/contact/view/contribution' q="reset=1&action=update&id=`$contribID`&cid=`$contactId`&context=`$context`&mode=live"}{/capture}
           <a class="open-inline action-item crm-hover-button" href="{$payNowLink}">&raquo; {ts}Pay with Credit Card{/ts}</a>
         {/if}
       <legend>
         {ts}Payment Details{/ts}
       </legend>
+      {if $isUsePaymentBlock}
+        {include file="CRM/Contribute/Form/PaymentInfoBlock.tpl"}
+      {else}
         <table class="form-layout-compressed" >
           <tr class="crm-contribution-form-block-payment_instrument_id">
             <td class="label">{$form.payment_instrument_id.label}</td>
             <td {$valueStyle}>{$form.trxn_id.html} {help id="id-trans_id"}</td>
           </tr>
         </table>
+      {/if}
       </fieldset>
   {/if}
 
-  {include file='CRM/Core/BillingBlockWrapper.tpl'}
+  {if !$isUsePaymentBlock}
+    {include file='CRM/Core/BillingBlockWrapper.tpl'}
+  {/if}
 
     <!-- start of soft credit -->
     {if !$payNow}