diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 83b2c719e81..483706fda4b 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -710,12 +710,13 @@ class Commande extends CommonObject
/**
- * \brief Load an object from its id and create a new one in database
- * \param fromid Id of object to clone
- * \param invertdetail Reverse sign of amounts for lines
- * \return int New id of clone
+ * Load an object from its id and create a new one in database
+ * @param fromid Id of object to clone
+ * @param invertdetail Reverse sign of amounts for lines
+ * @param socid Id of thirdparty
+ * @return int New id of clone
*/
- function createFromClone($fromid,$invertdetail=0)
+ function createFromClone($fromid,$invertdetail=0,$socid=0)
{
global $conf,$user,$langs;
@@ -734,6 +735,13 @@ class Commande extends CommonObject
// Load source object
$object->fetch($fromid);
$objFrom = $object;
+
+ // Change socid if needed
+ if (! empty($socid) && $socid != $object->socid)
+ {
+ $object->socid = $socid;
+ // TODO clear delivery address, project linked, change product price if multi-prices
+ }
$object->id=0;
$object->statut=0;
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 5a6e568e630..a18789fef92 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -90,13 +90,13 @@ if (! empty($object->hooks))
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
{
- if (1==0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"]))
+ if ( 1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers') )
{
$mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
';
}
else
{
- $result=$object->createFromClone($id);
+ $result=$object->createFromClone($id, 0, GETPOST('socid'));
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@@ -1497,7 +1497,8 @@ else
// Create an array for form
$formquestion=array(
//'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1)
+ //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ //array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $html->select_company(GETPOST('socid'),'socid','(s.client=1 OR s.client=3)'))
);
// Paiement incomplet. On demande si motif = escompte ou autre
$formconfirm=$html->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
@@ -1936,7 +1937,7 @@ else
// Clone
if ($user->rights->commande->creer)
{
- print ''.$langs->trans("ToClone").'';
+ print ''.$langs->trans("ToClone").'';
}
// Cancel order
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 980d422e5ff..5af432450ee 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1986,6 +1986,7 @@ class Form
$more='';
$formconfirm='';
+ $inputarray=array();
if (empty($height)) $height=170;
@@ -1997,15 +1998,16 @@ class Form
{
if ($input['type'] == 'text')
{
- $more.='
'.$input['label'].'
'."\n";
+ $more.='
'.$input['label'].'
'."\n";
}
if ($input['type'] == 'password')
{
- $more.='
'.$input['label'].'
'."\n";
+ $more.='
'.$input['label'].'
'."\n";
}
if ($input['type'] == 'select')
{
- $more.='
';
+ $more.='
';
+ if (! empty($input['label'])) $more.=$input['label'].'