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) »
  • If you need to handle the European Union as a world region
Pages: [1]

Author Topic: If you need to handle the European Union as a world region  (Read 887 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
If you need to handle the European Union as a world region
February 26, 2013, 03:02:36 am
Hi,

One user wanted to make it easier to make the distinction between their contact in the eu27 and the others.

run the following sql commands:
Code: [Select]
insert into civicrm_worldregion (id,name) value (90,"European Union (EU)");
update civicrm_country set region_id=90 where iso_code in ("BE","BG","CZ","DK","DE","EE","IE","GR","ES","FR","IT","CY","LV","LT","LU","HU","MT","NL","AT","PL","PT","RO","SI","SK","FI","SE","GB");

if you read that after the 1st of july, add a "HR" at the end of the list

You should be pretty safe, unless there is another region that has the number 90 (it shouldn't).

To make it more EU friendly, you might want to change two iso code in the civicrm_country table:

Code: [Select]
update civicrm_country set iso_code="UK" where iso_code="GB";
update civicrm_country set iso_code="EL" where iso_code="GR";

http://epp.eurostat.ec.europa.eu/statistics_explained/index.php/Tutorial:Country_codes_and_protocol_order
"The two-letter ISO code is used (ISO 3166 alpha-2) except for Greece and the United Kingdom, for which the abbreviations EL and UK have to be used."

I hope it helps someone else, worked for me, your mileage might vary, I'm not responsible if it triggers a meteorite to fall on Brussels and other usual disclaimers

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
Re: If you need to handle the European Union as a world region
November 13, 2013, 07:02:55 am
Hi Xavier,
I have a custom field for nationality and i would like to distinguish between them based on regions like: Asia, MENA, Ocenia etc.
Your sql query above works well for world region, how can i do this for a custom field of nationalities?

Thank you in advance.



Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: If you need to handle the European Union as a world region
November 13, 2013, 08:43:58 am
What is keeping you from just creating a select list for your custom field? That would work, would it not? Or would you like to determine the region based on the country?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
Re: If you need to handle the European Union as a world region
November 13, 2013, 10:39:48 am
I have already a select list which works perfectly for nationality but i would like to group these countries to regions so as to be able to determine the region based on the selected country.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: If you need to handle the European Union as a world region
November 13, 2013, 10:51:39 am
Makes sense, but I do not think you can do that with a single query updating the region field? Xavier's example is not based on what the user selected in the first field, it sets the region based on the country values.
What you could ofcourse do is either do a little jQuery magic in an extra.template to set the value of the region field whenever the nationaltiy field is selected?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

kennedy

  • I post occasionally
  • **
  • Posts: 119
  • Karma: 5
  • CiviCRM version: 4.5.5
  • CMS version: Drupal
  • PHP version: 5.3.10
Re: If you need to handle the European Union as a world region
November 14, 2013, 12:47:46 am
Thank you Erik. The idea is to be able to search the region based on the nationalities the individuals have selected.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: If you need to handle the European Union as a world region
November 14, 2013, 01:35:27 am
OK, so you can either use the region field in the civicrm_country table (without guarantees :-)) or create your own custom group with a region field and a hidden country field?
You can then probably make a customSearch for this scenario?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: If you need to handle the European Union as a world region
November 14, 2013, 01:43:05 am
Or use the country api Jaap is going to PR and contribute back soon, I've heard?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: If you need to handle the European Union as a world region
November 14, 2013, 01:54:02 am
:-)
If you do want to use the generic country API that will be part of core in the near future, you can find it here:
https://github.com/CiviCooP/org.civicoop.general.api.country
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: If you need to handle the European Union as a world region
November 14, 2013, 11:20:23 am
If you alter the built in regions you need to be wary that it can break upgrade scripts
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • If you need to handle the European Union as a world region

This forum was archived on 2017-11-26.