diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php
index fa9f5de6091..52ae082fc4c 100644
--- a/htdocs/comm/addpropal.php
+++ b/htdocs/comm/addpropal.php
@@ -115,6 +115,13 @@ if ($_GET["action"] == 'create')
print '';
print '';
print '';
+
+ /*
+ * Contact de la propale
+ */
+ print "
| ".$langs->trans("DefaultContact")." | \n";
+ $html->select_contacts($soc->id,$setcontact,'contactidp',1);
+ print ' |
';
// Ligne info remises tiers
print '| '.$langs->trans('Discounts').' | ';
@@ -217,13 +224,6 @@ if ($_GET["action"] == 'create')
print ' |
';
}
- /*
- * Contact de la propale
- */
- print "| ".$langs->trans("DefaultContact")." | \n";
- $html->select_contacts($soc->id,$setcontact,'contactidp',1);
- print ' |
';
-
// Model
print '';
print '| '.$langs->trans("DefaultModel").' | ';
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index c461e88d451..b05e76dec22 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -102,6 +102,7 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande->mode_reglement_id = $_POST['mode_reglement_id'];
$commande->date_livraison = $datelivraison;
$commande->adresse_livraison_id = $_POST['adresse_livraison_id'];
+ $commande->contactid = $_POST['contactidp'];
$commande->fetch_client();
@@ -124,6 +125,22 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
}
else
{
+ // Insertion contact par defaut si défini
+ if ($_POST["contactidp"])
+ {
+ $result=$commande->add_contact($_POST["contactidp"],'CUSTOMER','external');
+
+ if ($result > 0)
+ {
+ $error=0;
+ }
+ else
+ {
+ $msg = ''.$langs->trans("ErrorFailedToAddContact").'
';
+ $error=1;
+ }
+ }
+
$_GET['id'] = $commande->id;
$action = '';
}
@@ -628,6 +645,13 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
// Client
print '
| '.$langs->trans('Customer').' | '.$soc->getNomUrl(1).' | ';
print '
';
+
+ /*
+ * Contact de la propale
+ */
+ print "| ".$langs->trans("DefaultContact")." | \n";
+ $html->select_contacts($soc->id,$setcontact,'contactidp',1);
+ print ' |
';
// Ligne info remises tiers
print '| '.$langs->trans('Discounts').' | ';
|