add logic to create selected contact and contribution notes
This commit is contained in:
parent
10f6ca4e89
commit
df51d59cea
1 changed files with 37 additions and 11 deletions
|
@ -255,6 +255,13 @@ function _civicrm_api3_twingle_donation_Submit_spec(&$params) {
|
||||||
'api.required' => 0,
|
'api.required' => 0,
|
||||||
'description' => E::ts('Additional information for either the contact or the (recurring) contribution.'),
|
'description' => E::ts('Additional information for either the contact or the (recurring) contribution.'),
|
||||||
];
|
];
|
||||||
|
$params['remarks'] = [
|
||||||
|
'name' => 'remarks',
|
||||||
|
'title' => E::ts('Remarks'),
|
||||||
|
'type' => CRM_Utils_Type::T_STRING,
|
||||||
|
'api.required' => 0,
|
||||||
|
'description' => E::ts('Additional remarks for the donation.'),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,14 +484,21 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save user_extrafield as contact note.
|
// Create contact notes.
|
||||||
if (isset($params['user_extrafield']) && '' != $params['user_extrafield']) {
|
$contact_note_mappings = $profile->getAttribute('map_as_contact_notes', []);
|
||||||
|
foreach (['user_extrafield'] as $target) {
|
||||||
|
if (
|
||||||
|
isset($params[$target])
|
||||||
|
&& '' != $params[$target]
|
||||||
|
&& in_array($target, $contact_note_mappings)
|
||||||
|
) {
|
||||||
civicrm_api3('Note', 'create', [
|
civicrm_api3('Note', 'create', [
|
||||||
'entity_table' => 'civicrm_contact',
|
'entity_table' => 'civicrm_contact',
|
||||||
'entity_id' => $contact_id,
|
'entity_id' => $contact_id,
|
||||||
'note' => $params['user_extrafield'],
|
'note' => $params[$target],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Share organisation address with individual contact, using configured
|
// Share organisation address with individual contact, using configured
|
||||||
// location type for organisation address.
|
// location type for organisation address.
|
||||||
|
@ -620,10 +634,6 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
$contribution_data += $custom_fields['Contribution'];
|
$contribution_data += $custom_fields['Contribution'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($params['purpose'])) {
|
|
||||||
$contribution_data['note'] = $params['purpose'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// set campaign, subject to configuration
|
// set campaign, subject to configuration
|
||||||
CRM_Twingle_Submission::setCampaign($contribution_data, 'contribution', $params, $profile);
|
CRM_Twingle_Submission::setCampaign($contribution_data, 'contribution', $params, $profile);
|
||||||
|
|
||||||
|
@ -794,6 +804,22 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
$result_values['contribution'] = $contribution['values'];
|
$result_values['contribution'] = $contribution['values'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add notes to the contribution.
|
||||||
|
$contribution_note_mappings = $profile->getAttribute("map_as_contribution_notes");
|
||||||
|
foreach (['purpose', 'remarks'] as $target) {
|
||||||
|
if (
|
||||||
|
in_array($target, $contribution_note_mappings)
|
||||||
|
&& isset($params[$target])
|
||||||
|
&& '' != $params[$target]
|
||||||
|
) {
|
||||||
|
civicrm_api3('Note', 'create', [
|
||||||
|
'entity_table' => 'civicrm_contribution',
|
||||||
|
'entity_id' => CRM_Utils_Array::first($result_values['contribution'])['id'],
|
||||||
|
'note' => $params[$target],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MEMBERSHIP CREATION
|
// MEMBERSHIP CREATION
|
||||||
|
|
||||||
// CHECK whether a membership should be created (based on profile settings and data provided)
|
// CHECK whether a membership should be created (based on profile settings and data provided)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue