From c71d578931ed9126937fdcb3dda0e8e5a332f0c8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 16 Dec 2015 16:39:50 +0100 Subject: [PATCH 1/3] Fix: for avoid division by 0 --- htdocs/core/tpl/objectline_create.tpl.php | 19 ++++++++++--------- htdocs/core/tpl/objectline_edit.tpl.php | 17 ++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) 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; } From 905f9d78edbfe2089ed48dbbc17769ae06f6bb79 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Jan 2016 13:12:19 +0100 Subject: [PATCH 2/3] Fix: $outputlangs is not defined (dolibarr 3.7, 3.8, 3.9) --- htdocs/fourn/commande/card.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 20abbdf8378..0ce61f0eb51 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2006 Rodolphe Quiedeville * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2011 Philippe Grand * Copyright (C) 2012 Marcos GarcĂ­a @@ -121,7 +121,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) { - + $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); if ($result < 0) dol_print_error($db, $object->error); else $object->ref_supplier=GETPOST('ref_supplier','alpha'); // ADD : ref_supplier to object property, otherwise not visibly updated on change @@ -615,6 +615,14 @@ if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournis if ($result > 0) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); From 6aeb18ed7532aa534a3fc261145fd29f928238e6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 15 Jan 2016 13:14:55 +0100 Subject: [PATCH 3/3] Revert "Fix: for avoid division by 0" This reverts commit c71d578931ed9126937fdcb3dda0e8e5a332f0c8. --- htdocs/core/tpl/objectline_create.tpl.php | 19 +++++++++---------- htdocs/core/tpl/objectline_edit.tpl.php | 17 +++++++---------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d2827cb0b8e..e600df26147 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -352,36 +352,35 @@ if (! empty($usemargins) && $user->rights->margins->creer) if (! $.isNumeric(rate.val().replace(',','.'))) { - alert('transnoentities("rateMustBeNumeric")); ?>'); + alert('trans("rateMustBeNumeric")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('transnoentities("markRateShouldBeLesserThan100")); ?>'); + alert('trans("markRateShouldBeLesserThan100")); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } + var price = 0; remisejs=price2numjs(remise.val()); - if (remisejs == '') remisejs=0; - bpjs=price2numjs(buying_price.val()); - - if (bpjs > 0 && remisejs != 100) // If buying_price and a discount not 100 or no discount + if (remisejs != 100) // If a discount not 100 or no discount { - var price = 0; + if (remisejs == '') remisejs=0; + + bpjs=price2numjs(buying_price.val()); 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 eacba3519af..bb75b007524 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Florian Henry @@ -282,27 +282,25 @@ if (! empty($conf->margin->enabled)) if (! $.isNumeric(rate.val().replace(',','.'))) { - alert('transnoentities("rateMustBeNumeric"); ?>'); + alert('trans("rateMustBeNumeric"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } if (npRate == "np_markRate" && rate.val() >= 100) { - alert('transnoentities("markRateShouldBeLesserThan100"); ?>'); + alert('trans("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); setTimeout(function () { rate.focus() }, 50); return false; } + var price = 0; remisejs=price2numjs(remise.val()); - if (remisejs == '') remisejs=0; - bpjs=price2numjs(buying_price.val()); - - if (bpjs > 0 && remisejs != 100) // If buying_price and a discount not 100 or no discount + if (remisejs != 100) { - var price = 0; + bpjs=price2numjs(buying_price.val()); ratejs=price2numjs(rate.val()); /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ @@ -311,9 +309,8 @@ 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; }