Fix select zip/town

This commit is contained in:
Laurent Destailleur 2018-08-13 16:44:49 +02:00
parent f96dd391fa
commit 33f0172603
2 changed files with 9 additions and 6 deletions

View File

@ -120,6 +120,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
$row_array['selectcountry_id'] = $row['fk_country'];
$row_array['state_id'] = $row['fk_county'];
// TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs)
$row_array['states'] = $formcompany->select_state('',$row['fk_country'],'');
array_push($return_arr,$row_array);

View File

@ -203,7 +203,7 @@ class FormCompany
*
* @param string $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
* @param string $htmlname Id of department. If '', we want only the string with <option>
* @return string String with HTML select
* @see select_country
*/
@ -217,7 +217,7 @@ class FormCompany
$out='';
// On recherche les departements/cantons/province active d'une region et pays actif
// Serch departements/cantons/province active d'une region et pays actif
$sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM";
$sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
@ -226,7 +226,6 @@ class FormCompany
if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'";
$sql .= " ORDER BY c.code, d.code_departement";
dol_syslog(get_class($this)."::select_departement", LOG_DEBUG);
$result=$this->db->query($sql);
if ($result)
{
@ -298,9 +297,12 @@ class FormCompany
dol_print_error($this->db);
}
// Make select dynamic
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
// Make select dynamic
if (! empty($htmlname))
{
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
}
return $out;
}