From 6da3ed1a51cbf27bc1249c5fbde7a4ff26e70bfb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jan 2021 12:39:51 +0100 Subject: [PATCH] Merge 2 exclusive options into 1 --- htdocs/comm/propal/card.php | 5 +-- htdocs/core/class/conf.class.php | 6 ++++ htdocs/core/tpl/objectline_create.tpl.php | 6 ++-- htdocs/core/tpl/objectline_view.tpl.php | 3 +- htdocs/langs/en_US/admin.lang | 7 ++-- htdocs/langs/en_US/products.lang | 2 +- htdocs/product/admin/product.php | 44 ++++++++++++----------- htdocs/product/card.php | 7 ++-- 8 files changed, 47 insertions(+), 33 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index af00daa38e0..71f7f4d88cc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1003,8 +1003,9 @@ if (empty($reshook)) } else { $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 +var_dump($desc); +var_dump($product_desc);exit; + //If text set in desc is the same as product description (as now it's preloaded) whe add it only one time if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) { $product_desc=''; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3191e5edd47..1eb3b9911ba 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -697,6 +697,12 @@ class Conf if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel' + if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) { + $this->global->MAIN_NO_CONCAT_DESCRIPTION = 1; + } else { + unset($this->global->MAIN_NO_CONCAT_DESCRIPTION); + } + // For backward compatibility if (isset($this->product)) $this->produit = $this->product; if (isset($this->facture)) $this->invoice = $this->facture; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index baf5881ce2e..58d4627bf87 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -677,7 +677,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) console.log("Load unit price end, we got value "+data.price_ht); jQuery("#price_ht").val(data.price_ht); global->PRODUIT_AUTOFILL_DESC)) { + if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?> var proddesc = data.desc_trans; rights->margins->creer) } global->PRODUIT_AUTOFILL_DESC)) { + if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { ?> var description = $('option:selected', this).attr('data-description'); if (typeof description == 'undefined') { description = jQuery('#idprodfournprice').attr('data-description'); } @@ -898,7 +898,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) }?> } else if (jQuery('#idprodfournprice').length > 0) { global->PRODUIT_AUTOFILL_DESC)) { + if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?> if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") { diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index cba0b0b3e53..e6f41eaa8a5 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -119,8 +119,7 @@ if (($line->info_bits & 2) == 2) { } else { $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE ? 'dayhour' : 'day'; - if ($line->fk_product > 0) - { + if ($line->fk_product > 0) { print $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); } else { $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f759da42f3b..cf35c4c0f83 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1599,9 +1599,12 @@ 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 +OnProductSelectAddProductDesc=How to use the description of the products when adding a product as a line of a document +AutoFillFormFieldBeforeSubmit=Auto fill the description input field with the description of product +DoNotAutofillButAutoConcat=Do not autofill the input field with description of product. Description of the product will be concatenated to the entered description automatically. +DoNotUseDescriptionOfProdut=Description of the product will never be included into the description of lines of documents 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 +ViewProductDescInThirdpartyLanguageAbility=Display products descriptions in forms in the language of the third party (otherwise in the language of the user) 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. UseSearchToSelectProduct=Wait until you press a key before loading content of product combo list (This may increase performance if you have a large number of products, but it is less convenient) SetDefaultBarcodeTypeProducts=Default barcode type to use for products diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index f0c4a5362b8..9ecc11ed93d 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -108,7 +108,7 @@ FillWithLastServiceDates=Fill with last service line dates MultiPricesAbility=Multiple price segments per product/service (each customer is in one price segment) MultiPricesNumPrices=Number of prices DefaultPriceType=Base of prices per default (with versus without tax) when adding new sale prices -AssociatedProductsAbility=Enable Kits (set of other products) +AssociatedProductsAbility=Enable Kits (set of several products) VariantsAbility=Enable Variants (variations of products, for example color, size) AssociatedProducts=Kits AssociatedProductsNumber=Number of products composing this kit diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 5eabeb3ddfd..25c5c8b1142 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -148,9 +148,6 @@ if ($action == 'other') $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); @@ -583,7 +580,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES)) $current_rule = 'PRODUIT_MULTIPR if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY'; if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES'; if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $current_rule = 'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'; -print $form->selectarray("princingrule", $select_pricing_rules, $current_rule); +print $form->selectarray("princingrule", $select_pricing_rules, $current_rule, 0, 0, 0, '', 1, 0, 0, '', 'maxwidth400', 1); print ''; print ''; @@ -635,6 +632,28 @@ if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print ''; } +// Do Not Add Product description on add lines +print ''; +print ''.$langs->trans("OnProductSelectAddProductDesc").''; +print ''; +print $form->selectarray( + "activate_FillProductDescAuto", + array(1=>'AutoFillFormFieldBeforeSubmit', 0=>'DoNotAutofillButAutoConcat', -1=>'DoNotUseDescriptionOfProdut'), + empty($conf->global->PRODUIT_AUTOFILL_DESC) ? 0 : $conf->global->PRODUIT_AUTOFILL_DESC, + 0, + 0, + 0, + '', + 1, + 0, + 0, + '', + 'maxwidth400', + 1 +); +print ''; +print ''; + // Visualiser description produit dans les formulaires activation/desactivation print ''; print ''.$langs->trans("ViewProductDescInFormAbility").''; @@ -643,23 +662,6 @@ 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/card.php b/htdocs/product/card.php index b351b9ec7e1..b2997d948ac 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -413,7 +413,10 @@ if (empty($reshook)) $object->ref = $ref; $object->label = GETPOST('label', $label_security_check); - $object->description = dol_htmlcleanlastbr(GETPOST('desc', 'restricthtml')); + + $desc = dol_htmlcleanlastbr(preg_replace('/ $/', '', GETPOST('desc', 'restricthtml'))); + $object->description = $desc; + $object->url = GETPOST('url'); if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { @@ -426,8 +429,8 @@ if (empty($reshook)) $object->status = GETPOST('statut', 'int'); $object->status_buy = GETPOST('statut_buy', 'int'); $object->status_batch = GETPOST('status_batch', 'aZ09'); - // removed from update view so GETPOST always empty $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); + // removed from update view so GETPOST always empty /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $object->desiredstock = GETPOST('desiredstock');