CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • mailing labels - suppress local country
Pages: [1]

Author Topic: mailing labels - suppress local country  (Read 1134 times)

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
mailing labels - suppress local country
February 11, 2011, 09:15:10 am
Is it possible to have a mailing label format that will print foreign counties but not the local country?

For instance if I'm in the United Kingdom can it suppress adding that to the bottom of the majority of my labels but still add it if the contact lives abroad.

Thanks, Henry

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: mailing labels - suppress local country
February 11, 2011, 09:30:38 am

No option to do so in the current code base

You can look at the code here:

CRM/Contact/Form/Task/Label.php

and patch it to meet your needs

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: mailing labels - suppress local country
February 11, 2011, 10:12:24 am
thanks Lobo. I had a look at that file already. Will see if I can produce a patch.

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: mailing labels - suppress local country
February 15, 2011, 01:37:38 am
OK. Got this working.

Now when you run the mailing label form you get an extra select list called "Suppress this Country on last line of address" (see attached jpg). The list is populated from Administer CiviCRM » Global Settings  »  Available Countries.

Leaving it blank will print all country data. Selecting your country will print all labels as previously but suppress the final local country line.

Would be nice to see this in core.  Do you want me to raise an issue?

in CRM/Contact/Form/Task/Label.php

Add this at Line 86
Quote
        // add select for Country Type
        $this->addElement('select', 'local_country', ts('Suppress this Country on last line of address'),
                          array( '' => ts('Country')) + CRM_Core_PseudoConstant::country( ), true);

line 325 replace this
Code: [Select]
        // format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
require_once 'CRM/Utils/Address.php';
foreach ($rows as $id => $row) {
    if ( $commMethods = CRM_Utils_Array::value( 'preferred_communication_method', $row ) ) {

with this
Quote
        // format the addresses according to CIVICRM_ADDRESS_FORMAT (CRM-1327)
   require_once 'CRM/Utils/Address.php';
   $MyCountry = CRM_Core_PseudoConstant::country($id = $fv['local_country'], $applyLimit = true);
   foreach ($rows as $id => $row) {
       //  don't print local country.
       if ($row['country']  ==  $MyCountry){
      $row['country']  =' ';
      }
            if ( $commMethods = CRM_Utils_Array::value( 'preferred_communication_method', $row ) ) {

in templates/CRM/Contact/Form/Task/label.tpl

Add this at line 37
Quote
     <tr class="crm-contact-task-mailing-label-form-block-local_country">
        <td class="label">{$form.local_country.label}</td>
        <td>{$form.local_country.html}</td>
     </tr>


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • mailing labels - suppress local country

This forum was archived on 2017-11-26.