From 24f4d5040adad40d00daa39fcc8d549fc1a49678 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Apr 2018 14:25:02 +0200 Subject: [PATCH] Move isInEEC from common to thirdparty class. --- htdocs/core/class/commonobject.class.php | 19 +---- htdocs/core/lib/company.lib.php | 90 ++++++++++++++---------- htdocs/societe/class/societe.class.php | 11 +++ 3 files changed, 66 insertions(+), 54 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a620afd900b..88ef341cb04 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3576,19 +3576,6 @@ abstract class CommonObject } - /** - * Return if a country is inside the EEC (European Economic Community) - * @deprecated Use function isInEEC function instead - * - * @return boolean true = country inside EEC, false = country outside EEC - */ - function isInEEC() - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - return isInEEC($this); - } - - // -------------------- // TODO: All functions here must be redesigned and moved as they are not business functions but output functions // -------------------- @@ -6005,11 +5992,11 @@ abstract class CommonObject $domData = ' data-element="extrafield"'; $domData .= ' data-targetelement="'.$this->element.'"'; $domData .= ' data-targetid="'.$this->id.'"'; - + $html_id = !empty($this->id) ? 'extrarow-'.$this->element.'_'.$key.'_'.$this->id : ''; - + $out .= ''; - + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 1f2fb48f4cc..320b8cc1b63 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -635,9 +635,58 @@ function getFormeJuridiqueLabel($code) } } + +/** + * Return list of countries that are inside the EEC (European Economic Community) + * TODO Add a field into country dictionary. + * + * @return array Array of countries code in EEC + */ +function getCountriesInEEC() +{ + // List of all country codes that are in europe for european vat rules + // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 + $country_code_in_EEC=array( + 'AT', // Austria + 'BE', // Belgium + 'BG', // Bulgaria + 'CY', // Cyprus + 'CZ', // Czech republic + 'DE', // Germany + 'DK', // Danemark + 'EE', // Estonia + 'ES', // Spain + 'FI', // Finland + 'FR', // France + 'GB', // United Kingdom + 'GR', // Greece + 'HR', // Croatia + 'NL', // Holland + 'HU', // Hungary + 'IE', // Ireland + 'IM', // Isle of Man - Included in UK + 'IT', // Italy + 'LT', // Lithuania + 'LU', // Luxembourg + 'LV', // Latvia + 'MC', // Monaco - Included in France + 'MT', // Malta + //'NO', // Norway + 'PL', // Poland + 'PT', // Portugal + 'RO', // Romania + 'SE', // Sweden + 'SK', // Slovakia + 'SI', // Slovenia + 'UK', // United Kingdom + //'CH', // Switzerland - No. Swizerland in not in EEC + ); + + return $country_code_in_EEC; +} + /** * Return if a country of an object is inside the EEC (European Economic Community) - * TODO Add a field into country dictionary. * * @param Object $object Object * @return boolean true = country inside EEC, false = country outside EEC @@ -646,43 +695,8 @@ function isInEEC($object) { if (empty($object->country_code)) return false; - // List of all country codes that are in europe for european vat rules - // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9 - $country_code_in_EEC=array( - 'AT', // Austria - 'BE', // Belgium - 'BG', // Bulgaria - 'CY', // Cyprus - 'CZ', // Czech republic - 'DE', // Germany - 'DK', // Danemark - 'EE', // Estonia - 'ES', // Spain - 'FI', // Finland - 'FR', // France - 'GB', // United Kingdom - 'GR', // Greece - 'HR', // Croatia - 'NL', // Holland - 'HU', // Hungary - 'IE', // Ireland - 'IM', // Isle of Man - Included in UK - 'IT', // Italy - 'LT', // Lithuania - 'LU', // Luxembourg - 'LV', // Latvia - 'MC', // Monaco - Included in France - 'MT', // Malta - //'NO', // Norway - 'PL', // Poland - 'PT', // Portugal - 'RO', // Romania - 'SE', // Sweden - 'SK', // Slovakia - 'SI', // Slovenia - 'UK', // United Kingdom - //'CH', // Switzerland - No. Swizerland in not in EEC - ); + $country_code_in_EEC = getCountriesInEEC(); + //print "dd".$this->country_code; return in_array($object->country_code, $country_code_in_EEC); } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 511273fe4c6..62cb8956169 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3145,6 +3145,17 @@ class Societe extends CommonObject return $isacompany; } + /** + * Return if a company is inside the EEC (European Economic Community) + * + * @return boolean true = country inside EEC, false = country outside EEC + */ + function isInEEC() + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + return isInEEC($this); + } + /** * Charge la liste des categories fournisseurs *