diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index d9e5aa80a3f..ba935a51a1e 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","productbatch"));
@@ -229,7 +230,18 @@ else if ($search_year > 0)
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
if (strlen(trim($search_country))) {
- $sql .= natural_search("co.code", $search_country);
+ $arrayofcode = getCountriesInEEC();
+ $country_code_in_EEC = $country_code_in_EEC_without_me = '';
+ foreach ($arrayofcode as $key => $value)
+ {
+ $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
+ if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
+ }
+ if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
+ elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
+ elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
+ elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
+ else $sql .= natural_search(array("co.code","co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
@@ -308,7 +320,7 @@ if ($result) {
print '
';
print ' ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2');
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
//print ' ';
print ' ';
print ' ';
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index fb604988582..53674d4cbcb 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
@@ -266,7 +267,18 @@ else if ($search_year > 0)
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
if (strlen(trim($search_country))) {
- $sql .= natural_search("co.code", $search_country);
+ $arrayofcode = getCountriesInEEC();
+ $country_code_in_EEC = $country_code_in_EEC_without_me = '';
+ foreach ($arrayofcode as $key => $value)
+ {
+ $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
+ if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
+ }
+ if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
+ elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
+ elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
+ elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
+ else $sql .= natural_search(array("co.code","co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
@@ -373,7 +385,7 @@ if ($result) {
print ' ';
print ' ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2');
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
//print ' ';
print ' ';
print ' ';
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index 48bde2dfb87..b2df1231a4e 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","other","accountancy","productbatch"));
@@ -223,7 +224,18 @@ else if ($search_year > 0)
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
if (strlen(trim($search_country))) {
- $sql .= natural_search("co.code", $search_country);
+ $arrayofcode = getCountriesInEEC();
+ $country_code_in_EEC = $country_code_in_EEC_without_me = '';
+ foreach ($arrayofcode as $key => $value)
+ {
+ $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
+ if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
+ }
+ if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
+ elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
+ elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
+ elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
+ else $sql .= natural_search(array("co.code","co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
@@ -312,7 +324,7 @@ if ($result) {
print ' ';
print ' ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2');
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
// print ' ';
print ' ';
print ' ';
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 9a4610a2e42..53dcc4b1270 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills","compta","accountancy","other","productbatch"));
@@ -265,7 +266,18 @@ else if ($search_year > 0)
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
if (strlen(trim($search_country))) {
- $sql .= natural_search("co.label", $search_country);
+ $arrayofcode = getCountriesInEEC();
+ $country_code_in_EEC = $country_code_in_EEC_without_me = '';
+ foreach ($arrayofcode as $key => $value)
+ {
+ $country_code_in_EEC.=($country_code_in_EEC ? "," : "")."'".$value."'";
+ if ($value != $mysoc->country_code) $country_code_in_EEC_without_me.=($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
+ }
+ if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
+ elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
+ elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
+ elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
+ else $sql .= natural_search(array("co.code","co.label"), $search_country);
}
if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra);
@@ -374,7 +386,7 @@ if ($result) {
print ' ';
print ' ';
print '';
- print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2');
+ print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth200', 'code2', 1, 0, 1);
//print ' ';
print ' ';
print ' ';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index ec682f8b2b2..e4be098329c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -665,13 +665,14 @@ class Form
* @param string $morecss More css class
* @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key
* @param int $showempty Show empty choice
- * @param int $disablefavorites Disable favorites
+ * @param int $disablefavorites 1=Disable favorites,
+ * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...)
* @return string HTML string with select
*/
- function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1, $disablefavorites=0)
+ function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1, $disablefavorites=0, $addspecialentries=0)
{
// phpcs:enable
- global $conf,$langs;
+ global $conf,$langs,$mysoc;
$langs->load("dict");
@@ -713,9 +714,25 @@ class Form
if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray);
else $countryArray = dol_sort_array($countryArray, 'label');
+ if ($showempty)
+ {
+ $out.=' '."\n";
+ }
+
+ if ($addspecialentries) // Add dedicated entries for groups of countries
+ {
+ //if ($showempty) $out.= '-------------- ';
+ $out.= ''.$langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).' ';
+ $out.= ''.$langs->trans("CountriesInEEC").' ';
+ if ($mysoc->isInEEC()) $out.= ''.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).' ';
+ $out.= ''.$langs->trans("CountriesNotInEEC").' ';
+ $out.= '-------------- ';
+ }
+
foreach ($countryArray as $row)
{
- if (empty($showempty) && empty($row['rowid'])) continue;
+ //if (empty($showempty) && empty($row['rowid'])) continue;
+ if (empty($row['rowid'])) continue;
if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++;
if (empty($row['favorite']) && $atleastonefavorite)
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index e1fe73d0383..57e9b5aa894 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -38,6 +38,10 @@ GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accountin
DetailByAccount=Show detail by account
AccountWithNonZeroValues=Accounts with non-zero values
ListOfAccounts=List of accounts
+CountriesInEEC=Countries in EEC
+CountriesNotInEEC=Countries not in EEC
+CountriesInEECExceptMe=Countries in EEC except %s
+CountriesExceptMe=All countries except %s
MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup
MainAccountForSuppliersNotDefined=Main accounting account for vendors not defined in setup