Merge pull request #18552 from aspangaro/15a12

NEW Invoice list - Use complete country select field with EEC or not
This commit is contained in:
Laurent Destailleur 2021-09-01 17:17:48 +02:00 committed by GitHub
commit 7c5621a2d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,7 +106,7 @@ $search_pos_source = GETPOST('search_pos_source', 'alpha');
$search_town = GETPOST('search_town', 'alpha');
$search_zip = GETPOST('search_zip', 'alpha');
$search_state = GETPOST("search_state");
$search_country = GETPOST("search_country", 'int');
$search_country = GETPOST("search_country", 'alpha');
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
$search_user = GETPOST('search_user', 'int');
$search_sale = GETPOST('search_sale', 'int');
@ -652,8 +652,26 @@ if ($search_zip) {
if ($search_state) {
$sql .= natural_search("state.nom", $search_state);
}
if ($search_country) {
$sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
if (strlen(trim($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 country.code <> '".$db->escape($mysoc->country_code)."'";
} elseif ($search_country == 'special_eec') {
$sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
} elseif ($search_country == 'special_eecnotme') {
$sql .= " AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
} elseif ($search_country == 'special_noteec') {
$sql .= " AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
} else {
$sql .= natural_search("country.code", $search_country);
}
}
if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') {
$sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
@ -941,6 +959,9 @@ if ($resql) {
if ($search_zip) {
$param .= '&search_zip='.urlencode($search_zip);
}
if ($search_country) {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_sale > 0) {
$param .= '&search_sale='.urlencode($search_sale);
}
@ -1259,7 +1280,7 @@ if ($resql) {
// Country
if (!empty($arrayfields['country.code_iso']['checked'])) {
print '<td class="liste_titre" align="center">';
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, null, 1);
print '</td>';
}
// Company type