[#14] implementing individual prefix mapping
This commit is contained in:
parent
48116e5c98
commit
24801bb6bc
4 changed files with 75 additions and 7 deletions
|
@ -90,6 +90,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
*/
|
*/
|
||||||
protected static $_genderOptions = NULL;
|
protected static $_genderOptions = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*
|
||||||
|
* A static cache of retrieved prefixes found within
|
||||||
|
* static::getGenderOptions().
|
||||||
|
*/
|
||||||
|
protected static $_prefixOptions = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*
|
*
|
||||||
|
@ -267,6 +275,28 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->add(
|
||||||
|
'select',
|
||||||
|
'prefix_male',
|
||||||
|
E::ts('Prefix option for submitted value "male"'),
|
||||||
|
static::getPrefixOptions(),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->add(
|
||||||
|
'select',
|
||||||
|
'prefix_female',
|
||||||
|
E::ts('Prefix option for submitted value "female"'),
|
||||||
|
static::getPrefixOptions(),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->add(
|
||||||
|
'select',
|
||||||
|
'prefix_other',
|
||||||
|
E::ts('Prefix option for submitted value "other"'),
|
||||||
|
static::getPrefixOptions(),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
|
||||||
$payment_instruments = CRM_Twingle_Profile::paymentInstruments();
|
$payment_instruments = CRM_Twingle_Profile::paymentInstruments();
|
||||||
$this->assign('payment_instruments', $payment_instruments);
|
$this->assign('payment_instruments', $payment_instruments);
|
||||||
foreach ($payment_instruments as $pi_name => $pi_label) {
|
foreach ($payment_instruments as $pi_name => $pi_label) {
|
||||||
|
@ -593,7 +623,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves campaigns present within the system as options for select form
|
* Retrieves genders present within the system as options for select form
|
||||||
* elements.
|
* elements.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -619,6 +649,33 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
return static::$_genderOptions;
|
return static::$_genderOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves prefixes present within the system as options for select form
|
||||||
|
* elements.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @throws \CiviCRM_API3_Exception
|
||||||
|
*/
|
||||||
|
public static function getPrefixOptions() {
|
||||||
|
if (!isset(static::$_prefixOptions)) {
|
||||||
|
static::$_prefixOptions = array('' => E::ts('none'));
|
||||||
|
$query = civicrm_api3('OptionValue', 'get', array(
|
||||||
|
'option.limit' => 0,
|
||||||
|
'option_group_id' => 'individual_prefix',
|
||||||
|
'is_active' => 1,
|
||||||
|
'return' => array(
|
||||||
|
'value',
|
||||||
|
'label',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
foreach ($query['values'] as $prefix) {
|
||||||
|
static::$_prefixOptions[$prefix['value']] = $prefix['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return static::$_prefixOptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves CiviSEPA creditors as options for select form elements.
|
* Retrieves CiviSEPA creditors as options for select form elements.
|
||||||
*
|
*
|
||||||
|
|
|
@ -208,6 +208,9 @@ class CRM_Twingle_Profile {
|
||||||
'gender_male',
|
'gender_male',
|
||||||
'gender_female',
|
'gender_female',
|
||||||
'gender_other',
|
'gender_other',
|
||||||
|
'prefix_male',
|
||||||
|
'prefix_female',
|
||||||
|
'prefix_other',
|
||||||
'newsletter_groups',
|
'newsletter_groups',
|
||||||
'postinfo_groups',
|
'postinfo_groups',
|
||||||
'donation_receipt_groups',
|
'donation_receipt_groups',
|
||||||
|
|
|
@ -384,6 +384,14 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the prefix ID defined within the profile
|
||||||
|
if (!empty($params['user_gender'])) {
|
||||||
|
$prefix_id = (int) $profile->getAttribute('prefix_' . $params['user_gender']);
|
||||||
|
if ($prefix_id) {
|
||||||
|
$contact_data['prefix_id'] = $prefix_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add custom field values.
|
// Add custom field values.
|
||||||
if (!empty($custom_fields['Contact'])) {
|
if (!empty($custom_fields['Contact'])) {
|
||||||
$contact_data += $custom_fields['Contact'];
|
$contact_data += $custom_fields['Contact'];
|
||||||
|
|
|
@ -165,16 +165,16 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">{$form.gender_male.label}</td>
|
<td class="label">{ts domain="de.systopia.twingle"}Gender/Prefix for value 'male'{/ts}</td>
|
||||||
<td class="content">{$form.gender_male.html}</td>
|
<td class="content">{$form.gender_male.html} / {$form.prefix_male.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">{$form.gender_female.label}</td>
|
<td class="label">{ts domain="de.systopia.twingle"}Gender/Prefix for value 'female'{/ts}</td>
|
||||||
<td class="content">{$form.gender_female.html}</td>
|
<td class="content">{$form.gender_female.html} / {$form.prefix_female.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">{$form.gender_other.label}</td>
|
<td class="label">{ts domain="de.systopia.twingle"}Gender/Prefix for value 'other'{/ts}</td>
|
||||||
<td class="content">{$form.gender_other.html}</td>
|
<td class="content">{$form.gender_other.html} / {$form.prefix_other.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue