diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d5c78761989..dccf26e75c0 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -420,7 +420,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; if ($mysoc->country_code) { - print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$mysoc->country_code); + print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'legal_form'); } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f34d18fe47d..bb03435d25e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -503,7 +503,7 @@ class Form $resql=$this->db->query($sql); if ($resql) { - $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -531,7 +531,7 @@ class Form if (empty($row['favorite']) && $atleastonefavorite) { $atleastonefavorite=0; - $out.= ''; + $out.= ''; } if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label']) ) { @@ -554,6 +554,10 @@ class Form dol_print_error($this->db); } + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox('select'.$htmlname); + return $out; } @@ -4342,10 +4346,9 @@ class Form '; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index e5d8fa5688e..d3ffa569a7a 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -105,6 +105,10 @@ class FormAdmin } $out.= ''; + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname); + return $out; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 4f600ac0705..05200feee30 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -210,6 +210,7 @@ class FormCompany * @param string $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 * @return string String with HTML select + * @see select_country */ function select_state($selected='',$country_codeid=0, $htmlname='state_id') { @@ -234,7 +235,7 @@ class FormCompany $result=$this->db->query($sql); if ($result) { - if (!empty($htmlname)) $out.= ''; if ($country_codeid) $out.= ''; $num = $this->db->num_rows($result); $i = 0; @@ -277,13 +278,17 @@ class FormCompany } } if (! empty($htmlname)) $out.= ''; - if (! empty($htmlname) && $user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } else { dol_print_error($this->db); } + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + return $out; } @@ -431,9 +436,10 @@ class FormCompany * @param string $selected Preselected code of juridical type * @param int $country_codeid 0=list for all countries, otherwise list only country requested * @param string $filter Add a SQL filter on list + * @param string $htmlname HTML name of select * @return string String with HTML select */ - function select_juridicalstatus($selected='', $country_codeid=0, $filter='') + function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') { global $conf,$langs,$user; $langs->load("dict"); @@ -454,7 +460,7 @@ class FormCompany if ($resql) { $out.= '
'; - $out.= ''; if ($country_codeid) $out.= ''; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. $num = $this->db->num_rows($resql); @@ -488,7 +494,7 @@ class FormCompany // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { - $out.= '\n"; + $out.= '\n"; $country=$val['country']; } } @@ -508,6 +514,11 @@ class FormCompany } $out.= ''; if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + $out.= '
'; } else diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 0b119ada66a..47c4773cf62 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -328,14 +328,17 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; - $msg = '