diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f03986d471c..47dd722b5b1 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -793,7 +793,7 @@ if (empty($reshook)) } elseif ($action == 'addline' && $usercancreate) { // Add line // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOSTISSET('dp_desc') ?GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht')); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); $prod_entry_mode = GETPOST('prod_entry_mode'); @@ -1001,7 +1001,7 @@ if (empty($reshook)) } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc) { + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6572a383532..1bdce17f564 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -640,7 +640,7 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = GETPOST('price_ht'); $price_ht_devise = GETPOST('multicurrency_price_ht'); $prod_entry_mode = GETPOST('prod_entry_mode'); @@ -855,7 +855,7 @@ if (empty($reshook)) } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc) { + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 80e60dd8784..4602e968220 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1902,7 +1902,7 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht')); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); @@ -2073,7 +2073,7 @@ if (empty($reshook)) } //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc) { + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 034709ef110..3265e2f5866 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -383,7 +383,7 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht')); $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); if (GETPOST('prod_entry_mode', 'alpha') == 'free') @@ -501,7 +501,7 @@ if (empty($reshook)) $desc = $prod->description; //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if ($product_desc==$desc) { + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c69b57a90d0..f1faf50e991 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -674,13 +674,18 @@ if (!empty($usemargins) && $user->rights->margins->creer) function(data) { console.log("Load unit price end, we got value "+data.price_ht); jQuery("#price_ht").val(data.price_ht); - global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?> + global->PRODUIT_AUTOFILL_DESC)) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?> var proddesc = data.desc_trans; - + var proddesc = data.desc; - + console.log("Load desciption into text area : "+proddesc); - global->FCKEDITOR_ENABLE_DETAILS)) { ?> + global->FCKEDITOR_ENABLE_DETAILS)) { ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { var editor = CKEDITOR.instances['dp_desc']; @@ -688,9 +693,13 @@ if (!empty($usemargins) && $user->rights->margins->creer) editor.setData(proddesc); } } - + jQuery('#dp_desc').text(proddesc); - + + }, 'json' ); @@ -834,7 +843,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#remise_percent").val(pbqpercent); } - } + } else { jQuery("#pbq").val(''); } @@ -850,8 +859,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) var discount = parseFloat($('option:selected', this).attr('data-discount')); if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));} - var description = $('option:selected', this).attr('data-description'); - if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); } console.log("We find supplier price :"+up+" qty: "+qty+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val()); jQuery("#price_ht").val(up); @@ -864,24 +871,48 @@ if (!empty($usemargins) && $user->rights->margins->creer) jQuery("#remise_percent").val(discount); } + global->PRODUIT_AUTOFILL_DESC)) { + ?> + var description = $('option:selected', this).attr('data-description'); + if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); } + console.log("Load desciption into text area : "+description); - global->FCKEDITOR_ENABLE_DETAILS)) { ?> + global->FCKEDITOR_ENABLE_DETAILS)) { ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { var editor = CKEDITOR.instances['dp_desc']; if (editor) { - editor.setData(description); + editor.setData(description); } } - + jQuery('#dp_desc').text(description); - - } - else - { - jQuery("#pbq").val(''); + + } else if (jQuery('#idprodfournprice').length > 0) { + global->PRODUIT_AUTOFILL_DESC)) { + if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> + if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { + editor.setData(''); + } + } + + jQuery('#dp_desc').text(''); + } + /* To set focus */ if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 42817e2ea28..f7c963f5e29 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -484,7 +484,13 @@ if (empty($reshook)) $desc = $productsupplier->desc_supplier; } - if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; + if (!empty($product_desc) && trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; if ($price_ht != '' || $price_ht_devise != '') { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 9849e3b6223..a6bc58879c1 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1294,7 +1294,12 @@ if (empty($reshook)) $desc = $productsupplier->desc_supplier; } else $desc = $productsupplier->description; - if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); + //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time + if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { + $product_desc=''; + } + if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc; + if (!empty($product_desc) && trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); $type = $productsupplier->type; if ($price_ht != '' || $price_ht_devise != '') { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e47390b9ce0..c2bcdef711f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1587,6 +1587,8 @@ ServiceSetup=Services module setup ProductServiceSetup=Products and Services modules setup NumberOfProductShowInSelect=Maximum number of products to show in combo select lists (0=no limit) ViewProductDescInFormAbility=Display product descriptions in forms (otherwise shown in a tooltip popup) +DoNotAddProductDescAtAddLines=Do not add product description (from product card) on submit add lines on forms +OnProductSelectAddProductDesc=On product selection in forms get the production description into description line MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Display products descriptions in the language of the third party UseSearchToSelectProductTooltip=Also if you have a large number of products (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. @@ -2067,4 +2069,4 @@ TemplateDeleted=Template deleted MailToSendEventPush=Event reminder email SwitchThisForABetterSecurity=Switching this value to %s is recommended for more security DictionaryProductNature= Nature of product -CountryIfSpecificToOneCountry=Country (if specific to a given country) \ No newline at end of file +CountryIfSpecificToOneCountry=Country (if specific to a given country) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 313a27884ff..e7003c6ee47 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -145,6 +145,12 @@ if ($action == 'other') $value = GETPOST('activate_useProdFournDesc', 'alpha'); $res = dolibarr_set_const($db, "PRODUIT_FOURN_TEXTS", $value, 'chaine', 0, '', $conf->entity); + $value = GETPOST('activate_FillProductDescAuto', 'alpha'); + $res = dolibarr_set_const($db, "PRODUIT_AUTOFILL_DESC", $value, 'chaine', 0, '', $conf->entity); + + $value = GETPOST('activate_DoNotAddStdProductDescOnAddLine', 'alpha'); + $res = dolibarr_set_const($db, "MAIN_NO_CONCAT_DESCRIPTION", $value, 'chaine', 0, '', $conf->entity); + if ($value) { $sql_test = "SELECT count(desc_fourn) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1"; $resql = $db->query($sql_test); @@ -630,6 +636,23 @@ print $form->selectyesno("activate_viewProdDescInForm", $conf->global->PRODUIT_D print ''; print ''; +// Do Not Add Product description on add lines +print ''; +print ''.$langs->trans("DoNotAddProductDescAtAddLines").''; +print ''; +print $form->selectyesno("activate_DoNotAddStdProductDescOnAddLine", $conf->global->MAIN_NO_CONCAT_DESCRIPTION, 1); +print ''; +print ''; + +// Do Not Add Product description on add lines +print ''; +print ''.$langs->trans("OnProductSelectAddProductDesc").''; +print ''; +print $form->selectyesno("activate_FillProductDescAuto", $conf->global->PRODUIT_AUTOFILL_DESC, 1); +print ''; +print ''; + + // Activate propal merge produt card /* Kept as hidden feature only. PRODUIT_PDF_MERGE_PROPAL can be added manually. Still did not understand how this feature works. diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c2b698c8e04..40249e4041e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -99,6 +99,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) $outputlangs->setDefaultLang($newlang); $outdesc_trans = (!empty($object->multilangs[$outputlangs->defaultlang]["description"])) ? $object->multilangs[$outputlangs->defaultlang]["description"] : $object->description; $outlabel_trans = (!empty($object->multilangs[$outputlangs->defaultlang]["label"])) ? $object->multilangs[$outputlangs->defaultlang]["label"] : $object->label; + } else { + $outdesc_trans = $object->description; + $outlabel_trans = $object->label; } } }