NEW: preload product description on selection for customer propal/order/invoice
This commit is contained in:
parent
6c1f60f6c0
commit
7c2b5b614f
@ -995,11 +995,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) {
|
||||
$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));
|
||||
|
||||
|
||||
@ -854,6 +854,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) {
|
||||
$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));
|
||||
|
||||
|
||||
@ -2068,6 +2068,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) {
|
||||
$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) {
|
||||
$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));
|
||||
|
||||
|
||||
@ -514,13 +514,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
|
||||
}
|
||||
@ -535,21 +535,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;
|
||||
@ -659,7 +659,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)
|
||||
{
|
||||
@ -675,6 +674,23 @@ 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)) { ?>
|
||||
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 } ?>
|
||||
},
|
||||
'json'
|
||||
);
|
||||
|
||||
@ -1294,6 +1294,11 @@ if (empty($reshook))
|
||||
$desc = $productsupplier->desc_supplier;
|
||||
} else $desc = $productsupplier->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) {
|
||||
$product_desc='';
|
||||
}
|
||||
|
||||
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
|
||||
|
||||
$type = $productsupplier->type;
|
||||
|
||||
@ -71,7 +71,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;
|
||||
@ -79,10 +81,25 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
|
||||
$found = false;
|
||||
|
||||
$price_level = 1;
|
||||
if ($socid > 0 && !empty($conf->global->PRODUIT_MULTIPRICES)) {
|
||||
|
||||
if ($socid > 0) {
|
||||
$thirdpartytemp = new Societe($db);
|
||||
$thirdpartytemp->fetch($socid);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
|
||||
$price_level = $thirdpartytemp->price_level;
|
||||
}
|
||||
}
|
||||
|
||||
// Price by qty
|
||||
@ -158,7 +175,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