diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 605b03d9c72..a9140c46dd0 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -23,7 +23,7 @@ * $object (invoice, order, ...) * $conf * $langs - * $seller, $nuyer + * $seller, $buyer * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) * $senderissupplier (0 by default, 1 for supplier invoices/orders) @@ -259,6 +259,7 @@ if (! empty($conf->margin->enabled)) /* Init field buying_price and fournprice */ $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { + console.log(data); if (data && data.length > 0) { var options = ''; var trouve=false; @@ -302,9 +303,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_marginRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_marginRate']:first").blur(function(e) { return checkEditLine(e, "np_marginRate"); - }); + });*/ global->DISPLAY_MARK_RATES)) @@ -313,9 +315,10 @@ if (! empty($conf->margin->enabled)) $('#savelinebutton').click(function (e) { return checkEditLine(e, "np_markRate"); }); + /* Disabled. We must be able to click on button 'cancel'. Check must be done only on button 'save'. $("input[name='np_markRate']:first").blur(function(e) { return checkEditLine(e, "np_markRate"); - }); + });*/ @@ -323,7 +326,7 @@ if (! empty($conf->margin->enabled)) /* If margin rate field empty, do nothing. */ - /* Force content of price_ht to 0 or if a discount is set recalculate it from margin rate */ + /* Force content of price_ht to 0 or if a discount is set, recalculate it from margin rate */ function checkEditLine(e, npRate) { var buying_price = $("input[name='buying_price']:first"); @@ -332,16 +335,16 @@ if (! empty($conf->margin->enabled)) var rate = $("input[name='"+npRate+"']:first"); if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true; - if (! $.isNumeric(rate.val().replace(',','.'))) + if (! $.isNumeric(rate.val().replace(' ','').replace(',','.'))) { - alert('trans("rateMustBeNumeric"); ?>'); + alert('transnoentitiesnoconv("rateMustBeNumeric"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('trans("markRateShouldBeLesserThan100"); ?>'); + alert('transnoentitiesnoconv("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; @@ -354,14 +357,20 @@ if (! empty($conf->margin->enabled)) { bpjs=price2numjs(buying_price.val()); ratejs=price2numjs(rate.val()); - /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ if (npRate == "np_marginRate") - price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100)); + price = ((bpjs * (1 + (ratejs / 100))) / (1 - remisejs / 100)); else if (npRate == "np_markRate") - price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100)); + { + if (ratejs != 100) + { + price = ((bpjs / (1 - (ratejs / 100))) / (1 - remisejs / 100)); + } + else price=$("input[name='price_ht']:first").val(); + } } + /* console.log("new price ht = "+price); */ $("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value return true;