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 "
\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'; + print ''; + print ''; - // Status - print ''; + // Status + print ''; - // Description (utilisé dans facture, propale...) - print '"; - print "\n"; + // Description (utilisé dans facture, propale...) + print '"; + print "\n"; - // Nature - if($product->type!=1) - { - print ''; - } + // Nature + if($product->type!=1) + { + print ''; + } - if ($product->isproduct() && $conf->stock->enabled) - { - print "".''; - } - else - { - print ''; - } + if ($product->isproduct() && $conf->stock->enabled) + { + print "".''; + } + else + { + print ''; + } - if ($product->isservice()) - { - // Duration - print ''; - } - else - { - // Weight / Volume - print ''; + print ''; + } + else + { + // Weight / Volume + print ''; - print ''; - } + print ''; + } - // Note - print '"; + // Note + print '"; - print ''; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Status").''; - print ''; - print '
'.$langs->trans("Status").''; + print ''; + print '
'.$langs->trans("Description").''; - print "\n"; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
'.$langs->trans("Description").''; + print "\n"; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print '"; + } + print "
'.$langs->trans("Nature").''; - $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); - $html->select_array('finished',$statutarray,$product->finished); - print '
'.$langs->trans("Nature").''; + $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); + $html->select_array('finished',$statutarray,$product->finished); + print '
'.$langs->trans("StockLimit").''; - print ''; - print '
'.$langs->trans("StockLimit").''; + print ''; + print '
'.$langs->trans("Duration").''; - print '  '; - print 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); - print '  '; - print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); - print '  '; - print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); - print '  '; - print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); - print '  '; - print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); + if ($product->isservice()) + { + // Duration + print '
'.$langs->trans("Duration").''; + print '  '; + print 'duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); + print '  '; + print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); + print '  '; + print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); + print '  '; + print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); + print '  '; + print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - print '
'.$langs->trans("Weight").''; - print ' '; - print $formproduct->select_measuring_units("weight_units", "weight", $product->weight_units); - print '
'.$langs->trans("Weight").''; + print ' '; + print $formproduct->select_measuring_units("weight_units", "weight", $product->weight_units); + print '
'.$langs->trans("Volume").''; - print ' '; - print $formproduct->select_measuring_units("volume_units", "volume", $product->volume_units); - print '
'.$langs->trans("Volume").''; + print ' '; + print $formproduct->select_measuring_units("volume_units", "volume", $product->volume_units); + print '
'.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print '"; - } - print "
'.$langs->trans("NoteNotVisibleOnBill").''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print '"; + } + print "
 '; - print '
'; - print '
'; - print "\n"; + print ' '; + print ''; + print ''; + 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 ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else { - print ""; - } - print "
"; - print ''; - print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$product->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedPropals"); - print "
"; - $db->free($result); + $var=true; + $num = $db->num_rows($result); + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else { + print ""; + } + print "
"; + print ''; + print "propalid."\">".img_object($langs->trans("ShowPropal"),"propal")." ".$objp->ref."socid."\">".dol_trunc($objp->nom,18)."".dol_print_date($objp->dp,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$product->stock_proposition; + print ''; + print ''; + print '
"; + print $langs->trans("NoOpenedPropals"); + 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 ''; + $var=true; + $otherprop = $propal->liste_array(1, ' <> '.$user->id); + print '
'; - if (is_array($otherprop) && sizeof($otherprop)) - { - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherPropals").''; - $html->select_array("propalid", $otherprop); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedPropals"); - print '
'; + if (is_array($otherprop) && sizeof($otherprop)) + { + $var=!$var; + print '
'; + print ''; + print ''; + print ''; + print $langs->trans("OtherPropals").''; + $html->select_array("propalid", $otherprop); + print ''; + print ''.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print ''; + print '
'; + } + else + { + print ""; + print $langs->trans("NoOtherOpenedPropals"); + print ''; + } + 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 ''; - if ($num) - { - $i = 0; - while ($i < $num) - { - $objc = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ""; - print "\n"; - print "\n"; - print "\n"; - print ''; - print ''; - print ''; - $i++; - } - } - else - { - print "'; - } - print "
"; - print ''; - print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($objc->dc,"%d %b")."'; - print ''.$langs->trans("ReductionShort"); - print '%'; - print " ".$product->stock_proposition; - print ''; - print ''; - print '
"; - print $langs->trans("NoOpenedOrders"); - print '
"; - $db->free($result); + $num = $db->num_rows($result); + $var=true; + print ''; + if ($num) + { + $i = 0; + while ($i < $num) + { + $objc = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ""; + print "\n"; + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + $i++; + } + } + else + { + print "'; + } + print "
"; + print ''; + print "commandeid."\">".img_object($langs->trans("ShowOrder"),"order")." ".$objc->ref."socid."\">".dol_trunc($objc->nom,18)."".dol_print_date($objc->dc,"%d %b")."'; + print ''.$langs->trans("ReductionShort"); + print '%'; + print " ".$product->stock_proposition; + print ''; + print ''; + print '
"; + print $langs->trans("NoOpenedOrders"); + 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 ''; - if (is_array($othercom) && sizeof($othercom)) - { - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else - { - print "'; - } - print '
'; - print ''; - print $langs->trans("OtherOrders").''; - $html->select_array("commandeid", $othercom); - print '
'.$langs->trans("Qty"); - print ''.$langs->trans("ReductionShort"); - print '%'; - print ''; - print ''; - print '
"; - print $langs->trans("NoOtherOpenedOrders"); - print '
'; + $var=true; + $othercom = $commande->liste_array(1, ' <> '.$user->id); + print ''; + if (is_array($othercom) && sizeof($othercom)) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print ''; + } + else + { + print "'; + } + print '
'; + print ''; + print $langs->trans("OtherOrders").''; + $html->select_array("commandeid", $othercom); + print '
'.$langs->trans("Qty"); + print ''.$langs->trans("ReductionShort"); + print '%'; + print ''; + print ''; + print '
"; + print $langs->trans("NoOtherOpenedOrders"); + 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 '';