From: kurund Date: Tue, 27 Aug 2013 12:27:45 +0000 (+0530) Subject: CRM-13282, fixed state default for membership billing block and code cleanup for... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cc44e307ac7b07497853a6cacb9cfb0acff12435;p=civicrm-core.git CRM-13282, fixed state default for membership billing block and code cleanup for offline event registration via CC ---------------------------------------- * CRM-13282: Prefill billing address on back-office contribution via credit card and membership via credit card using profile.get api http://issues.civicrm.org/jira/browse/CRM-13282 --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 98f661b8f3..194b2c1944 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -318,7 +318,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); $defaults = array_merge($defaults, $billingDefaults); - // now fix all state country selectors (FIXME: what does this do ?? dgg) + // now fix all state country selectors, set correct state based on country CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults); } diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index 13017940d2..f71d404802 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -126,49 +126,22 @@ class CRM_Event_Form_EventFees { } if ($form->_mode) { - $fields = array(); - - foreach ($form->_fields as $name => $dontCare) { - $fields[$name] = 1; - } - - $names = array( - 'first_name', 'middle_name', 'last_name', "street_address-{$form->_bltID}", - "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "country_id-{$form->_bltID}", - "state_province_id-{$form->_bltID}", - ); - foreach ($names as $name) { - $fields[$name] = 1; - } - - $fields["state_province-{$form->_bltID}"] = 1; - $fields["country-{$form->_bltID}"] = 1; - $fields["email-{$form->_bltID}"] = 1; - $fields['email-Primary'] = 1; - - if ($form->_contactId) { - CRM_Core_BAO_UFGroup::setProfileDefaults($form->_contactId, $fields, $form->_defaults); - } - - // use primary email address if billing email address is empty - if (empty($form->_defaults["email-{$form->_bltID}"]) && - !empty($form->_defaults['email-Primary']) - ) { - $defaults[$form->_pId]["email-{$form->_bltID}"] = $form->_defaults['email-Primary']; - } - - foreach ($names as $name) { - if (!empty($form->_defaults[$name])) { - $defaults[$form->_pId]['billing_' . $name] = $form->_defaults[$name]; - } - } - $config = CRM_Core_Config::singleton(); // set default country from config if no country set if (!CRM_Utils_Array::value("billing_country_id-{$form->_bltID}", $defaults[$form->_pId])) { $defaults[$form->_pId]["billing_country_id-{$form->_bltID}"] = $config->defaultContactCountry; } + if (!CRM_Utils_Array::value("billing_state_province_id-{$form->_bltID}", $defaults)) { + $defaults[$form->_pId]["billing_state_province_id-{$form->_bltID}"] = $config->defaultContactStateProvince; + } + + $billingDefaults = $form->getProfileDefaults('Billing', $form->_contactId); + $defaults[$form->_pId] = array_merge($defaults[$form->_pId], $billingDefaults); + + // now fix all state country selectors, set correct state based on country + CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults[$form->_pId]); + // // hack to simplify credit card entry for testing // $defaults[$form->_pId]['credit_card_type'] = 'Visa'; // $defaults[$form->_pId]['credit_card_number'] = '4807731747657838'; diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 4d760c6f09..811a7e6357 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -420,6 +420,9 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $billingDefaults = $this->getProfileDefaults('Billing', $this->_contactID); $defaults = array_merge($defaults, $billingDefaults); + + // now fix all state country selectors, set correct state based on country + CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults); // // hack to simplify credit card entry for testing // $defaults['credit_card_type'] = 'Visa';