';
$coldisplay++;
}
if (! empty($conf->global->DISPLAY_MARK_RATES))
{
- echo '
%
';
+ echo '
%
';
$coldisplay++;
}
}
@@ -246,7 +246,7 @@ else {
table_element_line=='commandedet') {
$newline = new OrderLine($this->db);
@@ -344,6 +344,7 @@ if (! empty($usemargins) && $user->rights->margins->creer)
var rate = $("input[name='"+npRate+"']:first");
if (rate.val() == '')
return true;
+
if (! $.isNumeric(rate.val().replace(',','.')))
{
alert('trans("rateMustBeNumeric")); ?>');
@@ -362,14 +363,16 @@ if (! empty($usemargins) && $user->rights->margins->creer)
var price = 0;
remisejs=price2numjs(remise.val());
- if (remisejs != 100)
+ if (remisejs != 100) // If a discount not 100 or no discount
{
+ if (remisejs == '') remisejs=0;
+
bpjs=price2numjs(buying_price.val());
ratejs=price2numjs(rate.val());
- if (npRate == "marginRate")
+ if (npRate == "np_marginRate")
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
- else if (npRate == "markRate")
+ 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
@@ -381,6 +384,8 @@ if (! empty($usemargins) && $user->rights->margins->creer)
/* Function similar to price2num in PHP */
function price2numjs(num)
{
+ if (num == '') return '';
+
transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
@@ -497,6 +502,10 @@ function setforfree() {
jQuery("#title_vat").show();
jQuery("#title_up_ht").show();
jQuery("#title_up_ttc").show();
+ jQuery("#np_marginRate").show(); // May no exists
+ jQuery("#np_markRate").show(); // May no exists
+ jQuery(".np_marginRate").show(); // May no exists
+ jQuery(".np_markRate").show(); // May no exists
}
function setforpredef() {
jQuery("#select_type").val(-1);
@@ -509,6 +518,10 @@ function setforpredef() {
jQuery("#title_vat").hide();
jQuery("#title_up_ht").hide();
jQuery("#title_up_ttc").hide();
+ jQuery("#np_marginRate").hide(); // May no exists
+ jQuery("#np_markRate").hide(); // May no exists
+ jQuery(".np_marginRate").hide(); // May no exists
+ jQuery(".np_markRate").hide(); // May no exists
}