<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
/**
* create all common fields needed for a credit card or direct debit transaction
*
+ * @param $form
+ *
* @return void
* @access protected
*/
'attributes' => array(
'' => ts('- select -')) +
CRM_Core_PseudoConstant::stateProvince(),
- 'is_required' => self::checkRequiredStateProvince($form),
+ 'is_required' => self::checkRequiredStateProvince($form, "billing_country_id-{$bltID}"),
);
$form->_paymentFields["billing_postal_code-{$bltID}"] = array(
/**
* create all fields needed for a credit card transaction
*
+ * @param $form
+ *
* @return void
* @access public
*/
/**
* Function to add all the credit card fields
*
+ * @param $form
+ * @param bool $useRequired
+ *
* @return void
* @access public
*/
);
$form->addRule('credit_card_exp_date',
- ts('Credit card expiration date cannot be a past date.'),
+ ts('Card expiration date cannot be a past date.'),
'currentDate', TRUE
);
/**
* Function to add all the direct debit fields
*
- * @return None
+ * @return void
* @access public
*/
function buildDirectDebit(&$form, $useRequired = FALSE) {
if (!empty($values['credit_card_number']) &&
!CRM_Utils_Rule::creditCardNumber($values['credit_card_number'], $values['credit_card_type'])
) {
- $errors['credit_card_number'] = ts('Please enter a valid Credit Card Number');
+ $errors['credit_card_number'] = ts('Please enter a valid Card Number');
}
if (!empty($values['cvv2']) &&
!CRM_Utils_Rule::cvv($values['cvv2'], $values['credit_card_type'])
) {
- $errors['cvv2'] = ts('Please enter a valid Credit Card Verification Number');
+ $errors['cvv2'] = ts('Please enter a valid Card Verification Number');
}
}
elseif (!empty($values['credit_card_number'])) {
- $errors['credit_card_number'] = ts('Please enter a valid Credit Card Number and Type');
+ $errors['credit_card_number'] = ts('Please enter a valid Card Number');
}
}
/**
* function to map address fields
*
+ * @param $id
+ * @param $src
+ * @param $dst
+ * @param bool $reverse
+ *
* @return void
* @static
*/
/**
* function to return state/province is_required = true/false
*
+ * @param obj $form: Form object
+ * @param string $name: Country index name on $_submitValues array
+ * @param bool $onBehalf: Is 'On Behalf Of' profile?
+ *
+ * @return bool
+ * TRUE/FALSE for is_required if country consist/not consist of state/province respectively
+ * @static
*/
- static function checkRequiredStateProvince($form) {
+ static function checkRequiredStateProvince($form, $name, $onBehalf = FALSE) {
// If selected country has possible values for state/province mark the
// state/province field as required.
$config = CRM_Core_Config::singleton();
$stateProvince = new CRM_Core_DAO_StateProvince();
- $stateProvince->country_id = CRM_Utils_Array::value("billing_country_id-{$form->_bltID}", $form->_submitValues);
+
+ if ($onBehalf) {
+ $stateProvince->country_id = CRM_Utils_Array::value($name, $form->_submitValues['onbehalf']);
+ }
+ else {
+ $stateProvince->country_id = CRM_Utils_Array::value($name, $form->_submitValues);
+ }
+
+ $limitCountryId = $stateProvince->country_id;
if ($stateProvince->count() > 0) {
// check that the state/province data is not excluded by a
$limitIds = array_merge($limitIds, array_keys($countryIsoCodes, $code));
}
- $limitCountryId = CRM_Utils_Array::value("billing_country_id-{$form->_bltID}", $form->_submitValues);
if ($limitCountryId && in_array($limitCountryId, $limitIds)) {
return TRUE;
}