Additional fixes
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 1 Sep 2016 12:00:12 +0000 (17:30 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 2 Sep 2016 04:44:30 +0000 (10:14 +0530)
CRM/Admin/Form/Preferences/Contribute.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/Main.php
CRM/Contribute/Form/Contribution/ThankYou.php
templates/CRM/Contribute/Form/Contribution/Main.tpl
tests/phpunit/WebTest/Contribute/OnlineContributionTest.php

index d8a10303884ebe725b00f28d7811ff9c63b95171..3d484f7541a02a9b5408237bbdc47d594ba36673 100644 (file)
@@ -248,9 +248,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
     else {
       $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
       $invoiceKey = array_search($setKey, $setting);
-      if (!empty($invoiceKey)) {
-        unset($setting[$invoiceKey]);
-      }
+      unset($setting[$invoiceKey]);
       $settingName = CRM_Core_DAO::VALUE_SEPARATOR .
         implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) .
         CRM_Core_DAO::VALUE_SEPARATOR;
index 2cc2edc77fcb6bed183434dd5d1c913146e09664..39af77a1cabcfbbee48becba0b7ba0d914e0ec46 100644 (file)
@@ -390,7 +390,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     $params = $this->_params;
     // make sure we have values for it
-    if (!empty($this->_values['honoree_profile_id']) && !empty($params['soft_credit_type_id'])) {
+    if (!empty($this->_values['honoree_profile_id']) && !empty($params['soft_credit_type_id']) && empty($this->_ccid)) {
       $honorName = NULL;
       $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
 
@@ -433,7 +433,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
       $this->set('option', $option);
     }
     $config = CRM_Core_Config::singleton();
-    if (in_array('CiviMember', $config->enableComponents)) {
+    if (in_array('CiviMember', $config->enableComponents) && empty($this->_ccid)) {
       if (isset($params['selectMembership']) &&
         $params['selectMembership'] != 'no_thanks'
       ) {
@@ -451,14 +451,16 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         $this->assign('membershipBlock', FALSE);
       }
     }
-    $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
-    $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+    if (empty($this->_ccid)) {
+      $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
+      $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+    }
 
     if (!empty($this->_values['onbehalf_profile_id']) &&
       !empty($params['onbehalf']) &&
       ($this->_values['is_for_organization'] == 2 ||
         !empty($params['is_for_organization'])
-      )
+      ) && empty($this->_ccid)
     ) {
       $fieldTypes = array('Contact', 'Organization');
       $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
@@ -1997,7 +1999,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
     // organization params in a separate variable, to make sure
     // normal behavior is continued. And use that variable to
     // process on-behalf-of functionality.
-    if (!empty($this->_values['onbehalf_profile_id'])) {
+    if (!empty($this->_values['onbehalf_profile_id']) && empty($this->_ccid)) {
       $behalfOrganization = array();
       $orgFields = array('organization_name', 'organization_id', 'org_option');
       foreach ($orgFields as $fld) {
index b3307f570c702105fb64d242414a56e03be8d87a..1fee2ce6c77eefbfff67d02eb43ce874a0bec2a7 100644 (file)
@@ -319,13 +319,15 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
   public function buildQuickForm() {
     // build profiles first so that we can determine address fields etc
     // and then show copy address checkbox
-    $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
-    $this->buildCustom($this->_values['custom_post_id'], 'customPost');
+    if (empty($this->_ccid)) {
+      $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
+      $this->buildCustom($this->_values['custom_post_id'], 'customPost');
 
-    // CRM-18399: used by template to pass pre profile id as a url arg
-    $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
+      // CRM-18399: used by template to pass pre profile id as a url arg
+      $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
 
-    $this->buildComponentForm($this->_id, $this);
+      $this->buildComponentForm($this->_id, $this);
+    }
 
     // Build payment processor form
     CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
@@ -1151,7 +1153,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu
       $this->set('amount_level', CRM_Utils_Array::value('amount_level', $params));
     }
 
-    if ($this->_ccid) {
+    if (!empty($this->_ccid)) {
       $this->set('lineItem', $this->_lineItem);
     }
     elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) {
index 753d41c7748ad11144822a33e58efed504b1f3b2..37c7b281a8e16c6751d23b8533167a3684437b42 100644 (file)
@@ -89,6 +89,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
    */
   public function buildQuickForm() {
     $this->assignToTemplate();
+    $this->_ccid = $this->get('ccid');
     $productID = $this->get('productID');
     $option = $this->get('option');
     $membershipTypeID = $this->get('membershipTypeID');
@@ -184,13 +185,15 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
     $this->_separateMembershipPayment = $this->get('separateMembershipPayment');
     $this->assign("is_separate_payment", $this->_separateMembershipPayment);
 
-    $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
-    $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+    if (empty($this->_ccid)) {
+      $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
+      $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
+    }
     if (!empty($this->_values['onbehalf_profile_id']) &&
       !empty($params['onbehalf']) &&
       ($this->_values['is_for_organization'] == 2 ||
         !empty($params['is_for_organization'])
-      )
+      ) && empty($this->_ccid)
     ) {
       $fieldTypes = array('Contact', 'Organization');
       $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
index 3121b9da89e1ebcf7f19fae3323403cb71d933ba..a093570ef3e7c8c7e31969353c8727ba4072626c 100644 (file)
   }
 
   function hidePayLater() {
+    cj('#billingcheckbox').hide();
+    cj('#billingcheckbox').next('label').hide();
     cj('input:radio[name="payment_processor_id"][value=0]').hide();
     cj('input:radio[name="payment_processor_id"][value=0]').next('label').hide();
   }
index e52ffdcc1cff3823fb512ba9bba91530171a950b..b3fe6192001d2fc8de12241142f58001bb4650d4 100644 (file)
@@ -505,7 +505,10 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
     $this->webtestVerifyTabularData($expected);
   }
 
- public function testOnlineContributionWithPayNowLink() {
+  /**
+   * CRM-19263 - Test online pay now functionality
+   */
+  public function testOnlineContributionWithPayNowLink() {
     $this->webtestLogin();
     $pageId = 1;
     $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=$pageId", 'is_pay_later');
@@ -584,7 +587,7 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
       1 => '$ 588.50',
       2 => '$ 98.50',
     );
-    foreach($amountValues as $row => $amount) {
+    foreach ($amountValues as $row => $amount) {
       $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[{$row}]/td[8]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
 
       // View Contribution Record and test for expected values
@@ -603,6 +606,11 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
     }
   }
 
+  /**
+   * Contribute using pay now link
+   * @param string $firstName
+   * @param bool $priceSet
+   */
   public function _testContributeWithPayNow($firstName, $priceSet = FALSE) {
     //user dashboard
     $this->openCiviPage("user", "reset=1");
@@ -638,6 +646,13 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
 
   }
 
+  /**
+   * Contribute with pay later
+   *
+   * @param int $pageId
+   * @param string $firstName
+   * @param bool $priceSet
+   */
   public function _testContributeWithPayLater($pageId, $firstName, $priceSet = FALSE) {
     $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
     $this->waitForElementPresent("email-5");
@@ -671,6 +686,14 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase {
     $this->assertElementContainsText("xpath=//div[@class='help']/div/p", $payLaterInstructionsText);
   }
 
+  /**
+   * Create test user
+   *
+   * @param string $firstName
+   * @param string $lastName
+   *
+   * @return string
+   */
   public function _testCreateUser($firstName, $lastName) {
     $this->open($this->sboxPath . "admin/people/create");