tested and approuve feaure #15036

This commit is contained in:
Florian HENRY 2020-10-28 16:37:41 +01:00
parent a3073be8e4
commit d77a0b40a8
10 changed files with 98 additions and 28 deletions

View File

@ -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='';
}

View File

@ -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='';
}

View File

@ -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='';
}

View File

@ -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='';
}

View File

@ -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);
<?php if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?>
<?php
if (!empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?>
var proddesc = data.desc_trans;
<?php } else { ?>
<?php
} else { ?>
var proddesc = data.desc;
<?php } ?>
<?php
} ?>
console.log("Load desciption into text area : "+proddesc);
<?php if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
<?php
if (!empty($conf->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);
}
}
<?php } else { ?>
<?php
} else { ?>
jQuery('#dp_desc').text(proddesc);
<?php } ?>
<?php
} ?>
<?php
} ?>
},
'json'
);
@ -834,7 +843,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
{
jQuery("#remise_percent").val(pbqpercent);
}
}
} else { jQuery("#pbq").val(''); }
<?php
}
?>
@ -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);
}
<?php
if (!empty($conf->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);
<?php if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS)) { ?>
<?php
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(description);
editor.setData(description);
}
}
<?php } else { ?>
<?php
} else { ?>
jQuery('#dp_desc').text(description);
<?php } ?>
}
else
{
jQuery("#pbq").val('');
<?php
}
}?>
} else if (jQuery('#idprodfournprice').length > 0) {
<?php
if (!empty($conf->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('');
}
}
<?php
} else { ?>
jQuery('#dp_desc').text('');
<?php
}
}?>
}
/* To set focus */
if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0)
{

View File

@ -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 != '') {

View File

@ -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 != '') {

View File

@ -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)
CountryIfSpecificToOneCountry=Country (if specific to a given country)

View File

@ -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 '</td>';
print '</tr>';
// Do Not Add Product description on add lines
print '<tr class="oddeven">';
print '<td>'.$langs->trans("DoNotAddProductDescAtAddLines").'</td>';
print '<td class="right">';
print $form->selectyesno("activate_DoNotAddStdProductDescOnAddLine", $conf->global->MAIN_NO_CONCAT_DESCRIPTION, 1);
print '</td>';
print '</tr>';
// Do Not Add Product description on add lines
print '<tr class="oddeven">';
print '<td>'.$langs->trans("OnProductSelectAddProductDesc").'</td>';
print '<td class="right">';
print $form->selectyesno("activate_FillProductDescAuto", $conf->global->PRODUIT_AUTOFILL_DESC, 1);
print '</td>';
print '</tr>';
// 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.

View File

@ -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;
}
}
}