Fix: change the content of county select if country is different

This commit is contained in:
Regis Houssin 2010-10-13 16:36:10 +00:00
parent 049a32312e
commit bbbad66194
3 changed files with 12 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -223,7 +223,7 @@ class FormCompany
$result=$this->db->query($sql);
if ($result)
{
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
if ($pays_code) $out.= '<option value="0">&nbsp;</option>';
$num = $this->db->num_rows($result);
$i = 0;
@ -264,8 +264,9 @@ class FormCompany
$i++;
}
}
$out.= '</select>';
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
$noselect.=$out;
if (!empty($htmlname)) $out.= '</select>';
if (!empty($htmlname) && $user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{

View File

@ -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<length;i++) {
//alert(fields[i] + " = " + ui.item[fields[i]]);
if (ui.item[fields[i]]) {
if (ui.item[fields[i]]) {
jQuery("#" + fields[i]).val(ui.item[fields[i]]);
}
}