diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index e600df26147..d2827cb0b8e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2015 Regis Houssin * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -352,35 +352,36 @@ if (! empty($usemargins) && $user->rights->margins->creer) if (! $.isNumeric(rate.val().replace(',','.'))) { - alert('trans("rateMustBeNumeric")); ?>'); + alert('transnoentities("rateMustBeNumeric")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('trans("markRateShouldBeLesserThan100")); ?>'); + alert('transnoentities("markRateShouldBeLesserThan100")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } - var price = 0; remisejs=price2numjs(remise.val()); + if (remisejs == '') remisejs=0; - if (remisejs != 100) // If a discount not 100 or no discount + bpjs=price2numjs(buying_price.val()); + + if (bpjs > 0 && remisejs != 100) // If buying_price and a discount not 100 or no discount { - if (remisejs == '') remisejs=0; - - bpjs=price2numjs(buying_price.val()); + var price = 0; ratejs=price2numjs(rate.val()); if (npRate == "np_marginRate") price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value } - $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index bb75b007524..eacba3519af 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2015 Regis Houssin * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -282,25 +282,27 @@ if (! empty($conf->margin->enabled)) if (! $.isNumeric(rate.val().replace(',','.'))) { - alert('trans("rateMustBeNumeric"); ?>'); + alert('transnoentities("rateMustBeNumeric"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('trans("markRateShouldBeLesserThan100"); ?>'); + alert('transnoentities("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } - var price = 0; remisejs=price2numjs(remise.val()); + if (remisejs == '') remisejs=0; - if (remisejs != 100) + bpjs=price2numjs(buying_price.val()); + + if (bpjs > 0 && remisejs != 100) // If buying_price and a discount not 100 or no discount { - bpjs=price2numjs(buying_price.val()); + var price = 0; ratejs=price2numjs(rate.val()); /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ @@ -309,8 +311,9 @@ if (! empty($conf->margin->enabled)) price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); else if (npRate == "np_markRate") price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + + $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value } - $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true; }