[#5] Add membership type configuration option in profile

This commit is contained in:
Jens Schuppe 2019-08-07 11:34:07 +02:00
parent 4537ac540a
commit 341a0f0e32
3 changed files with 37 additions and 0 deletions

View file

@ -224,6 +224,15 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
array('class' => 'crm-select2 huge') array('class' => 'crm-select2 huge')
); );
$this->add(
'select', // field type
'membership_type_id', // field name
E::ts('Create membership of type'), // field label
array('' => E::ts('- none -')) + $this->getMembershipTypes(), // list of options
FALSE, // is not required
array('class' => 'crm-select2 huge')
);
$this->add( $this->add(
'text', // field type 'text', // field type
'contribution_source', // field name 'contribution_source', // field name
@ -349,6 +358,27 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
return $financial_types; return $financial_types;
} }
/**
* Retrieves membership types present within the system as options for select
* form elements.
*
* @return array
*
* @throws \CiviCRM_API3_Exception
*/
public function getMembershipTypes() {
$membership_types = array();
$query = civicrm_api3('MembershipType', 'get', array(
'is_active' => 1,
'option.limit' => 0,
'return' => 'id,name'
));
foreach ($query['values'] as $type) {
$membership_types[$type['id']] = $type['name'];
}
return $membership_types;
}
/** /**
* Retrieves campaigns present within the system as options for select form * Retrieves campaigns present within the system as options for select form
* elements. * elements.

View file

@ -191,6 +191,7 @@ class CRM_Twingle_Profile {
'donation_receipt_groups', 'donation_receipt_groups',
'campaign', 'campaign',
'contribution_source', 'contribution_source',
'membership_type_id',
); );
} }
@ -250,6 +251,7 @@ class CRM_Twingle_Profile {
'donation_receipt_groups' => NULL, 'donation_receipt_groups' => NULL,
'campaign' => NULL, 'campaign' => NULL,
'contribution_source' => NULL, 'contribution_source' => NULL,
'membreship_type_id' => NULL,
)); ));
} }

View file

@ -185,6 +185,11 @@
<td class="content">{$form.campaign.html}</td> <td class="content">{$form.campaign.html}</td>
</tr> </tr>
<tr class="crm-section">
<td class="label">{$form.membership_type_id.label}</td>
<td class="content">{$form.membership_type_id.html}</td>
</tr>
<tr class="crm-section"> <tr class="crm-section">
<td class="label">{$form.contribution_source.label}</td> <td class="label">{$form.contribution_source.label}</td>
<td class="content">{$form.contribution_source.html}</td> <td class="content">{$form.contribution_source.html}</td>