diff --git a/CRM/Twingle/Form/Profile.php b/CRM/Twingle/Form/Profile.php index 0a7c065..e39ad52 100644 --- a/CRM/Twingle/Form/Profile.php +++ b/CRM/Twingle/Form/Profile.php @@ -121,6 +121,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form { TRUE ); + $this->add( + 'select', + 'location_type_id_organisation', + E::ts('Location type for organisations'), + $this->getLocationTypes(), + TRUE + ); + $this->add( 'select', // field type 'financial_type_id', // field name diff --git a/CRM/Twingle/Profile.php b/CRM/Twingle/Profile.php index ce6aa54..474d2ad 100644 --- a/CRM/Twingle/Profile.php +++ b/CRM/Twingle/Profile.php @@ -168,6 +168,7 @@ class CRM_Twingle_Profile { return array( 'selector', 'location_type_id', + 'location_type_id_organisation', 'financial_type_id', 'pi_banktransfer', 'pi_debit_manual', @@ -225,6 +226,7 @@ class CRM_Twingle_Profile { return new CRM_Twingle_Profile($name, array( 'selector' => '', '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" 'pi_banktransfer' => 5, // "EFT" 'pi_debit_manual' => NULL, diff --git a/api/v3/TwingleDonation/Submit.php b/api/v3/TwingleDonation/Submit.php index 7be943d..06d30f8 100644 --- a/api/v3/TwingleDonation/Submit.php +++ b/api/v3/TwingleDonation/Submit.php @@ -300,7 +300,7 @@ function civicrm_api3_twingle_donation_Submit($params) { unset($params['id']); } - // Add location type to parameters. + // Add configured location type to parameters. $params['location_type_id'] = (int) $profile->getAttribute('location_type_id'); // 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)) { $organisation_data += $submitted_address; - // Always use WORK address for organisation address. - $organisation_data['location_type_id'] = CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK; + // Use configured location type for organisation address. + $organisation_data['location_type_id'] = (int) $profile->getAttribute('location_type_id_organisation'); } if (!$organisation_id = CRM_Twingle_Submission::getContact( '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 = ( isset($organisation_id) && CRM_Twingle_Submission::shareWorkAddress( $contact_id, $organisation_id, - CRM_Twingle_Submission::LOCATION_TYPE_ID_WORK + (int) $profile->getAttribute('location_type_id_organisation') ) ); diff --git a/templates/CRM/Twingle/Form/Profile.hlp b/templates/CRM/Twingle/Form/Profile.hlp new file mode 100644 index 0000000..125e276 --- /dev/null +++ b/templates/CRM/Twingle/Form/Profile.hlp @@ -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} diff --git a/templates/CRM/Twingle/Form/Profile.tpl b/templates/CRM/Twingle/Form/Profile.tpl index 2c9eee2..502404b 100644 --- a/templates/CRM/Twingle/Form/Profile.tpl +++ b/templates/CRM/Twingle/Form/Profile.tpl @@ -33,10 +33,49 @@