$this->addRadio($fieldName, $fieldValue['title'], $options, NULL, ' ');
break;
+ case 'YesNo':
+ $this->addRadio($fieldName, $fieldValue['title'], array(0 => 'No', 1 => 'Yes'), NULL, ' ');
+ break;
+
case 'checkboxes':
$options = array_flip(CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE));
$newOptions = array();
case 'text':
case 'select':
case 'radio':
+ case 'YesNo':
case 'entity_reference':
$this->_config->$settingName = CRM_Utils_Array::value($settingName, $this->_params);
break;
'description' => NULL,
'weight' => 3,
),
+ 'hideCountryMailingLabels' => array(
+ 'html_type' => 'YesNo',
+ 'title' => 'Hide Country in Mailing Labels when same as domain country',
+ 'weight' => 4,
+ ),
),
CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => array(
'address_standardization_provider' => array(
'html_type' => 'select',
'title' => ts('Provider'),
'option_values' => $addrProviders,
- 'weight' => 4,
+ 'weight' => 5,
),
'address_standardization_userid' => array(
'html_type' => 'text',
'title' => ts('User ID'),
'description' => NULL,
- 'weight' => 5,
+ 'weight' => 6,
),
'address_standardization_url' => array(
'html_type' => 'text',
'title' => ts('Web Service URL'),
'description' => NULL,
- 'weight' => 6,
+ 'weight' => 7,
),
),
);
$defaults['address_format'] = $this->_config->address_format;
$defaults['mailing_format'] = $this->_config->mailing_format;
+ $defaults['hideCountryMailingLabels'] = $this->_config->hideCountryMailingLabels;
parent::cbsDefaultValues($defaults);
}
}
+ if ($mailing && !empty($fields['country'])) {
+ if (Civi::settings()->get('hideCountryMailingLabels')) {
+ $domain = CRM_Core_BAO_Domain::getDomain();
+ $domainLocation = CRM_Core_Location::getValues(array('contact_id' => $domain->contact_id));
+ $domainAddress = $domainLocation['address'][1];
+ $domainCountryId = $domainAddress['country_id'];
+ if ($fields['country'] == CRM_Core_PseudoConstant::country($domainCountryId)) {
+ $fields['country'] = NULL;
+ }
+ }
+ else {
+ $fields['country'] = strtoupper($fields['country']);
+ }
+ }
+
$contactName = CRM_Utils_Array::value('display_name', $fields);
if (!$individualFormat) {
if (isset($fields['id'])) {
'help_text' => 'Web Service URL',
'validate_callback' => 'CRM_Utils_Rule::url',
),
+ 'hideCountryMailingLabels' => array(
+ 'group_name' => 'Address Preferences',
+ 'group' => 'address',
+ 'name' => 'hideCountryMailingLabels',
+ 'type' => 'Boolean',
+ 'quick_form_type' => 'YesNo',
+ 'default' => 0,
+ 'add' => '4.7',
+ 'title' => 'Hide Country in Mailing Labels when same as domain country',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain',
+ 'help_text' => NULL,
+ ),
);
<span class="description">{ts}Content and format for mailing labels.{/ts}</span>
</td>
</tr>
+ <tr class="crm-preferences-address-form-block-hideCountryMailingLabels">
+ <td class="label">{$form.hideCountryMailingLabels.label}
+ <td>{$form.hideCountryMailingLabels.html}
+ </td>
+ </tr>
+
</table>
<h3>{ts}Address Display{/ts}</h3>