diff --git a/htdocs/comm/adresse_livraison.php b/htdocs/comm/adresse_livraison.php
index 57f13d70c12..740ecd3778e 100644
--- a/htdocs/comm/adresse_livraison.php
+++ b/htdocs/comm/adresse_livraison.php
@@ -47,6 +47,8 @@ if (! $user->rights->societe->creer)
}
$idl = isset($_GET["idl"])?$_GET["idl"]:'';
+$origin = isset($_GET["origin"])?$_GET["origin"]:'';
+$originid = isset($_GET["originid"])?$_GET["originid"]:'';
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add' && $_REQUEST["action"] != 'update')) accessforbidden();
@@ -98,8 +100,16 @@ if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
if ($result >= 0)
{
+ if ($origin == commande)
+ {
+ Header("Location: ../commande/fiche.php?action=editdelivery_adress&socid=".$socid."&id=".$originid);
+ exit;
+ }
+ else
+ {
Header("Location: adresse_livraison.php?socid=".$socid);
exit;
+ }
}
else
{
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 6da2a199fa7..f3532d29039 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -739,7 +739,7 @@ else
print '
';
if ($_GET['action'] == 'editdelivery_adress')
{
- $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id');
+ $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
}
else
{
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 69c4a97a9ad..eaf6b6de592 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -1584,9 +1584,10 @@ class Form
* \param page Page
* \param selected Id condition présélectionnée
* \param htmlname Nom du formulaire select
- * \param addempty Ajoute entrée vide
+ * \param origin origine de l'appel pour pouvoir créer un retour
+ * \param id id de l'origine
*/
- function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id')
+ function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id', $origin='', $id)
{
global $langs,$conf;
if ($htmlname != "none")
@@ -1602,7 +1603,7 @@ class Form
if ($numaddress==0)
{
$langs->load("companies");
- print ' '.$langs->trans("AddAddress").'';
+ print ' '.$langs->trans("AddAddress").'';
}
print ' | ';
}