diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang
index 40bb7dfab4b..3807c4bf82a 100644
--- a/htdocs/langs/en_US/mails.lang
+++ b/htdocs/langs/en_US/mails.lang
@@ -62,6 +62,10 @@ EMailTestSubstitutionReplacedByGenericValues=When using test mode, substitutions
MailingAddFile=Attach this file
NoAttachedFiles=No attached files
BadEMail=Bad value for EMail
+CloneEMailing=Clone Emailing
+ConfirmCloneEMailing=Are you sure you want to clone this emailing ?
+CloneContent=Clone message
+CloneReceivers=Cloner recipients
# Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts of all third parties (customer, prospect, supplier, ...)
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index a6d7b6b4b30..afa4507858c 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -108,11 +108,7 @@ Save=Save
SaveAs=Save As
TestConnection=Test connection
ToClone=Clone
-CloneEMailing=Clone Emailing
-CloneContent=Clone message
-CloneReceivers=Cloner recipients
ConfirmClone=Choose data you want to clone :
-ConfirmCloneEMailing=Are you sure you want to clone this emailing ?
NoCloneOptionsSpecified=No data to clone defined.
CopyOf=Copy of
Show=Show
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index cf3ed65a5a1..4b0c31379e2 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -141,4 +141,8 @@ ProductCanvasAbility=Use special "canvas" addons
ServiceNb=Service #%s
ListProductByPopularity=List of products/services by popularity
Finished=Manufactured product
-RowMaterial=First material
\ No newline at end of file
+RowMaterial=First material
+CloneProduct=Clone product or service
+ConfirmCloneProduct=Are you sure you want to clone product or service %s ?
+CloneContentProduct=Clone all main informations of product/service
+ClonePricesProduct=Clone main informations and prices
diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang
index 5aa7f634ce4..26bc686a539 100644
--- a/htdocs/langs/fr_FR/mails.lang
+++ b/htdocs/langs/fr_FR/mails.lang
@@ -62,6 +62,10 @@ EMailTestSubstitutionReplacedByGenericValues=En mode test, les variables de subs
MailingAddFile=Joindre ce fichier
NoAttachedFiles=Aucun fichier joint
BadEMail=EMail incorrect
+CloneEMailing=Cloner Emailing
+ConfirmCloneEMailing=Etes-vous sur de vouloir cloner cet emailing ?
+CloneContent=Cloner message
+CloneReceivers=Cloner destinataires
# Libelle des modules de liste de destinataires mailing
MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...)
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 86e3316a8ec..e787b4e38da 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -108,11 +108,7 @@ Save=Enregistrer
SaveAs=Enregistrer sous
TestConnection=Tester la connexion
ToClone=Cloner
-CloneEMailing=Cloner Emailing
-CloneContent=Cloner message
-CloneReceivers=Cloner destinataires
ConfirmClone=Veuillez choisir votre option de clonage :
-ConfirmCloneEMailing=Etes-vous sur de vouloir cloner cet emailing ?
NoCloneOptionsSpecified=Aucun option de clonage n'a été spécifiée.
CopyOf=Copie de
Show=Voir
diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang
index cd621abf194..82c7e49f7ce 100644
--- a/htdocs/langs/fr_FR/products.lang
+++ b/htdocs/langs/fr_FR/products.lang
@@ -143,4 +143,8 @@ ProductCanvasAbility=Utiliser les extensions speciales "canvas"
ServiceNb=Service no %s
ListProductByPopularity=Liste des produits/services par popularité
Finished=Produit manufacturé
-RowMaterial=Matière première
\ No newline at end of file
+RowMaterial=Matière première
+CloneProduct=Cloner produit/service
+ConfirmCloneProduct=Etes-vous sur de vouloir cloner le produit ou service %s ?
+CloneContentProduct=Cloner les informations générales du produit/service uniquement
+ClonePricesProduct=Cloner les informations générales et les prix
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 6cc78fc1f4b..e58a8a597e2 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -51,9 +51,11 @@ $result=restrictedArea($user,'produit',$id,'product','','',$fieldid);
$mesg = '';
+
/*
- *
+ * Actions
*/
+
if ($_GET["action"] == 'fastappro')
{
$product = new Product($db);
@@ -216,57 +218,64 @@ if ($_POST["action"] == 'update' && $user->rights->produit->creer)
}
}
-// Clone a product
-if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
+// Action clone object
+if ($_POST["action"] == 'confirm_clone' && $_POST['confirm'] == 'yes' && $user->rights->produit->creer)
{
- $db->begin();
-
- $product = new Product($db);
- $originalId = $_GET["id"];
- if ($product->fetch($_GET["id"]) > 0)
+ if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_prices"]))
{
- $product->ref = "Clone ".$product->ref;
- $product->status = 0;
- $product->finished = 1;
- $product->id = null;
-
- if ($product->check())
- {
- $id = $product->create($user);
- if ($id > 0)
- {
- // $product->clone_fournisseurs($originalId, $id);
-
- $db->commit();
- $db->close();
-
- Header("Location: fiche.php?id=$id");
- exit;
- }
- else
- {
- if ($product->error == 'ErrorProductAlreadyExists')
- {
- $db->rollback();
-
- $_error = 1;
- $_GET["action"] = "";
-
- $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$product->ref).'
';
- //dol_print_error($product->db);
- }
- else
- {
- $db->rollback();
- dol_print_error($product->db);
- }
- }
- }
+ $mesg=''.$langs->trans("NoCloneOptionsSpecified").'
';
}
else
{
- $db->rollback();
- dol_print_error($product->db);
+ $db->begin();
+
+ $product = new Product($db);
+ $originalId = $_GET["id"];
+ if ($product->fetch($_GET["id"]) > 0)
+ {
+ $product->ref = $langs->trans("CopyOf").' '.$product->ref;
+ $product->status = 0;
+ $product->finished = 1;
+ $product->id = null;
+
+ if ($product->check())
+ {
+ $id = $product->create($user);
+ if ($id > 0)
+ {
+ // $product->clone_fournisseurs($originalId, $id);
+
+ $db->commit();
+ $db->close();
+
+ Header("Location: fiche.php?id=$id");
+ exit;
+ }
+ else
+ {
+ if ($product->error == 'ErrorProductAlreadyExists')
+ {
+ $db->rollback();
+
+ $_error = 1;
+ $_GET["action"] = "";
+
+ $mesg=''.$langs->trans("ErrorProductAlreadyExists",$product->ref).'
';
+ //dol_print_error($product->db);
+ }
+ else
+ {
+ $db->rollback();
+ dol_print_error($product->db);
+ }
+ }
+ }
+ }
+ else
+ {
+ $db->rollback();
+ dol_print_error($product->db);
+ }
}
}
@@ -1006,129 +1015,129 @@ if ($_GET["id"] || $_GET["ref"])
if ( $product->canvas == '')
{
- print "\n";
- print "';
+ print "\n";
}
else
{
- $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'','');
- $smarty->assign('tva_taux_value', $tvaarray['value']);
- $smarty->assign('tva_taux_libelle', $tvaarray['label']);
- $smarty->display($product->canvas.'-edit.tpl');
+ $tvaarray = load_tva($db,"tva_tx",$conf->defaulttx,$mysoc,'','');
+ $smarty->assign('tva_taux_value', $tvaarray['value']);
+ $smarty->assign('tva_taux_libelle', $tvaarray['label']);
+ $smarty->display($product->canvas.'-edit.tpl');
}
}
}
@@ -1139,6 +1148,21 @@ else if (!$_GET["action"] == 'create')
}
+
+// Clone confirmation
+if ($_GET["action"] == 'clone')
+{
+ // Create an array for form
+ $formquestion=array(
+ 'text' => $langs->trans("ConfirmClone"),
+ array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContentProduct"), 'value' => 1),
+ array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true)
+ );
+ // Paiement incomplet. On demande si motif = escompte ou autre
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$product->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$product->ref),'confirm_clone',$formquestion,'yes');
+}
+
+
/* ************************************************************************** */
/* */
/* Barre d'action */
@@ -1211,12 +1235,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
if ($user->rights->societe->client->voir)
{
- print '';
- print $langs->trans("AddToOtherProposals").' | ';
+ print '';
+ print $langs->trans("AddToOtherProposals").' | ';
}
else
{
- print ' | ';
+ print ' | ';
}
print '';
@@ -1235,83 +1259,83 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$result=$db->query($sql);
if ($result)
{
- $var=true;
- $num = $db->num_rows($result);
- print '";
- $db->free($result);
+ $var=true;
+ $num = $db->num_rows($result);
+ print '";
+ $db->free($result);
}
print '';
if ($user->rights->societe->client->voir)
{
- // Liste de "Other propals"
- print '';
+ // Liste de "Other propals"
+ print ' | ';
- $var=true;
- $otherprop = $propal->liste_array(1, ' <> '.$user->id);
- print '';
- print ' | ';
+ print '';
}
print '';
@@ -1330,12 +1354,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
if ($user->rights->societe->client->voir)
{
- print '';
- print $langs->trans("AddToOtherOrders").' | ';
+ print '';
+ print $langs->trans("AddToOtherOrders").' | ';
}
else
{
- print ' | ';
+ print ' | ';
}
print '';
@@ -1354,81 +1378,81 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
$result=$db->query($sql);
if ($result)
{
- $num = $db->num_rows($result);
- $var=true;
- print '";
- $db->free($result);
+ $num = $db->num_rows($result);
+ $var=true;
+ print '";
+ $db->free($result);
}
print '';
if ($user->rights->societe->client->voir)
{
- // Liste de "Other orders"
- print '';
+ // Liste de "Other orders"
+ print ' | ';
- $var=true;
- $othercom = $commande->liste_array(1, ' <> '.$user->id);
- print '';
+ $var=true;
+ $othercom = $commande->liste_array(1, ' <> '.$user->id);
+ print '';
}
print ' | ';
@@ -1445,12 +1469,12 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->status)
if ($user->rights->societe->client->voir)
{
- print '';
- print $langs->trans("AddToOtherBills").' | ';
+ print '';
+ print $langs->trans("AddToOtherBills").' | ';
}
else
{
- print ' | ';
+ print ' | ';
}
print '';