diff --git a/htdocs/core/ajaxziptown.php b/htdocs/core/ajaxziptown.php index 020fa5c6e36..8a3ef91364c 100644 --- a/htdocs/core/ajaxziptown.php +++ b/htdocs/core/ajaxziptown.php @@ -30,7 +30,7 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); require('../main.inc.php'); - +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); /* * View @@ -52,6 +52,7 @@ dol_syslog(join(',',$_GET)); if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) { $return_arr = array(); + $formcompany = new FormCompany($db); // Define filter on text typed $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; @@ -121,6 +122,8 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) $row_array['selectpays_id'] = $row['fk_country']; $row_array['departement_id'] = $row['fk_county']; + $row_array['countydata'] = $formcompany->select_state('',$row['fk_country'],''); + array_push($return_arr,$row_array); } } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 07e82008282..cdc2072aebb 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -223,7 +223,7 @@ class FormCompany $result=$this->db->query($sql); if ($result) { - $out.= ''; if ($pays_code) $out.= ''; $num = $this->db->num_rows($result); $i = 0; @@ -264,8 +264,9 @@ class FormCompany $i++; } } - $out.= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + $noselect.=$out; + if (!empty($htmlname)) $out.= ''; + if (!empty($htmlname) && $user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); } else { diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index 2be75f9f7e1..3be2160179b 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -172,9 +172,12 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='') }); }, select: function( event, ui ) { + if (ui.item.countydata) { + jQuery("#departement_id").html(ui.item.countydata); + } for (i=0;i