public function preProcess() {
$config = CRM_Core_Config::singleton();
parent::preProcess();
-
+
// lineItem isn't set until Register postProcess
$this->_lineItem = $this->get('lineItem');
$this->_paymentProcessor = $this->get('paymentProcessor');
-
+
if ($this->_contributeMode == 'express') {
// rfp == redirect from paypal
$rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean',
$this->_params['payer_status'] = $expressParams['payer_status'];
CRM_Core_Payment_Form::mapParams($this->_bltID, $expressParams, $this->_params, FALSE);
-
+
// fix state and country id if present
if (!empty($this->_params["billing_state_province_id-{$this->_bltID}"]) && $this->_params["billing_state_province_id-{$this->_bltID}"]) {
$this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params['amount'] = $this->get('amount');
$this->_useForMember = $this->get('useForMember');
-
+
if (isset($this->_params['amount'])) {
$priceField = new CRM_Price_DAO_Field();
$priceField->price_set_id = $this->_params['priceSetId'];
if ($locType == 'Primary') {
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$locType = $defaultLocationType->id;
- }
-
+ }
+
if ($field == 'country') {
$value = CRM_Core_PseudoConstant::countryIsoCode($value);
}
elseif ($field == 'state_province') {
$value = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value);
}
-
+
$isPrimary = 1;
if (isset($this->_params['onbehalf_location']['address'])
&& count($this->_params['onbehalf_location']['address']) > 0) {
$isPrimary = 0;
}
-
+
$this->_params['onbehalf_location']['address'][$locType][$field] = $value;
if (!CRM_Utils_Array::value('is_primary', $this->_params['onbehalf_location']['address'][$locType])) {
$this->_params['onbehalf_location']['address'][$locType]['is_primary'] = $isPrimary;
foreach ($params['onbehalf'] as $fld => $values) {
if (strstr($fld, 'custom_')) {
$behalfOrganization[$fld] = $values;
- }
+ }
elseif (!(strstr($fld, '-'))) {
if (in_array($fld, array(
'contribution_campaign_id', 'member_campaign_id'))) {
}
else {
$behalfOrganization[$fld] = $values;
- }
+ }
$this->_params[$fld] = $values;
}
}
}
else {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'contact_type');
- $contactID = &CRM_Contact_BAO_Contact::createProfileContact($params,
+ $contactID = CRM_Contact_BAO_Contact::createProfileContact($params,
$fields,
$contactID,
$addToGroups,
$membershipParams['types_terms'] = $membershipTypeTerms;
}
if (CRM_Utils_Array::value('selectMembership', $membershipParams)) {
- CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
- $this, $premiumParams, $customFieldsFormatted,
- $fieldTypes
- );
+ CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
+ $this, $premiumParams, $customFieldsFormatted,
+ $fieldTypes
+ );
}
}
else {
$this->assign('option', CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams));
$periodType = $productDAO->period_type;
-
+
if ($periodType) {
$fixed_period_start_day = $productDAO->fixed_period_start_day;
$duration_unit = $productDAO->duration_unit;
if ($daoContrProd->find(TRUE)) {
$params['id'] = $daoContrProd->id;
}
-
+
CRM_Contribute_BAO_Contribution::addPremium($params);
- if ($productDAO->cost && CRM_Utils_Array::value('financial_type_id', $params)) {
+ if ($productDAO->cost && CRM_Utils_Array::value('financial_type_id', $params)) {
$trxnParams = array(
'cost' => $productDAO->cost,
'currency' => $productDAO->currency,
if ($params['amount']) {
$contribParams['line_item'] = $form->_lineItem;
- //add contribution record
- $contribution = &CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
+ h//add contribution record
+ $contribution = CRM_Contribute_BAO_Contribution::add($contribParams, $ids);
}
-
+
// process soft credit / pcp pages
CRM_Contribute_Form_Contribution_Confirm::processPcpSoft($params, $contribution);
-
+
//handle pledge stuff.
if (
!CRM_Utils_Array::value('separate_membership_payment', $form->_params) &&
$contactID,
'email-' . $form->_bltID
);
-
+
//create contribution activity w/ individual and target
//activity w/ organisation contact id when onbelf, CRM-4027
$targetContactID = NULL;
* Create the recurring contribution record
*
*/
- function processRecurringContribution(&$form, &$params, $contactID, $contributionType, $online = TRUE) {
+ static function processRecurringContribution(&$form, &$params, $contactID, $contributionType, $online = TRUE) {
// return if this page is not set for recurring
// or the user has not chosen the recurring option
//don't create contact - possibly the form was left blank
return null;
}
-
+
//assign to template for email receipt
$honor_block_is_active = $this->get('honor_block_is_active');
-
+
$this->assign('honor_block_is_active', $honor_block_is_active);
$this->assign('honor_block_title', CRM_Utils_Array::value('honor_block_title', $this->_values));
'entity_table' => 'civicrm_contribution_page',
'entity_id' => $this->_id,
);
- $defaults['onbehalf_profile_id'] = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+ $onBehalfIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+ if ($onBehalfIDs) {
+ // get the first one only
+ $defaults['onbehalf_profile_id'] = $onBehalfIDs[0];
+ }
}
else {
CRM_Utils_System::setTitle(ts('Title and Settings'));
) {
$errors['onbehalf_profile_id'] = ts('Please select a profile to collect organization information on this contribution page.');
}
-
+
//CRM-11494
$start = CRM_Utils_Date::processDate($values['start_date']);
$end = CRM_Utils_Date::processDate($values['end_date']);
}
//dont allow on behalf of save when
- //pre or post profile consists of membership fields
+ //pre or post profile consists of membership fields
if ($contributionPageId && CRM_Utils_Array::value('is_organization', $values)) {
$ufJoinParams = array(
'module' => 'CiviContribute',
'entity_table' => 'civicrm_contribution_page',
'entity_id' => $contributionPageId,
);
-
+
list($contributionProfiles['custom_pre_id'],
$contributionProfiles['custom_post_id']
) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
if ($contributionProfiles['custom_post_id']) {
$postProfileType = CRM_Core_BAO_UFField::getProfileType($contributionProfiles['custom_post_id']);
if ($postProfileType == 'Membership') {
- $conProfileType = empty($conProfileType) ? "'Includes Profile (bottom of page)'" : "{$conProfileType} and 'Includes Profile (bottom of page)'";
+ $conProfileType = empty($conProfileType) ? "'Includes Profile (bottom of page)'" : "{$conProfileType} and 'Includes Profile (bottom of page)'";
}
}
if (!empty($conProfileType)) {
$ids = implode(',', $entities);
$queryString = "SELECT cp.id as id, cp.title as title, cp.start_date as startDate, cp.end_date as endDate,ct.name as type
FROM civicrm_contribution_page cp, civicrm_financial_type ct
-WHERE ct.id = cp.financial_type_id AND
+WHERE ct.id = cp.financial_type_id AND
cp.id IN ($ids) AND
cp.is_active = 1;";
$crmDAO = CRM_Core_DAO::executeQuery($queryString);
}
CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
$totalPrice += $lineItem[$optionValueId]['line_total'];
- if ($component) {
+ if (
+ $component &&
+ isset($lineItem[$optionValueId]['auto_renew']) &&
+ is_numeric($lineItem[$optionValueId]['auto_renew'])
+ ) {
$autoRenew[$lineItem[$optionValueId]['auto_renew']] += $lineItem[$optionValueId]['line_total'];
}
break;
}
CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
$totalPrice += $lineItem[$optionValueId]['line_total'];
- if ($component) {
+ if (
+ $component &&
+ isset($lineItem[$optionValueId]['auto_renew']) &&
+ is_numeric($lineItem[$optionValueId]['auto_renew'])
+ ) {
$autoRenew[$lineItem[$optionValueId]['auto_renew']] += $lineItem[$optionValueId]['line_total'];
}
break;
CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
foreach ($optionIds as $optionId) {
$totalPrice += $lineItem[$optionId]['line_total'];
- if ($component) {
+ if (
+ $component &&
+ isset($lineItem[$optionId]['auto_renew']) &&
+ is_numeric($lineItem[$optionId]['auto_renew'])
+ ) {
$autoRenew[$lineItem[$optionId]['auto_renew']] += $lineItem[$optionId]['line_total'];
}
}
if ($component) {
foreach ($autoRenew as $dontCare => $eachAmount) {
if (!$eachAmount) {
- unset($autoRenew[$dontCare]);
+ unset($autoRenew[$dontCare]);
}
}
if (count($autoRenew) > 1 ) {
}
/**
- * Check if price set id provides option for
+ * Check if price set id provides option for
* user to select both auto-renew and non-auto-renew memberships
*
- * @access public
+ * @access public
* @static
*
*/
public static function checkMembershipPriceSet($id) {
- $query =
+ $query =
"
SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew
FROM civicrm_price_field_value pfv
//2 membership types can be selected
//instead of comparing all of them
while ($dao->fetch()) {
- //temp fix for #CRM-10370
+ //temp fix for #CRM-10370
//if its NULL consider it '0' i.e. 'No auto-renew option'
$daoAutoRenew = $dao->auto_renew;
if ($daoAutoRenew === NULL) {