Merge pull request #15153 from FHenry/dev_new_add_desc_when_select_product
NEW: preload product description on selection for customer propal/order/invoice
This commit is contained in:
commit
26fa8b45ac
@ -796,7 +796,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');
|
||||
@ -999,11 +999,16 @@ if (empty($reshook))
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
|
||||
$desc = (!empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
|
||||
} 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
|
||||
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;
|
||||
else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||
|
||||
|
||||
@ -846,6 +846,11 @@ 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 && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
|
||||
$product_desc='';
|
||||
}
|
||||
|
||||
if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc;
|
||||
else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||
|
||||
|
||||
@ -1894,7 +1894,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');
|
||||
@ -2064,6 +2064,11 @@ 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 && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
|
||||
$product_desc='';
|
||||
}
|
||||
|
||||
if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc;
|
||||
else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||
|
||||
|
||||
@ -499,6 +499,12 @@ 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 && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
|
||||
$product_desc='';
|
||||
}
|
||||
|
||||
if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) $desc = $product_desc;
|
||||
else $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||
|
||||
|
||||
@ -2182,7 +2182,9 @@ class Form
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
$sql .= ", pl.label as label_translated";
|
||||
$sql .= ", pl.description as description_translated";
|
||||
$selectFields .= ", label_translated";
|
||||
$selectFields .= ", description_translated";
|
||||
}
|
||||
// Price by quantity
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
|
||||
@ -2222,7 +2224,18 @@ class Form
|
||||
// Multilang : we add translation
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='".$this->db->escape($langs->getDefaultLang())."'";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid ";
|
||||
if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) {
|
||||
$soc = new Societe($db);
|
||||
$result = $soc->fetch($socid);
|
||||
if ($result > 0 && !empty($soc->default_lang)) {
|
||||
$sql .= " AND pl.lang='" . $this->db->escape($soc->default_lang) . "'";
|
||||
} else {
|
||||
$sql .= " AND pl.lang='".$this->db->escape($langs->getDefaultLang())."'";
|
||||
}
|
||||
} else {
|
||||
$sql .= " AND pl.lang='".$this->db->escape($langs->getDefaultLang())."'";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
|
||||
@ -2435,7 +2448,9 @@ class Form
|
||||
$outval = '';
|
||||
$outref = '';
|
||||
$outlabel = '';
|
||||
$outlabel_translated = '';
|
||||
$outdesc = '';
|
||||
$outdesc_translated = '';
|
||||
$outbarcode = '';
|
||||
$outorigin = '';
|
||||
$outtype = '';
|
||||
@ -2456,6 +2471,11 @@ class Form
|
||||
$outref = $objp->ref;
|
||||
$outlabel = $objp->label;
|
||||
$outdesc = $objp->description;
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
$outlabel_translated = $objp->label_translated;
|
||||
$outdesc_translated = $objp->description_translated;
|
||||
}
|
||||
$outbarcode = $objp->barcode;
|
||||
$outorigin = $objp->fk_country;
|
||||
$outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid;
|
||||
@ -2517,6 +2537,10 @@ class Form
|
||||
elseif ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"';
|
||||
}
|
||||
}
|
||||
if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$opt .= ' data-labeltrans="'.$outlabel_translated.'"';
|
||||
$opt .= ' data-desctrans="'.dol_escape_htmltag($outdesc_translated).'"';
|
||||
}
|
||||
$opt .= '>';
|
||||
$opt .= $objp->ref;
|
||||
if ($outbarcode) $opt .= ' ('.$outbarcode.')';
|
||||
@ -2687,7 +2711,24 @@ class Form
|
||||
}
|
||||
|
||||
$opt .= "</option>\n";
|
||||
$optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>price2num($outprice_ht), 'price_ttc'=>price2num($outprice_ttc), 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'pbq'=>$outpbq);
|
||||
$optJson = array(
|
||||
'key'=>$outkey,
|
||||
'value'=>$outref,
|
||||
'label'=>$outval,
|
||||
'label2'=>$outlabel,
|
||||
'desc'=>$outdesc,
|
||||
'type'=>$outtype,
|
||||
'price_ht'=>price2num($outprice_ht),
|
||||
'price_ttc'=>price2num($outprice_ttc),
|
||||
'pricebasetype'=>$outpricebasetype,
|
||||
'tva_tx'=>$outtva_tx, 'qty'=>$outqty,
|
||||
'discount'=>$outdiscount,
|
||||
'duration_value'=>$outdurationvalue,
|
||||
'duration_unit'=>$outdurationunit,
|
||||
'pbq'=>$outpbq,
|
||||
'labeltrans'=>$outlabel_translated,
|
||||
'desctrans'=>$outdesc_translated
|
||||
);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
@ -2770,6 +2811,12 @@ class Form
|
||||
$sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
|
||||
$sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
|
||||
$sql .= " pfp.supplier_reputation";
|
||||
// if we use supplier description of the products
|
||||
if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||
$sql .= " ,pfp.desc_fourn as description";
|
||||
} else {
|
||||
$sql .= " ,p.description";
|
||||
}
|
||||
// Units
|
||||
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
|
||||
$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
|
||||
@ -2799,7 +2846,11 @@ class Form
|
||||
foreach ($scrit as $crit)
|
||||
{
|
||||
if ($i > 0) $sql .= " AND ";
|
||||
$sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')";
|
||||
$sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||
if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
|
||||
$sql .= " OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit)."%'";
|
||||
}
|
||||
$sql .= ")";
|
||||
$i++;
|
||||
}
|
||||
if (count($scrit) > 1) $sql .= ")";
|
||||
@ -3028,8 +3079,9 @@ class Form
|
||||
if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
|
||||
if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
|
||||
{
|
||||
$opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"';
|
||||
$opt .= ' data-qty="'.$objp->quantity.'" data-up="'.$objp->unitprice.'" data-discount="'.$outdiscount.'"';
|
||||
}
|
||||
$opt .= ' data-description="'.dol_escape_htmltag($objp->description).'"';
|
||||
$opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"';
|
||||
$opt .= '>';
|
||||
|
||||
@ -3043,7 +3095,20 @@ class Form
|
||||
// "key" value of json key array is used by jQuery automatically as selected value
|
||||
// "label" value of json key array is used by jQuery automatically as text for combo box
|
||||
$out .= $opt;
|
||||
array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'up'=>$objp->unitprice, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false)));
|
||||
array_push($outarray,
|
||||
array('key'=>$outkey,
|
||||
'value'=>$outref,
|
||||
'label'=>$outval,
|
||||
'qty'=>$outqty,
|
||||
'up'=>$objp->unitprice,
|
||||
'discount'=>$outdiscount,
|
||||
'type'=>$outtype,
|
||||
'duration_value'=>$outdurationvalue,
|
||||
'duration_unit'=>$outdurationunit,
|
||||
'disabled'=>(empty($objp->idprodfournprice) ?true:false),
|
||||
'description'=>$objp->description
|
||||
)
|
||||
);
|
||||
// Exemple of var_dump $outarray
|
||||
// array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp"
|
||||
// ["label"]=>string(76) "ppp (<strong>f</strong>ff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)"
|
||||
|
||||
@ -135,7 +135,11 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
||||
}
|
||||
return { label: label, value: item.value, id: item.key, disabled: item.disabled,
|
||||
update: update, textarea: textarea,
|
||||
pbq: item.pbq, type: item.type, qty: item.qty, discount: item.discount, pricebasetype: item.pricebasetype, price_ht: item.price_ht, price_ttc: item.price_ttc }
|
||||
pbq: item.pbq,
|
||||
type: item.type, qty: item.qty, discount: item.discount,
|
||||
pricebasetype: item.pricebasetype, price_ht: item.price_ht,
|
||||
price_ttc: item.price_ttc,
|
||||
up: item.up, description : item.description}
|
||||
}));
|
||||
}
|
||||
else console.error("Error: Ajax url '.$url.($urloption ? '?'.$urloption : '').' has returned an empty page. Should be an empty json array.");
|
||||
@ -148,13 +152,33 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
|
||||
console.log("Selected id = "+ui.item.id+" - If this value is null, it means you select a record with key that is null so selection is not effective");
|
||||
|
||||
//console.log(ui.item);
|
||||
$("#'.$htmlname.'").attr("data-pbq", ui.item.pbq);
|
||||
$("#'.$htmlname.'").attr("data-pbqup", ui.item.price_ht);
|
||||
$("#'.$htmlname.'").attr("data-pbqbase", ui.item.pricebasetype);
|
||||
$("#'.$htmlname.'").attr("data-pbqqty", ui.item.qty);
|
||||
$("#'.$htmlname.'").attr("data-pbqpercent", ui.item.discount);
|
||||
//For supplier price
|
||||
$("#'.$htmlname.'").attr("data-up", ui.item.up);
|
||||
$("#'.$htmlname.'").attr("data-discount", ui.item.discount);
|
||||
$("#'.$htmlname.'").attr("data-qty", ui.item.qty);
|
||||
$("#'.$htmlname.'").attr("data-description", ui.item.description);
|
||||
|
||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
||||
//For customer price
|
||||
';
|
||||
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
|
||||
$script .= '
|
||||
$("#' . $htmlname . '").attr("data-pbq", ui.item.pbq);
|
||||
$("#' . $htmlname . '").attr("data-pbqup", ui.item.price_ht);
|
||||
$("#' . $htmlname . '").attr("data-pbqbase", ui.item.pricebasetype);
|
||||
$("#' . $htmlname . '").attr("data-pbqqty", ui.item.qty);
|
||||
$("#' . $htmlname . '").attr("data-pbqpercent", ui.item.discount);
|
||||
';
|
||||
} else {
|
||||
$script .= '
|
||||
$("#' . $htmlname . '").attr("data-up", ui.item.price_ht);
|
||||
$("#' . $htmlname . '").attr("data-base", ui.item.pricebasetype);
|
||||
$("#' . $htmlname . '").attr("data-qty", ui.item.qty);
|
||||
$("#' . $htmlname . '").attr("data-discount", ui.item.discount);
|
||||
';
|
||||
}
|
||||
$script .= '
|
||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
|
||||
// Disable an element
|
||||
if (options.option_disabled) {
|
||||
console.log("Make action option_disabled on #"+options.option_disabled+" with disabled="+ui.item.disabled)
|
||||
|
||||
@ -516,13 +516,13 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
<?php
|
||||
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
|
||||
$("input[name='np_marginRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
return checkFreeLine(e, "np_marginRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
if (!empty($conf->global->DISPLAY_MARK_RATES)) { ?>
|
||||
$("input[name='np_markRate']:first").blur(function(e) {
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
return checkFreeLine(e, "np_markRate");
|
||||
});
|
||||
<?php
|
||||
}
|
||||
@ -537,21 +537,21 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
|
||||
var rate = $("input[name='"+npRate+"']:first");
|
||||
if (rate.val() == '')
|
||||
return true;
|
||||
return true;
|
||||
|
||||
if (! $.isNumeric(rate.val().replace(',','.')))
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
if (npRate == "np_markRate" && rate.val() >= 100)
|
||||
{
|
||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
alert('<?php echo dol_escape_js($langs->trans("markRateShouldBeLesserThan100")); ?>');
|
||||
e.stopPropagation();
|
||||
setTimeout(function () { rate.focus() }, 50);
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = 0;
|
||||
@ -604,39 +604,39 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
});
|
||||
|
||||
$("#prod_entry_mode_free").on( "click", function() {
|
||||
setforfree();
|
||||
setforfree();
|
||||
});
|
||||
$("#select_type").change(function()
|
||||
{
|
||||
setforfree();
|
||||
setforfree();
|
||||
if (jQuery('#select_type').val() >= 0)
|
||||
{
|
||||
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
|
||||
jQuery('#dp_desc').focus();
|
||||
/* focus if CKEDITOR */
|
||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||
{
|
||||
var editor = CKEDITOR.instances['dp_desc'];
|
||||
if (editor) { editor.focus(); }
|
||||
}
|
||||
jQuery('#dp_desc').focus();
|
||||
/* focus if CKEDITOR */
|
||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||
{
|
||||
var editor = CKEDITOR.instances['dp_desc'];
|
||||
if (editor) { editor.focus(); }
|
||||
}
|
||||
}
|
||||
console.log("Hide/show date according to product type");
|
||||
if (jQuery('#select_type').val() == '0')
|
||||
{
|
||||
jQuery('#trlinefordates').hide();
|
||||
jQuery('.divlinefordates').hide();
|
||||
jQuery('#trlinefordates').hide();
|
||||
jQuery('.divlinefordates').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#trlinefordates').show();
|
||||
jQuery('.divlinefordates').show();
|
||||
jQuery('#trlinefordates').show();
|
||||
jQuery('.divlinefordates').show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#prod_entry_mode_predef").on( "click", function() {
|
||||
console.log("click prod_entry_mode_predef");
|
||||
setforpredef();
|
||||
jQuery('#trlinefordates').show();
|
||||
console.log("click prod_entry_mode_predef");
|
||||
setforpredef();
|
||||
jQuery('#trlinefordates').show();
|
||||
});
|
||||
|
||||
<?php
|
||||
@ -661,7 +661,6 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
?>
|
||||
var pbq = parseInt($('option:selected', this).attr('data-pbq')); /* If product was selected with a HTML select */
|
||||
if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } /* If product was selected with a HTML input with autocomplete */
|
||||
//console.log(pbq);
|
||||
|
||||
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
|
||||
{
|
||||
@ -677,6 +676,32 @@ 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->PRODUIT_AUTOFILL_DESC)) {
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?>
|
||||
var proddesc = data.desc_trans;
|
||||
<?php
|
||||
} else { ?>
|
||||
var proddesc = data.desc;
|
||||
<?php
|
||||
} ?>
|
||||
console.log("Load desciption into text area : "+proddesc);
|
||||
<?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 { ?>
|
||||
jQuery('#dp_desc').text(proddesc);
|
||||
<?php
|
||||
} ?>
|
||||
<?php
|
||||
} ?>
|
||||
},
|
||||
'json'
|
||||
);
|
||||
@ -791,7 +816,10 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
}
|
||||
?>
|
||||
|
||||
/* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */
|
||||
<?php
|
||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
|
||||
{?>
|
||||
/* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */
|
||||
var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select
|
||||
if (isNaN(pbq)) { pbq = jQuery('#idprod').attr('data-pbq'); } // When select is done from HTML input with autocomplete
|
||||
var pbqup = parseFloat($('option:selected', this).attr('data-pbqup'));
|
||||
@ -803,7 +831,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent'));
|
||||
if (isNaN(pbqpercent)) { pbqpercent = jQuery('#idprod').attr('data-pbqpercent'); }
|
||||
|
||||
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
|
||||
if ((jQuery('#idprod').val() > 0) && ! isNaN(pbq) && pbq > 0)
|
||||
{
|
||||
var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */
|
||||
|
||||
@ -818,12 +846,76 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
{
|
||||
jQuery("#remise_percent").val(pbqpercent);
|
||||
}
|
||||
} else { jQuery("#pbq").val(''); }
|
||||
<?php
|
||||
}
|
||||
else
|
||||
?>
|
||||
//Deal with supplier
|
||||
if (jQuery('#idprodfournprice').val() >0)
|
||||
{
|
||||
jQuery("#pbq").val('');
|
||||
var up = parseFloat($('option:selected', this).attr('data-up')); // When select is done from HTML select
|
||||
if (isNaN(up)) { up = parseFloat(jQuery('#idprodfournprice').attr('data-up'));} // When select is done from HTML input with autocomplete
|
||||
|
||||
var qty = parseFloat($('option:selected', this).attr('data-qty'));
|
||||
if (isNaN(qty)) { qty = parseFloat(jQuery('#idprodfournprice').attr('data-qty'));}
|
||||
|
||||
var discount = parseFloat($('option:selected', this).attr('data-discount'));
|
||||
if (isNaN(discount)) { discount = parseFloat(jQuery('#idprodfournprice').attr('data-discount'));}
|
||||
|
||||
console.log("We find supplier price :"+up+" qty: "+qty+" discount: "+discount+" for product "+jQuery('#idprodfournprice').val());
|
||||
|
||||
jQuery("#price_ht").val(up);
|
||||
if (jQuery("#qty").val() < qty)
|
||||
{
|
||||
jQuery("#qty").val(qty);
|
||||
}
|
||||
if (jQuery("#remise_percent").val() < discount)
|
||||
{
|
||||
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)) { ?>
|
||||
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
|
||||
{
|
||||
var editor = CKEDITOR.instances['dp_desc'];
|
||||
if (editor) {
|
||||
editor.setData(description);
|
||||
}
|
||||
}
|
||||
<?php
|
||||
} else { ?>
|
||||
jQuery('#dp_desc').text(description);
|
||||
<?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)
|
||||
{
|
||||
|
||||
@ -475,7 +475,7 @@ if (empty($reshook))
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$desc = (!empty($productsupplier->multilangs [$outputlangs->defaultlang] ["description"])) ? $productsupplier->multilangs [$outputlangs->defaultlang] ["description"] : $productsupplier->description;
|
||||
$desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang]["description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang]["description"] : $productsupplier->description;
|
||||
} else {
|
||||
$desc = $productsupplier->description;
|
||||
}
|
||||
@ -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 != '') {
|
||||
|
||||
@ -1289,7 +1289,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 != '') {
|
||||
|
||||
@ -1598,6 +1598,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.
|
||||
|
||||
@ -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);
|
||||
@ -637,6 +643,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.
|
||||
|
||||
|
||||
@ -72,7 +72,9 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
{
|
||||
$outref = $object->ref;
|
||||
$outlabel = $object->label;
|
||||
$outlabel_trans ='';
|
||||
$outdesc = $object->description;
|
||||
$outdesc_trans ='';
|
||||
$outtype = $object->type;
|
||||
$outqty = 1;
|
||||
$outdiscount = 0;
|
||||
@ -83,7 +85,25 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
if ($socid > 0 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
|
||||
$thirdpartytemp = new Societe($db);
|
||||
$thirdpartytemp->fetch($socid);
|
||||
$price_level = $thirdpartytemp->price_level;
|
||||
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
|
||||
$price_level = $thirdpartytemp->price_level;
|
||||
}
|
||||
|
||||
//Load translation description and label
|
||||
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||
$newlang = $thirdpartytemp->default_lang;
|
||||
|
||||
if (!empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Price by qty
|
||||
@ -159,7 +179,19 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
$outtva_tx = $object->tva_tx;
|
||||
}
|
||||
|
||||
$outjson = array('ref' => $outref, 'label' => $outlabel, 'desc' => $outdesc, 'type' => $outtype, 'price_ht' => $outprice_ht, 'price_ttc' => $outprice_ttc, 'pricebasetype' => $outpricebasetype, 'tva_tx' => $outtva_tx, 'qty' => $outqty, 'discount' => $outdiscount);
|
||||
$outjson = array(
|
||||
'ref' => $outref,
|
||||
'label' => $outlabel,
|
||||
'label_trans' => $outlabel_trans,
|
||||
'desc' => $outdesc,
|
||||
'desc_trans' => $outdesc_trans,
|
||||
'type' => $outtype,
|
||||
'price_ht' => $outprice_ht,
|
||||
'price_ttc' => $outprice_ttc,
|
||||
'pricebasetype' => $outpricebasetype,
|
||||
'tva_tx' => $outtva_tx,
|
||||
'qty' => $outqty,
|
||||
'discount' => $outdiscount);
|
||||
}
|
||||
|
||||
echo json_encode($outjson);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user