diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index 854e8df1a57..0d76e41d012 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -27,6 +27,7 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); $langs->load("companies"); @@ -55,8 +56,8 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update') $address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:''); $address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:''); $address->address = $_POST["address"]; - $address->cp = $_POST["cp"]; - $address->ville = $_POST["ville"]; + $address->cp = $_POST["zipcode"]; + $address->ville = $_POST["town"]; $address->pays_id = $_POST["pays_id"]; $address->tel = $_POST["tel"]; $address->fax = $_POST["fax"]; @@ -159,6 +160,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user- llxHeader(); $form = new Form($db); +$formcompany = new FormCompany($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (!empty($mesg)) print '
'.$mesg.'
'; @@ -185,8 +187,8 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create') $address->label = $_POST["label"]; $address->name = $_POST["name"]; $address->address = $_POST["address"]; - $address->cp = $_POST["cp"]; - $address->ville = $_POST["ville"]; + $address->cp = $_POST["zipcode"]; + $address->ville = $_POST["town"]; $address->tel = $_POST["tel"]; $address->fax = $_POST["fax"]; $address->note = $_POST["note"]; @@ -263,10 +265,16 @@ if ($_GET["action"] == 'create' || $_POST["action"] == 'create') print ''.$langs->trans('Address').''; - - print ''.$langs->trans('Zip').''; - print ''; - print ''.$langs->trans('Town').''; + + // Zip + print ''.$langs->trans('Zip').''; + $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectpays_id'),6); + print ''; + + // Town + print ''.$langs->trans('Town').''; + $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectpays_id')); + print ''; print ''.$langs->trans('Country').''; $form->select_pays($address->pays_id,'pays_id'); @@ -318,8 +326,8 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') $address->label = $_POST["label"]; $address->name = $_POST["name"]; $address->address = $_POST["address"]; - $address->zip = $_POST["zip"]; - $address->ville = $_POST["ville"]; + $address->cp = $_POST["zipcode"]; + $address->ville = $_POST["town"]; $address->pays_id = $_POST["pays_id"]?$_POST["pays_id"]:$mysoc->pays_id; $address->tel = $_POST["tel"]; $address->fax = $_POST["fax"]; @@ -370,10 +378,15 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print $address->address; print ''; - print ''.$langs->trans('Zip').''; - print ''; - - print ''.$langs->trans('Town').''; + // Zip + print ''.$langs->trans('Zip').''; + $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectpays_id'),6); + print ''; + + // Town + print ''.$langs->trans('Town').''; + $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectpays_id')); + print ''; print ''.$langs->trans('Country').''; $form->select_pays($address->pays_id,'pays_id'); diff --git a/htdocs/societe/ajaxziptown.php b/htdocs/core/ajaxziptown.php similarity index 100% rename from htdocs/societe/ajaxziptown.php rename to htdocs/core/ajaxziptown.php diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 5b82d235968..10a6df494a9 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -617,7 +617,7 @@ class FormCompany $size=''; if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; - if ($conf->use_javascript_ajax) print ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/societe/ajaxziptown.php')."\n"; + if ($conf->use_javascript_ajax) print ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajaxziptown.php')."\n"; print ''."\n"; }