}
- /**
- * Assign billing type id to bltID.
- *
- * @throws CRM_Core_Exception
- * @return void
- */
- public function assignBillingType() {
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $this->_bltID = array_search('Billing', $locationTypes);
- if (!$this->_bltID) {
- throw new CRM_Core_Exception(ts('Please set a location type of %1', array(1 => 'Billing')));
- }
- $this->set('bltID', $this->_bltID);
- $this->assign('bltID', $this->_bltID);
- }
-
/**
* Assign $this->processors, $this->recurPaymentProcessors, and related Smarty variables
*/
throw new CRM_Contribute_Exception_InactiveContributionPageException(ts('The page you requested is currently unavailable.'), $this->_id);
}
- // also check for billing information.
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- // CRM-8108 remove ts around Billing location type
- //$this->_bltID = array_search( ts('Billing'), $locationTypes );
- $this->_bltID = array_search('Billing', $locationTypes);
- if (!$this->_bltID) {
- CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
- }
- $this->set('bltID', $this->_bltID);
+ $this->assignBillingType();
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
}
$this->assign('paymentProcessor', $this->_paymentProcessor);
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $this->_bltID = array_search('Billing', $locationTypes);
- $this->assign('bltID', $this->_bltID);
- if (!$this->_bltID) {
- CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
- }
+ $this->assignBillingType();
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
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.
*/
*
* @param string $title
* The title of the form.
- *
- * @return void
*/
public function setTitle($title) {
$this->_title = $title;
}
+ /**
+ * Assign billing type id to bltID.
+ *
+ * @throws CRM_Core_Exception
+ */
+ public function assignBillingType() {
+ $this->_bltID = CRM_Core_BAO_Location::getBillingLocationId();
+ $this->set('bltID', $this->_bltID);
+ $this->assign('bltID', $this->_bltID);
+ }
+
/**
* Setter function for options.
*
$this->checkWaitingList();
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- $this->_bltID = array_search('Billing', $locationTypes);
- $this->assign('bltID', $this->_bltID);
+ $this->assignBillingType();
$event_titles = array();
foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
unset($this->_values['additional_custom_post_id']);
}
}
- // get the billing location type
- $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
- // CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
- //$this->_bltID = array_search( ts('Billing'), $locationTypes );
- $this->_bltID = array_search('Billing', $locationTypes);
- if (!$this->_bltID) {
- CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
- }
- $this->set('bltID', $this->_bltID);
+
+ $this->assignBillingType();
if ($this->_values['event']['is_monetary']) {
CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);