FIX #12875
This commit is contained in:
parent
08841d4475
commit
d13e5bc90b
@ -670,6 +670,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
$(data).each(function() {
|
$(data).each(function() {
|
||||||
|
/* Warning: Lines must be processed in order: best supplier price, then pmpprice line then costprice */
|
||||||
if (this.id != 'pmpprice' && this.id != 'costprice')
|
if (this.id != 'pmpprice' && this.id != 'costprice')
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@ -681,7 +682,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
if (this.id == 'pmpprice')
|
if (this.id == 'pmpprice')
|
||||||
{
|
{
|
||||||
// If margin is calculated on PMP, we set it by defaut (but only if value is not 0)
|
// If margin is calculated on PMP, we set it by defaut (but only if value is not 0)
|
||||||
//console.log("id="+this.id+"-price="+this.price);
|
console.log("id="+this.id+"-price="+this.price);
|
||||||
if ('pmp' == defaultbuyprice || 'costprice' == defaultbuyprice)
|
if ('pmp' == defaultbuyprice || 'costprice' == defaultbuyprice)
|
||||||
{
|
{
|
||||||
if (this.price > 0) {
|
if (this.price > 0) {
|
||||||
@ -693,11 +694,11 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
|||||||
if (this.id == 'costprice')
|
if (this.id == 'costprice')
|
||||||
{
|
{
|
||||||
// If margin is calculated on Cost price, we set it by defaut (but only if value is not 0)
|
// If margin is calculated on Cost price, we set it by defaut (but only if value is not 0)
|
||||||
//console.log("id="+this.id+"-price="+this.price+"-pmppricevalue="+pmppricevalue);
|
console.log("id="+this.id+"-price="+this.price+"-pmppricevalue="+pmppricevalue);
|
||||||
if ('costprice' == defaultbuyprice)
|
if ('costprice' == defaultbuyprice)
|
||||||
{
|
{
|
||||||
if (this.price > 0) { defaultkey = this.id; defaultprice = this.price; costpriceid = this.id; costpricevalue = this.price; }
|
if (this.price > 0) { defaultkey = this.id; defaultprice = this.price; costpriceid = this.id; costpricevalue = this.price; }
|
||||||
else if (pmppricevalue > 0) { defaultkey = pmppriceid; defaultprice = pmppricevalue; }
|
else if (pmppricevalue > 0) { defaultkey = 'pmpprice'; defaultprice = pmppricevalue; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
|
options += '<option value="'+this.id+'" price="'+this.price+'">'+this.label+'</option>';
|
||||||
|
|||||||
@ -84,16 +84,17 @@ if ($idprod > 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add price for costprice
|
// After best supplier prices and before costprice
|
||||||
$price=$producttmp->cost_price;
|
|
||||||
$prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
|
|
||||||
|
|
||||||
if(!empty($conf->stock->enabled))
|
if(!empty($conf->stock->enabled))
|
||||||
{
|
{
|
||||||
// Add price for pmp
|
// Add price for pmp
|
||||||
$price=$producttmp->pmp;
|
$price=$producttmp->pmp;
|
||||||
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
|
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add price for costprice (at end)
|
||||||
|
$price=$producttmp->cost_price;
|
||||||
|
$prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($prices);
|
echo json_encode($prices);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user