Merge remote-tracking branch 'MarcMichalsky/issue/47'
[#48] Allow configuring required address comonents
This commit is contained in:
commit
d95813d1ad
5 changed files with 68 additions and 1 deletions
|
@ -416,6 +416,20 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
array()
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'select',
|
||||
'required_address_components',
|
||||
E::ts('Required address components'),
|
||||
[
|
||||
'street_address' => E::ts("Street"),
|
||||
'postal_code' => E::ts("Postal Code"),
|
||||
'city' => E::ts("City"),
|
||||
'country' => E::ts("Country"),
|
||||
],
|
||||
FALSE, // is not required
|
||||
['class' => 'crm-select2 huge', 'multiple' => 'multiple']
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'textarea', // field type
|
||||
'custom_field_mapping', // field name
|
||||
|
|
|
@ -226,7 +226,8 @@ class CRM_Twingle_Profile {
|
|||
'membership_type_id',
|
||||
'membership_type_id_recur',
|
||||
'membership_postprocess_call',
|
||||
'newsletter_double_opt_in'
|
||||
'newsletter_double_opt_in',
|
||||
'required_address_components',
|
||||
),
|
||||
// Add payment methods.
|
||||
array_keys(static::paymentInstruments()),
|
||||
|
@ -300,6 +301,12 @@ class CRM_Twingle_Profile {
|
|||
'membership_type_id' => NULL,
|
||||
'membership_type_id_recur' => NULL,
|
||||
'newsletter_double_opt_in' => NULL,
|
||||
'required_address_components' => [
|
||||
'street_address',
|
||||
'postal_code',
|
||||
'city',
|
||||
'country',
|
||||
],
|
||||
)
|
||||
// Add contribution status for all payment methods.
|
||||
+ array_fill_keys(array_map(function($attribute) {
|
||||
|
|
|
@ -335,6 +335,23 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove address data when any address component that is configured as
|
||||
// required is missing.
|
||||
// See https://github.com/systopia/de.systopia.twingle/issues/47
|
||||
foreach ($profile->getAttribute('required_address_components', []) as $required_address_component) {
|
||||
if (empty($params[$required_address_component])) {
|
||||
foreach ([
|
||||
'street_address',
|
||||
'postal_code',
|
||||
'city',
|
||||
'country',
|
||||
] as $address_param) {
|
||||
unset($params[$address_param]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare parameter mapping for organisation.
|
||||
if (!empty($params['user_company'])) {
|
||||
$params['organization_name'] = $params['user_company'];
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
| written permission from the original author(s). |
|
||||
+-------------------------------------------------------------*}
|
||||
|
||||
{crmScope extensionKey='de.systopia.twingle'}
|
||||
{htxt id='id-location_type_id'}
|
||||
{ts domain="de.systopia.twingle"}Select which location type to use for addresses for individuals, either when no organisation name is specified, or an organisation address can not be shared with the individual contact.{/ts}
|
||||
{/htxt}
|
||||
|
@ -54,6 +55,12 @@
|
|||
</ul>{/ts}
|
||||
{/htxt}
|
||||
|
||||
{htxt id='id-required_address_components'}
|
||||
<p>{ts}Select the address components that must be present to create or update an address for the contact.{/ts}</p>
|
||||
<p>{ts}Depending on your XCM settings, the transferred address might replace an existing one.{/ts}</p>
|
||||
<p>{ts}Since in some cases Twingle send the country of the user as the only address parameter, depending on your XCM configuration, not declaring other address components as required might lead to the current user address being overwritten with an address containing the country only.{/ts}</p>
|
||||
{/htxt}
|
||||
|
||||
{htxt id='id-custom_field_mapping'}
|
||||
{ts domain="de.systopia.twingle"}<p>Map Twingle custom fields to CiviCRM custom fields using the following format (each assignment in a separate line):</p>
|
||||
<pre>twingle_field_1=custom_123<br />twingle_field_2=custom_789</pre>
|
||||
|
@ -68,3 +75,4 @@
|
|||
<li><strong>ContributionRecur</strong> – Will be set on the recurring contribution and deriving single contributions</li>
|
||||
</ul>{/ts}
|
||||
{/htxt}
|
||||
{/crmScope}
|
|
@ -113,6 +113,27 @@
|
|||
<td class="content">{$form.location_type_id_organisation.html}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="crm-section">
|
||||
<td class="label">{$form.required_address_components.label}
|
||||
<a
|
||||
onclick='
|
||||
CRM.help(
|
||||
"{ts domain="de.systopia.twingle"}Required address components{/ts}",
|
||||
{literal}{
|
||||
"id": "id-required_address_components",
|
||||
"file": "CRM\/Twingle\/Form\/Profile"
|
||||
}{/literal}
|
||||
);
|
||||
return false;
|
||||
'
|
||||
href="#"
|
||||
title="{ts domain="de.systopia.twingle"}Help{/ts}"
|
||||
class="helpicon"
|
||||
></a>
|
||||
</td>
|
||||
<td class="content">{$form.required_address_components.html}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="crm-section">
|
||||
<td class="label">
|
||||
{$form.financial_type_id.label}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue