'address_id' => $addressID,
//setting to make available to hook - although seems wrong to set on form for BAO hook availability
'soft_credit_to' => $softCreditToID,
- 'line_item' => $lineItems
+ 'line_item' => $lineItems,
+ 'skipLineItem' => CRM_Utils_Array::value('skipLineItem', $params, 0)
);
if (!$online && isset($params['thankyou_date'])) {
$contributionParam['thankyou_date'] = $params['thankyou_date'];
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}"]) {
+ if (!empty($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}"]);
}
if (!empty($this->_params["billing_country_id-{$this->_bltID}"]) && $this->_params["billing_country_id-{$this->_bltID}"]) {
}
// if onbehalf-of-organization
if (!empty($this->_params['hidden_onbehalf_profile'])) {
- if (!empty($this->_params['org_option']) && !empty($this->_params['organization_id'])) {
+ // CRM-15182
+ if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) {
if (!empty($this->_params['onbehalfof_id'])) {
$this->_params['organization_id'] = $this->_params['onbehalfof_id'];
}
+ else {
+ $this->_params['organization_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_params['onbehalf']['organization_name'], 'id', 'display_name');
+ }
}
$this->_params['organization_name'] = $this->_params['onbehalf']['organization_name'];
}
$defaults = array();
- $fields = array();
- foreach ($this->_fields as $name => $dontCare) {
- if ($name != 'onbehalf' || $name != 'honor') {
- $fields[$name] = 1;
- }
- }
+ $fields = array_fill_keys(array_keys($this->_fields), 1);
$fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1;
$contact = $this->_params;
foreach ($fields as $name => $dontCare) {
- if (isset($contact[$name])) {
+ // Recursively set defaults for nested fields
+ if (isset($contact[$name]) && is_array($contact[$name]) && ($name == 'onbehalf' || $name == 'honor')) {
+ foreach ($contact[$name] as $fieldName => $fieldValue) {
+ $defaults["{$name}[{$fieldName}]"] = $fieldValue;
+ }
+ }
+ elseif (isset($contact[$name])) {
$defaults[$name] = $contact[$name];
if (substr($name, 0, 7) == 'custom_') {
$timeField = "{$name}_time";
$this->assign('useForMember', $this->get('useForMember'));
- // now fix all state country selectors
- CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
-
$this->setDefaults($defaults);
$this->freeze();
* @param array $lineItems
*
* @throws Exception
- * @internal param bool $deductibleMode
* @return CRM_Contribute_DAO_Contribution
* @access public
*/
$isCurrentEmployer = FALSE;
$dupeIDs = array();
$orgID = NULL;
- if (!empty($behalfOrganization['organization_id']) && !empty($behalfOrganization['org_option'])) {
+ if (!empty($behalfOrganization['organization_id']) && empty($behalfOrganization['org_option'])) {
$orgID = $behalfOrganization['organization_id'];
unset($behalfOrganization['organization_id']);
$isCurrentEmployer = TRUE;
// CRM-6243 says to pick the first org even if more than one match
if (count($dupeIDs) >= 1) {
- $behalfOrganization['contact_id'] = $dupeIDs[0];
+ $behalfOrganization['contact_id'] = $orgID = $dupeIDs[0];
// don't allow name edit
unset($behalfOrganization['organization_name']);
}
*/
public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems) {
try {
- $membershipTypeID = (array) $membershipParams['selectMembership'];
-
- $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this);
-
+ $membershipTypeIDs = (array) $membershipParams['selectMembership'];
+ $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
$membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
$this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
$isPaidMembership = FALSE;
- if($this->_amount > 0.0 && $membershipParams['amount']) {
+ if($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
//amount must be greater than zero for
//adding contribution record to contribution table.
//this condition arises when separate membership payment is
}
CRM_Member_BAO_Membership::postProcessMembership($membershipParams, $contactID,
- $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeID, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId,
+ $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $contributionTypeId,
$membershipLineItems
);
$this->assign('membership_assign', TRUE);
$priceField->price_set_id = $priceSetID;
$priceField->orderBy('weight');
$priceField->find();
+ $paramWeDoNotUnderstand = NULL;
while ($priceField->fetch()) {
- $paramWeDoNotUnderstand = NULL;
if ($priceField->name == "contribution_amount") {
$paramWeDoNotUnderstand = $priceField->id;
}
// contribution amount same as membership amount.
//@todo - merge with section above
if ($this->_membershipBlock['is_separate_payment']
+ && !empty($this->_values['fee'][$priceField->id])
&& CRM_Utils_Array::value('name', $this->_values['fee'][$priceField->id]) == 'contribution_amount'
&& CRM_Utils_Array::value("price_{$priceField->id}", $this->_params) == '-1'
) {
}
}
- /**
- * Static submit function allowing tests (& api access although this is being built slowly)
- * @param $params
- */
static function submit($params) {
$form = new CRM_Contribute_Form_Contribution_Confirm();
$form->_id = $params['id'];
+ if (!empty($params['contact_id'])) {
+ $form->_contactID = $params['contact_id'];
+ }
CRM_Contribute_BAO_ContributionPage::setValues($form->_id, $form->_values);
$form->_separateMembershipPayment = CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id);
//this way the mocked up controller ignores the session stuff
$params['invoiceID'] = md5(uniqid(rand(), TRUE));
$paramsProcessedForForm = $form->_params = self::getFormParams($params['id'], $params);
$form->_amount = $params['amount'];
-
-
$priceSetID = $form->_params['priceSetId'] = $paramsProcessedForForm['price_set_id'];
$priceFields = CRM_Price_BAO_PriceSet::getSetDetail($priceSetID);
$priceSetFields = reset($priceFields);
$form->_values['fee'] = $priceSetFields['fields'];
$form->_priceSetId = $priceSetID;
$form->setFormAmountFields($priceSetID);
+ if (!empty($params['payment_processor'])) {
+ $form->_paymentProcessor = civicrm_api3('payment_processor', 'getsingle', array('id' => $params['payment_processor']));
+ if ($form->_paymentProcessor['billing_mode'] ==1) {
+ $form->_contributeMode = 'direct';
+ }
+ else {
+ $form->_contributeMode = 'notify';
+ }
+ }
$priceFields = $priceFields[$priceSetID]['fields'];
CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution');
$form->_lineItem = array($priceSetID => $lineItems);
*/
static function getFormParams($id, array $params) {
if(!isset($params['is_pay_later'])) {
- $params['is_pay_later'] = civicrm_api3('contribution_page', 'getvalue', array('id' => $id, 'return' => 'is_pay_later'));
+ if (!empty($params['payment_processor'])) {
+ $params['is_pay_later'] = 0;
+ }
+ else {
+ $params['is_pay_later'] = civicrm_api3('contribution_page', 'getvalue', array(
+ 'id' => $id,
+ 'return' => 'is_pay_later'
+ ));
+ }
}
if(empty($params['price_set_id'])) {
$params['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id']);