$defaultLocationId = $defaultLocation->id;
}
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $billingLocationTypeId = array_search('Billing', $locationTypes);
+ $billingLocationTypeId = CRM_Core_BAO_LocationType::getBilling();
$blocks = array('email', 'phone', 'im', 'openid');
// get the billing location type
if (!array_key_exists('related_contact', $values)) {
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $billingLocationTypeId = array_search('Billing', $locationTypes);
+ $billingLocationTypeId = CRM_Core_BAO_LocationType::getBilling();
}
else {
// presence of related contact implies onbehalf of org case,
TRUE, NULL, FALSE, TRUE
);
// set email in the template here
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $billingLocationTypeId = array_search('Billing', $locationTypes);
- if ($billingLocationTypeId) {
- list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, $billingLocationTypeId);
+ if (CRM_Core_BAO_LocationType::getBilling()) {
+ list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id,
+ FALSE, CRM_Core_BAO_LocationType::getBilling());
}
// get primary location email if no email exist( for billing location).
if (!$email) {
return $location;
}
- /**
- * Get the ID of the database billing location.
- *
- * @return int
- * Billing location type id.
- *
- * @throws \CRM_Core_Exception
- */
- public static function getBillingLocationId() {
- static $billingTypeID = NULL;
- if ($billingTypeID) {
- return $billingTypeID;
- }
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $billingTypeID = array_search('Billing', $locationTypes);
- if (!$billingTypeID) {
- throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
- }
- return $billingTypeID;
- }
/**
* Creates the entry in the civicrm_loc_block.
*/
* @throws CRM_Core_Exception
*/
public function assignBillingType() {
- $this->_bltID = CRM_Core_BAO_Location::getBillingLocationId();
+ $this->_bltID = CRM_Core_BAO_LocationType::getBilling();
$this->set('bltID', $this->_bltID);
$this->assign('bltID', $this->_bltID);
}
*
* @return array
*/
- public function getBillingAddressFields($billingLocationID) {
+ public function getBillingAddressFields($billingLocationID = NULL) {
+ if (!$billingLocationID) {
+ // Note that although the billing id is passed around the forms the idea that it would be anything other than
+ // the result of the function below doesn't seem to have eventuated.
+ // So taking this as a param is possibly something to be removed in favour of the standard default.
+ $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
+ }
if ($this->_paymentProcessor['billing_mode'] != 1 && $this->_paymentProcessor['billing_mode'] != 3) {
return array();
}
* @return array
* Array of metadata for address fields.
*/
- public function getBillingAddressFieldsMetadata($billingLocationID) {
+ public function getBillingAddressFieldsMetadata($billingLocationID = NULL) {
+ if (!$billingLocationID) {
+ // Note that although the billing id is passed around the forms the idea that it would be anything other than
+ // the result of the function below doesn't seem to have eventuated.
+ // So taking this as a param is possibly something to be removed in favour of the standard default.
+ $billingLocationID = CRM_Core_BAO_LocationType::getBilling();
+ }
$metadata = array();
$metadata['billing_first_name'] = array(
'htmlType' => 'text',
* @return bool
*/
public function getBillingID(&$ids) {
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- // CRM-8108 remove the ts around the Billing location type
- //$ids['billing'] = array_search( ts('Billing'), $locationTypes );
- $ids['billing'] = array_search('Billing', $locationTypes);
+ $ids['billing'] = CRM_Core_BAO_LocationType::getBilling();
if (!$ids['billing']) {
CRM_Core_Error::debug_log_message(ts('Please set a location type of %1', array(1 => 'Billing')));
echo "Failure: Could not find billing location type<p>";
*/
function _civicrm_api3_profile_getbillingpseudoprofile(&$params) {
- $locations = civicrm_api3('address', 'getoptions', array('field' => 'location_type_id', 'context' => 'validate'));
- $locationTypeID = array_search('Billing', $locations['values']);
+ $locationTypeID = CRM_Core_BAO_LocationType::getBilling();
if (empty($params['contact_id'])) {
$config = CRM_Core_Config::singleton();