<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
// see function comment block for explanation of this
return;
}
-
+ $this->_defaults = array();
$contactID = $this->getContactID();
- if ($contactID) {
- //@todo CRM-11915 I observed that even when the billing block is not present the routine to retrieve the billing defaults is still called - which seems a bit redundant.
- $names = array(
- 'first_name', 'middle_name', 'last_name',
- "street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}",
- "country_id-{$this->_bltID}", "state_province_id-{$this->_bltID}",
- );
-
- foreach ($names as $name) {
- $fields[$name] = 1;
- }
- $fields["state_province-{$this->_bltID}"] = 1;
- $fields["country-{$this->_bltID}"] = 1;
- $fields["email-{$this->_bltID}"] = 1;
- $fields['email-Primary'] = 1;
-
- CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $fields, $this->_defaults);
-
- // use primary email address if billing email address is empty
- if (empty($this->_defaults["email-{$this->_bltID}"]) &&
- !empty($this->_defaults['email-Primary'])
- ) {
- $this->_defaults["email-{$this->_bltID}"] = $this->_defaults['email-Primary'];
- }
+ $billingDefaults = $this->getProfileDefaults('Billing', $contactID);
+ $this->_defaults = array_merge($this->_defaults, $billingDefaults);
- foreach ($names as $name) {
- if (isset($this->_defaults[$name])) {
- $this->_defaults['billing_' . $name] = $this->_defaults[$name];
- }
- }
- }
$config = CRM_Core_Config::singleton();
// set default country from config if no country set
+ // note the effect of this is to set the billing country to default to the site default
+ // country if the person has an address but no country (for anonymous country is set above)
+ // this could have implications if the billing profile is filled but hidden.
+ // this behaviour has been in place for a while but the use of js to hide things has increased
if (!CRM_Utils_Array::value("billing_country_id-{$this->_bltID}", $this->_defaults)) {
$this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
}
+ // set default state/province from config if no state/province set
+ if (!CRM_Utils_Array::value("billing_state_province_id-{$this->_bltID}", $this->_defaults)) {
+ $this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
+ }
+
if ($this->_snippet) {
// now fix all state country selectors
CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
if (!$this->_allowConfirmation || $this->_additionalParticipantIds) {
// Hardcode maximum number of additional participants here for now. May need to make this configurable per event.
// Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self")
- $additionalOptions = array('' => ts('1'), 1 => ts('2'), 2 => ts('3'), 3 => ts('4'), 4 => ts('5'),
- 5 => ts('6'), 6 => ts('7'), 7 => ts('8'), 8 => ts('9'), 9 => ts('10'),
+ $additionalOptions = array(
+ '' => '1', 1 => '2', 2 => '3', 3 => '4', 4 => '5',
+ 5 => '6', 6 => '7', 7 => '8', 8 => '9', 9 => '10',
);
$element = $this->add('select', 'additional_participants',
ts('How many people are you registering?'),
self::buildAmount($this);
}
- $pps = NULL;
+ $pps = array();
+ //@todo this processor adding fn is another one duplicated on contribute - a shared
+ // common class would make this sort of thing extractable
+ $onlinePaymentProcessorEnabled = FALSE;
if (!empty($this->_paymentProcessors)) {
- $pps = $this->_paymentProcessors;
- foreach ($pps as $key => & $name) {
+ foreach ($this->_paymentProcessors as $key => $name) {
+ if($name['billing_mode'] == 1) {
+ $onlinePaymentProcessorEnabled = TRUE;
+ }
$pps[$key] = $name['name'];
}
}
-
+ if($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) {
+ //@todo we are blocking for multiple registrations because we haven't tested
+ $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
+ }
if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) &&
($this->_allowConfirmation || (!$this->_requireApproval && !$this->_allowWaitlist))
) {
if ($this->_values['event']['is_monetary']) {
if (count($pps) > 1) {
$this->addRadio('payment_processor', ts('Payment Method'), $pps,
- NULL, " ", TRUE
+ NULL, " "
);
}
elseif (!empty($pps)) {
}
if ($self->_values['event']['is_monetary']) {
+ if (empty($self->_requireApproval) && $fields['amount'] > 0 && !isset($fields['payment_processor'])) {
+ $errors['payment_processor'] = ts('Please select a Payment Method');
+ }
if (is_array($self->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, $this);
$error = $payment->checkConfig($self->_mode);
}
}
- $isZeroAmount = $skipPayementValidation = FALSE;
+ $isZeroAmount = $skipPaymentValidation = FALSE;
if (CRM_Utils_Array::value('priceSetId', $fields)) {
if (CRM_Utils_Array::value('amount', $fields) == 0) {
$isZeroAmount = TRUE;
}
if ($isZeroAmount && !($self->_forcePayement && CRM_Utils_Array::value('additional_participants', $fields))) {
- $skipPayementValidation = TRUE;
+ $skipPaymentValidation = TRUE;
}
// also return if paylater mode or zero fees for valid members
if (CRM_Utils_Array::value('is_pay_later', $fields) ||
CRM_Utils_Array::value('bypass_payment', $fields) ||
- $skipPayementValidation ||
+ $skipPaymentValidation ||
(!$self->_allowConfirmation && ($self->_requireApproval || $self->_allowWaitlist))
) {
return empty($errors) ? TRUE : $errors;