Allow contributions be assigned to a configured campaign per profile.
This commit is contained in:
parent
336870c38e
commit
5ce76eae5f
4 changed files with 38 additions and 1 deletions
|
@ -200,6 +200,15 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
array('class' => 'crm-select2 huge', 'multiple' => 'multiple')
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'select', // field type
|
||||
'campaign', // field name
|
||||
E::ts('Assign donation to campaign'), // field label
|
||||
$this->getCampaigns(), // list of options
|
||||
FALSE, // is not required
|
||||
array('class' => 'crm-select2 huge')
|
||||
);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
|
@ -470,4 +479,22 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
return $this->getGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves campaigns as options for select elements.
|
||||
*/
|
||||
public function getCampaigns() {
|
||||
$campaigns = array();
|
||||
$query = civicrm_api3('Campaign', 'get', array(
|
||||
'option.limit' => 0,
|
||||
'return' => array(
|
||||
'id',
|
||||
'title',
|
||||
)
|
||||
));
|
||||
foreach ($query['values'] as $campaign) {
|
||||
$campaigns[$campaign['id']] = $campaign['title'];
|
||||
}
|
||||
return $campaigns;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -186,7 +186,8 @@ class CRM_Twingle_Profile {
|
|||
'gender_other',
|
||||
'newsletter_groups',
|
||||
'postinfo_groups',
|
||||
'donation_receipt_groups'
|
||||
'donation_receipt_groups',
|
||||
'campaign',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -242,6 +243,7 @@ class CRM_Twingle_Profile {
|
|||
'newsletter_groups' => NULL,
|
||||
'postinfo_groups' => NULL,
|
||||
'donation_receipt_groups' => NULL,
|
||||
'campaign' => NULL,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -448,6 +448,9 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
if (!empty($params['purpose'])) {
|
||||
$contribution_data['note'] = $params['purpose'];
|
||||
}
|
||||
if (!empty($campaign = $profile->getAttribute('campaign'))) {
|
||||
$contribution_data['campaign_id'] = $campaign;
|
||||
}
|
||||
|
||||
if (
|
||||
CRM_Twingle_Submission::civiSepaEnabled()
|
||||
|
|
|
@ -102,6 +102,11 @@
|
|||
<td class="content">{$form.donation_receipt_groups.html}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="crm-section">
|
||||
<td class="label">{$form.campaign.label}</td>
|
||||
<td class="content">{$form.campaign.html}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue