Skip to content

Commit

Permalink
tested and approuve feaure Dolibarr#15036
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Oct 28, 2020
1 parent a3073be commit d77a0b4
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 28 deletions.
4 changes: 2 additions & 2 deletions htdocs/comm/propal/card.php
Expand Up @@ -793,7 +793,7 @@
} 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');
Expand Down Expand Up @@ -1001,7 +1001,7 @@
}

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

Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/card.php
Expand Up @@ -640,7 +640,7 @@

// 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');
Expand Down Expand Up @@ -855,7 +855,7 @@
}

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

Expand Down
4 changes: 2 additions & 2 deletions htdocs/compta/facture/card.php
Expand Up @@ -1902,7 +1902,7 @@

// 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');
Expand Down Expand Up @@ -2073,7 +2073,7 @@
}

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

Expand Down
4 changes: 2 additions & 2 deletions htdocs/contrat/card.php
Expand Up @@ -383,7 +383,7 @@
{
// 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')
Expand Down Expand Up @@ -501,7 +501,7 @@
$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='';
}

Expand Down
65 changes: 48 additions & 17 deletions htdocs/core/tpl/objectline_create.tpl.php
Expand Up @@ -674,23 +674,32 @@ function checkFreeLine(e, npRate)
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'];
if (editor) {
editor.setData(proddesc);
}
}
<?php } else { ?>
<?php
} else { ?>
jQuery('#dp_desc').text(proddesc);
<?php } ?>
<?php
} ?>
<?php
} ?>
},
'json'
);
Expand Down Expand Up @@ -834,7 +843,7 @@ function(data) {
{
jQuery("#remise_percent").val(pbqpercent);
}
}
} else { jQuery("#pbq").val(''); }
<?php
}
?>
Expand All @@ -850,8 +859,6 @@ function(data) {
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);
Expand All @@ -864,24 +871,48 @@ function(data) {
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)
{
Expand Down
8 changes: 7 additions & 1 deletion htdocs/fourn/commande/card.php
Expand Up @@ -484,7 +484,13 @@
$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 != '') {
Expand Down
7 changes: 6 additions & 1 deletion htdocs/fourn/facture/card.php
Expand Up @@ -1294,7 +1294,12 @@
$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 != '') {
Expand Down
4 changes: 3 additions & 1 deletion htdocs/langs/en_US/admin.lang
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
23 changes: 23 additions & 0 deletions htdocs/product/admin/product.php
Expand Up @@ -145,6 +145,12 @@
$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);
Expand Down Expand Up @@ -630,6 +636,23 @@
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.
Expand Down
3 changes: 3 additions & 0 deletions htdocs/product/ajax/products.php
Expand Up @@ -99,6 +99,9 @@
$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;
}
}
}
Expand Down

0 comments on commit d77a0b4

Please sign in to comment.