diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 2ac6ef5316e..e1ce804a270 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -377,12 +377,12 @@ else
if ($conf->use_javascript_ajax)
{
- print "\n".''."\n";
+ print ''."\n";
}
print '
';
@@ -434,8 +434,8 @@ else
// Address
if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party
print '
'.$langs->trans("Address");
- if ($conf->use_javascript_ajax) print ' '.$langs->trans('CopyAddressFromSoc').' | ';
- print ' | ';
+ if ($conf->use_javascript_ajax) print '
'.$langs->trans('CopyAddressFromSoc').'';
+ print ' | ';
// Zip / Town
if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party
@@ -576,20 +576,30 @@ else
$object->country_code = $tmparray['code'];
$object->country = $tmparray['label'];
}
+
+ $objsoc = new Societe($db);
+ $objsoc->fetch($object->socid);
// Affiche les erreurs
dol_htmloutput_errors($error,$errors);
if ($conf->use_javascript_ajax)
{
- print '';
+
+ $("#copyaddressfromsoc").click(function() {
+ $(\'textarea[name="address"]\').text("'.addslashes($objsoc->address).'");
+ $(\'input[name="zipcode"]\').val("'.addslashes($objsoc->zip).'");
+ $(\'input[name="town"]\').val("'.addslashes($objsoc->town).'");
+ $(\'select[name="country_id"]\').val("'.addslashes($objsoc->country_id).'");
+ });
+ })'."\n";
+ print ''."\n";
}
print '