Allow location type for organisation addresses be configurable.
This commit is contained in:
parent
d28248723b
commit
3a027cc7c9
5 changed files with 77 additions and 6 deletions
|
@ -121,6 +121,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->add(
|
||||||
|
'select',
|
||||||
|
'location_type_id_organisation',
|
||||||
|
E::ts('Location type for organisations'),
|
||||||
|
$this->getLocationTypes(),
|
||||||
|
TRUE
|
||||||
|
);
|
||||||
|
|
||||||
$this->add(
|
$this->add(
|
||||||
'select', // field type
|
'select', // field type
|
||||||
'financial_type_id', // field name
|
'financial_type_id', // field name
|
||||||
|
|
|
@ -168,6 +168,7 @@ class CRM_Twingle_Profile {
|
||||||
return array(
|
return array(
|
||||||
'selector',
|
'selector',
|
||||||
'location_type_id',
|
'location_type_id',
|
||||||
|
'location_type_id_organisation',
|
||||||
'financial_type_id',
|
'financial_type_id',
|
||||||
'pi_banktransfer',
|
'pi_banktransfer',
|
||||||
'pi_debit_manual',
|
'pi_debit_manual',
|
||||||
|
@ -225,6 +226,7 @@ class CRM_Twingle_Profile {
|
||||||
return new CRM_Twingle_Profile($name, array(
|
return new CRM_Twingle_Profile($name, array(
|
||||||
'selector' => '',
|
'selector' => '',
|
||||||
'location_type_id' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
'location_type_id' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
||||||
|
'location_type_id_organisation' => CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK,
|
||||||
'financial_type_id' => 1, // "Donation"
|
'financial_type_id' => 1, // "Donation"
|
||||||
'pi_banktransfer' => 5, // "EFT"
|
'pi_banktransfer' => 5, // "EFT"
|
||||||
'pi_debit_manual' => NULL,
|
'pi_debit_manual' => NULL,
|
||||||
|
|
|
@ -300,7 +300,7 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
unset($params['id']);
|
unset($params['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add location type to parameters.
|
// Add configured location type to parameters.
|
||||||
$params['location_type_id'] = (int) $profile->getAttribute('location_type_id');
|
$params['location_type_id'] = (int) $profile->getAttribute('location_type_id');
|
||||||
|
|
||||||
// Exclude address for now when retrieving/creating the individual contact
|
// Exclude address for now when retrieving/creating the individual contact
|
||||||
|
@ -364,8 +364,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
);
|
);
|
||||||
if (!empty($submitted_address)) {
|
if (!empty($submitted_address)) {
|
||||||
$organisation_data += $submitted_address;
|
$organisation_data += $submitted_address;
|
||||||
// Always use WORK address for organisation address.
|
// Use configured location type for organisation address.
|
||||||
$organisation_data['location_type_id'] = CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK;
|
$organisation_data['location_type_id'] = (int) $profile->getAttribute('location_type_id_organisation');
|
||||||
}
|
}
|
||||||
if (!$organisation_id = CRM_Twingle_Submission::getContact(
|
if (!$organisation_id = CRM_Twingle_Submission::getContact(
|
||||||
'Organization',
|
'Organization',
|
||||||
|
@ -377,13 +377,14 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Share organisation address as WORK address with individual contact.
|
// Share organisation address with individual contact, using configured
|
||||||
|
// location type for organisation address.
|
||||||
$address_shared = (
|
$address_shared = (
|
||||||
isset($organisation_id)
|
isset($organisation_id)
|
||||||
&& CRM_Twingle_Submission::shareWorkAddress(
|
&& CRM_Twingle_Submission::shareWorkAddress(
|
||||||
$contact_id,
|
$contact_id,
|
||||||
$organisation_id,
|
$organisation_id,
|
||||||
CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK
|
(int) $profile->getAttribute('location_type_id_organisation')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
21
templates/CRM/Twingle/Form/Profile.hlp
Normal file
21
templates/CRM/Twingle/Form/Profile.hlp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{*------------------------------------------------------------+
|
||||||
|
| SYSTOPIA Twingle Integration |
|
||||||
|
| Copyright (C) 2018 SYSTOPIA |
|
||||||
|
| Author: J. Schuppe (schuppe@systopia.de) |
|
||||||
|
+-------------------------------------------------------------+
|
||||||
|
| This program is released as free software under the |
|
||||||
|
| Affero GPL license. You can redistribute it and/or |
|
||||||
|
| modify it under the terms of this license which you |
|
||||||
|
| can read by viewing the included agpl.txt or online |
|
||||||
|
| at www.gnu.org/licenses/agpl.html. Removal of this |
|
||||||
|
| copyright header is strictly prohibited without |
|
||||||
|
| written permission from the original author(s). |
|
||||||
|
+-------------------------------------------------------------*}
|
||||||
|
|
||||||
|
{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}
|
||||||
|
|
||||||
|
{htxt id='id-location_type_id_organisation'}
|
||||||
|
{ts domain="de.systopia.twingle"}Select which location type to use for addresses for organisations and shared organisation addresses for individual contacts{/ts}
|
||||||
|
{/htxt}
|
|
@ -33,10 +33,49 @@
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">{$form.location_type_id.label}</td>
|
<td class="label">
|
||||||
|
{$form.location_type_id.label}
|
||||||
|
<a
|
||||||
|
onclick='
|
||||||
|
CRM.help(
|
||||||
|
"{ts domain="de.systopia.twingle"}Location type{/ts}",
|
||||||
|
{literal}{
|
||||||
|
"id": "id-location_type_id",
|
||||||
|
"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.location_type_id.html}</td>
|
<td class="content">{$form.location_type_id.html}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr class="crm-section">
|
||||||
|
<td class="label">
|
||||||
|
{$form.location_type_id_organisation.label}
|
||||||
|
<a
|
||||||
|
onclick='
|
||||||
|
CRM.help(
|
||||||
|
"{ts domain="de.systopia.twingle"}Location type for organisations{/ts}",
|
||||||
|
{literal}{
|
||||||
|
"id": "id-location_type_id_organisation",
|
||||||
|
"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.location_type_id_organisation.html}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr class="crm-section">
|
<tr class="crm-section">
|
||||||
<td class="label">{$form.financial_type_id.label}</td>
|
<td class="label">{$form.financial_type_id.label}</td>
|
||||||
<td class="content">{$form.financial_type_id.html}</td>
|
<td class="content">{$form.financial_type_id.html}</td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue