Towards CRM-20392 (IIDA-108), code cleanup, removed cruft code
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 3 Apr 2017 22:16:45 +0000 (10:16 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 11 Apr 2017 07:35:48 +0000 (19:35 +1200)
CRM/Contribute/Form/AdditionalPayment.php
templates/CRM/Contribute/Form/AdditionalPayment.tpl

index b6cee86c1b75f7e8fd99350e96e6fa5fa8c2d788..703d524832a46ebb0caff72546774982aa254f3b 100644 (file)
@@ -176,20 +176,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
     $defaults = array();
     if ($this->_mode) {
-      $defaults = $this->_values;
-
-      $config = CRM_Core_Config::singleton();
-      // set default country from config if no country set
-      if (empty($defaults["billing_country_id-{$this->_bltID}"])) {
-        $defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
-      }
-
-      if (empty($defaults["billing_state_province_id-{$this->_bltID}"])) {
-        $defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
-      }
-
-      $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactId);
-      $defaults = array_merge($defaults, $billingDefaults);
+      CRM_Core_Payment_Form::setDefaultValues($this, $this->_contactId);
+      $defaults = array_merge($defaults, $this->_defaults);
     }
 
     if (empty($defaults['trxn_date']) && empty($defaults['trxn_date_time'])) {
@@ -209,6 +197,9 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     return $defaults;
   }
 
+  /**
+   * Build the form object.
+   */
   public function buildQuickForm() {
     if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) {
       $this->addButtons(array(
@@ -222,56 +213,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       );
       return;
     }
-    $ccPane = NULL;
-    if ($this->_mode) {
-      if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT
-      ) {
-        $ccPane = array(ts('Direct Debit Information') => 'DirectDebit');
-      }
-      else {
-        $ccPane = array(ts('Credit Card Information') => 'CreditCard');
-      }
-      $defaults = $this->_values;
-      $showAdditionalInfo = FALSE;
-
-      foreach ($ccPane as $name => $type) {
-        if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) ||
-          CRM_Utils_Array::value("hidden_{$type}", $defaults)
-        ) {
-          $showAdditionalInfo = TRUE;
-          $allPanes[$name]['open'] = 'true';
-        }
 
-        $urlParams = "snippet=4&formType={$type}";
-        if ($this->_mode) {
-          $urlParams .= "&mode={$this->_mode}";
-        }
-        $open = 'false';
-        if ($type == 'CreditCard' ||
-          $type == 'DirectDebit'
-        ) {
-          $open = 'true';
-        }
-
-        $allPanes[$name] = array(
-          'url' => CRM_Utils_System::url('civicrm/payment/add', $urlParams),
-          'open' => $open,
-          'id' => $type,
-        );
-
-        CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
-
-        $qfKey = $this->controller->_key;
-        $this->assign('qfKey', $qfKey);
-        $this->assign('allPanes', $allPanes);
-        $this->assign('showAdditionalInfo', $showAdditionalInfo);
-
-        if ($this->_formType) {
-          $this->assign('formType', $this->_formType);
-          return;
-        }
-      }
-    }
+    CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialTrxn');
 
     $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, NULL);
index 268da6ac6237bbcf3d246ad4c80949df029d0045..c8dc83a5e1dcba2973601110b3028ecf5d39579a 100644 (file)
@@ -58,8 +58,6 @@
        {include file="CRM/common/formButtons.tpl"}
     </div>
   {/if}
- {elseif $formType}
-  {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
 {else}
 
 <div class="crm-block crm-form-block crm-payment-form-block">
             <span class="description">{ts}Net value of the payment (Total Amount minus Fee).{/ts}</span></td></tr>
         </table>
       </div>
+      {include file='CRM/Core/BillingBlockWrapper.tpl'}
     </div>
 
-<div class="accordion ui-accordion ui-widget ui-helper-reset">
-  {* Additional Detail / Honoree Information / Premium Information *}
-    {foreach from=$allPanes key=paneName item=paneValue}
-
-      <div class="crm-accordion-wrapper crm-ajax-accordion crm-{$paneValue.id}-accordion {if $paneValue.open neq 'true'}collapsed{/if}">
-        <div class="crm-accordion-header" id="{$paneValue.id}">
-
-          {$paneName}
-        </div><!-- /.crm-accordion-header -->
-        <div class="crm-accordion-body">
-
-          <div class="{$paneValue.id}"></div>
-        </div><!-- /.crm-accordion-body -->
-      </div><!-- /.crm-accordion-wrapper -->
-
-    {/foreach}
-  </div>
-
-
-
     {literal}
     <script type="text/javascript">
 
             $('#receiptDate', $form).show();
           }
         }
-  
+
         // bind first click of accordion header to load crm-accordion-body with snippet
         $('#adjust-option-type', $form).hide();
         $('.crm-ajax-accordion .crm-accordion-header', $form).one('click', function() {
             CRM.loadPage(url, {target: $('div.' + id, $form)});
           }
         }
-        
+
         $('#fee_amount', $form).change( function() {
           var totalAmount = $('#total_amount', $form).val();
           var feeAmount = $('#fee_amount', $form).val();