if (CRM_Utils_Array::value('contribution', $ids)) {
$contributionId['id'] = $ids['contribution'];
$params['prevContribution'] = self::getValues($contributionId, CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
- if (CRM_Utils_Array::value('soft_credit_to', $params)) {
+ /*if (CRM_Utils_Array::value('soft_credit_to', $params)) {
foreach (array('financial_type_id', 'total_amount') as $field) {
if (!isset($contribution->$field)) {
$contribution->$field = $params['prevContribution']->$field;
}
}
- }
+ }*/
}
$result = $contribution->save();
self::recordFinancialAccounts($params, $ids);
// Add soft_contribution details as part of fix for CRM-8908
- $contribution->soft_credit_to = CRM_Utils_Array::value('soft_credit_to', $params);
+ //$contribution->soft_credit_to = CRM_Utils_Array::value('soft_credit_to', $params);
// reset the group contact cache for this group
CRM_Contact_BAO_GroupContactCache::remove();
}
}
- if (CRM_Utils_Array::value('contribution', $ids) &&
+ /*if (CRM_Utils_Array::value('contribution', $ids) &&
!CRM_Utils_Array::value('softID', $params)
) {
if ($softID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionSoft', $ids['contribution'], 'id', 'contribution_id')) {
$params['softID'] = $softID;
}
- }
+ }*/
$transaction = new CRM_Core_Transaction();
// delete the soft credit record if no soft credit contact ID AND no PCP is set in the form
- if (CRM_Utils_Array::value('contribution', $ids) &&
+ /*if (CRM_Utils_Array::value('contribution', $ids) &&
(!CRM_Utils_Array::value('soft_credit_to', $params) &&
!CRM_Utils_Array::value('pcp_made_through_id', $params)
) &&
$softCredit = new CRM_Contribute_DAO_ContributionSoft();
$softCredit->id = $params['softID'];
$softCredit->delete();
- }
+ }*/
$contribution = self::add($params, $ids);
+ if (CRM_Utils_Array::value('deleteSoftCredit', $params, TRUE)) {
+ // first delete soft credits if any
+ CRM_Contribute_BAO_ContributionSoft::del($contribution->id);
+
+ if (CRM_Utils_Array::value('pcp_made_through_id', $params)) {
+ $softParams = array();
+ $softParams['contribution_id'] = $contribution->id;
+ $softParams['pcp_id'] = $params['pcp_made_through_id'];
+ $softParams['contact_id'] = $params['soft_credit_to'];
+ $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
+ $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
+ $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params);
+ CRM_Contribute_BAO_ContributionSoft::add($softParams);
+ }
+ elseif (CRM_Utils_Array::value('soft_credit', $params)) {
+ $softParams = $params['soft_credit'];
+ foreach ($softParams as $softParam) {
+ $softParam['contribution_id'] = $contribution->id;
+ $softParam['currency'] = $contribution->currency;
+ CRM_Contribute_BAO_ContributionSoft::add($softParam);
+ }
+ }
+ }
+
if (is_a($contribution, 'CRM_Core_Error')) {
$transaction->rollback();
return $contribution;
// get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
+
if (CRM_Utils_Array::value('price_set_id', $submittedValues) && $this->_action & CRM_Core_Action::UPDATE ) {
$line = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution');
$lineID = key($line);
}
$this->assign('lineItem', !empty($lineItem) && !$isQuickConfig ? $lineItem : FALSE);
- if (CRM_Utils_Array::value('soft_credit_to', $submittedValues)) {
- $submittedValues['soft_credit_to'] = $submittedValues['soft_contact_id'];
+ if (CRM_Utils_Array::value('pcp_made_through_id', $submittedValues)) {
+
+ }
+ else {
+ //build soft credit params
+ if (!empty($submittedValues['soft_credit_contact_select_id']))
+ $softParams = array();
+ foreach( $submittedValues['soft_credit_contact_select_id'] as $key => $val) {
+ if ($val && $submittedValues['soft_credit_amount'][$key]) {
+ $softParams[$key]['contact_id'] = $val;
+ $softParams[$key]['amount'] = $submittedValues['soft_credit_amount'][$key];
+ $softCredit = TRUE;
+ }
+ }
}
+ if (!empty($softParams)) {
+ $params['soft_credit'] = $softParams;
+ }
+
+ /* if (CRM_Utils_Array::value('soft_credit_to', $submittedValues)) {
+ $submittedValues['soft_credit_to'] = $submittedValues['soft_contact_id'];
+ }*/
// set the contact, when contact is selected
if (CRM_Utils_Array::value('contact_select_id', $submittedValues)) {
'cancel_reason',
'source',
'check_number',
- 'soft_credit_to',
+ /*'soft_credit_to',
'pcp_made_through_id',
'pcp_display_in_roll',
'pcp_roll_nickname',
- 'pcp_personal_note',
+ 'pcp_personal_note',*/
);
foreach ($fields as $f) {
$params[$f] = CRM_Utils_Array::value($f, $formValues);
}
-
- if ($softID = CRM_Utils_Array::value('softID', $this->_values)) {
- $params['softID'] = $softID;
+ if (!empty($softParams)) {
+ $params['soft_credit'] = $softParams;
}
+ /*if ($softID = CRM_Utils_Array::value('softID', $this->_values)) {
+ $params['softID'] = $softID;
+ }*/
//if priceset is used, no need to cleanup money
//CRM-5740
if ($priceSetId) {
}
}
else {
- $params['cancel_date'] = $params['cancel_reason'] = 'null';
+ $params['cancel_date'] = $params['cancel_reason'] = 'null';
}
// Set is_pay_later flag for back-office offline Pending status contributions CRM-8996