From 16bdd0dc491744ecfbff2e7c5b250b4a91ae5ecb Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Sat, 21 May 2022 18:54:38 +0200 Subject: [PATCH 01/10] FIX #20930 --- htdocs/core/ajax/ziptown.php | 3 +++ htdocs/core/class/html.formcompany.class.php | 26 ++++++++++++++++++++ htdocs/user/card.php | 4 +-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index aa9474ce142..3cd50c8b612 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -141,6 +141,9 @@ if (GETPOST('zipcode') || GETPOST('town')) { } echo json_encode($return_arr); +} elseif (isset($_GET['country_codeid'])) { + $formcompany = new FormCompany($db); + print $formcompany->select_state(GETPOST('selected', 'int', 1), GETPOST('country_codeid', 'int', 1), GETPOST('htmlname', 'alpha', 1), GETPOST('morecss', 'alpha', 1)); } $db->close(); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f976fac978d..d1c79ab2979 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -366,6 +366,32 @@ class FormCompany extends Form return $out; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. + * In the case of an all-country list, the display breaks on the country. + * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). + * Thus the links with the departments are done on a department independently of its name. + * + * @param string $parent_field_id Parent select name to monitor + * @param integer $selected Code state preselected (mus be state id) + * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department. If '', we want only the string with