diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 8b5054afd7f..e823ec95cdc 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -354,8 +354,8 @@ if (empty($reshook))
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
- $object->remise_percent = GETPOST('remise_percent');
- $object->remise_absolue = GETPOST('remise_absolue');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
+ $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU');
$object->socid = GETPOST('socid', 'int');
$object->contact_id = GETPOST('contactid', 'int');
$object->fk_project = GETPOST('projectid', 'int');
@@ -812,7 +812,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = GETPOST('remise_percent'.$predef);
+ $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
if (empty($remise_percent)) $remise_percent = 0;
// Extrafields
@@ -1210,7 +1210,7 @@ if (empty($reshook))
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) {
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++;
}
@@ -1243,7 +1243,7 @@ if (empty($reshook))
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
- $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, $_POST["units"], $pu_ht_devise);
+ $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise);
if ($result >= 0) {
$db->commit();
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 287150e6ca2..1d2f12132e5 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -607,9 +607,9 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setremisepercent' && $usercancreate) {
- $result = $object->set_remise($user, GETPOST('remise_percent'));
+ $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2));
} elseif ($action == 'setremiseabsolue' && $usercancreate) {
- $result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
+ $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU'));
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
// Define vat_rate
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
@@ -640,7 +640,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha')) : 0);
+ $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -1032,7 +1032,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) {
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++;
}
@@ -1060,7 +1060,7 @@ if (empty($reshook))
}
}
}
- $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
+ $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, price2num(GETPOST('qty'), 'MS'), price2num(GETPOST('remise_percent'), 2), $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 35d70e1edd6..1a125a38147 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -451,7 +451,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = GETPOST('remise_percent'.$predef);
+ $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -801,7 +801,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))))
+ if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent', 2)) / 100) < price2num($price_min))))
{
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++;
@@ -837,7 +837,7 @@ if (empty($reshook))
$localtax1_rate,
$localtax1_rate,
GETPOST('productid'),
- GETPOST('remise_percent'),
+ price2num(GETPOST('remise_percent'), 2),
'HT',
$info_bits,
0,
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 16a472d878c..f4f1c5cde1a 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -476,19 +476,15 @@ if (empty($reshook))
}
}
} // Set incoterm
- elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
- {
+ elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) {
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
} // bank account
- elseif ($action == 'setbankaccount' && $usercancreate)
- {
+ elseif ($action == 'setbankaccount' && $usercancreate) {
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
- } elseif ($action == 'setremisepercent' && $usercancreate)
- {
+ } elseif ($action == 'setremisepercent' && $usercancreate) {
$object->fetch($id);
- $result = $object->set_remise($user, $_POST['remise_percent']);
- } elseif ($action == "setabsolutediscount" && $usercancreate)
- {
+ $result = $object->set_remise($user, price2num(GETPOST('remise_percent'), 2));
+ } elseif ($action == "setabsolutediscount" && $usercancreate) {
// POST[remise_id] or POST[remise_id_for_payment]
// We use the credit to reduce amount of invoice
@@ -981,7 +977,7 @@ if (empty($reshook))
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$action = 'create';
- } elseif ($dateinvoice > (dol_now() + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
+ } elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create';
@@ -993,26 +989,25 @@ if (empty($reshook))
$action = 'create';
}
- $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
+ $date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
if (!$error) {
// This is a replacement invoice
- $result = $object->fetch($_POST['fac_replacement']);
+ $result = $object->fetch(GETPOST('fac_replacement', 'int'));
$object->fetch_thirdparty();
$object->date = $dateinvoice;
$object->date_pointoftax = $date_pointoftax;
$object->note_public = trim(GETPOST('note_public', 'restricthtml'));
// We do not copy the private note
- $object->ref_client = $_POST['ref_client'];
- $object->ref_int = $_POST['ref_int'];
- $object->model_pdf = $_POST['model'];
- $object->fk_project = $_POST['projectid'];
- $object->cond_reglement_id = $_POST['cond_reglement_id'];
- $object->mode_reglement_id = $_POST['mode_reglement_id'];
+ $object->ref_client = GETPOST('ref_client', 'alphanohtml');
+ $object->model_pdf = GETPOST('model', 'alphanohtml');
+ $object->fk_project = GETPOST('projectid', 'int');
+ $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
+ $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
- $object->remise_absolue = $_POST['remise_absolue'];
- $object->remise_percent = $_POST['remise_percent'];
+ $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
@@ -1067,11 +1062,11 @@ if (empty($reshook))
$object->ref_client = GETPOST('ref_client');
$object->model_pdf = GETPOST('model');
$object->fk_project = GETPOST('projectid', 'int');
- $object->cond_reglement_id = 0;
- $object->mode_reglement_id = GETPOST('mode_reglement_id');
+ $object->cond_reglement_id = 0; // No payment term for a credit note
+ $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
- $object->remise_absolue = GETPOST('remise_absolue');
- $object->remise_percent = GETPOST('remise_percent');
+ $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
@@ -1289,8 +1284,8 @@ if (empty($reshook))
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->amount = price2num(GETPOST('amount'));
- $object->remise_absolue = GETPOST('remise_absolue');
- $object->remise_percent = GETPOST('remise_percent');
+ $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
@@ -1343,8 +1338,8 @@ if (empty($reshook))
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->amount = price2num(GETPOST('amount'));
- $object->remise_absolue = GETPOST('remise_absolue');
- $object->remise_percent = GETPOST('remise_percent');
+ $object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
@@ -1837,8 +1832,8 @@ if (empty($reshook))
$object->fk_project = GETPOST('projectid', 'int');
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
- $object->remise_absolue = GETPOST('remise_absolue', 'int');
- $object->remise_percent = GETPOST('remise_percent', 'int');
+ $object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
// Proprietes particulieres a facture de remplacement
@@ -1923,8 +1918,8 @@ if (empty($reshook))
$tva_tx = '';
}
- $qty = GETPOST('qty'.$predef);
- $remise_percent = GETPOST('remise_percent'.$predef);
+ $qty = price2num(GETPOST('qty'.$predef), 'MS');
+ $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -2314,7 +2309,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
- if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) {
+ if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent'), 2) / 100) < price2num($price_min)))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++;
}
@@ -2367,7 +2362,7 @@ if (empty($reshook))
}
}
- $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, price2num(GETPOST('remise_percent', 'alpha')),
+ $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, price2num(GETPOST('remise_percent'), 2),
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
GETPOST('fk_parent_line', 'int'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, price2num(GETPOST('progress', 'alpha')),
GETPOST('units', 'alpha'), $pu_ht_devise);
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index ca03905b834..8d78b410329 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -213,7 +213,7 @@ if (empty($reshook))
$object->note_private = GETPOST('note_private', 'alpha');
$object->note_public = GETPOST('note_public', 'alpha');
$object->fk_project = GETPOST('projectid', 'int');
- $object->remise_percent = GETPOST('remise_percent', 'alpha');
+ $object->remise_percent = price2num(GETPOST('remise_percent'), 2);
$object->ref = GETPOST('ref', 'alpha');
$object->ref_customer = GETPOST('ref_customer', 'alpha');
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
@@ -396,7 +396,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0);
+ $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0);
if ($qty == '')
{
@@ -673,10 +673,10 @@ if (empty($reshook))
$objectline->fk_product = GETPOST('idprod', 'int');
$objectline->description = GETPOST('product_desc', 'restricthtml');
- $objectline->price_ht = GETPOST('elprice');
- $objectline->subprice = GETPOST('elprice');
- $objectline->qty = GETPOST('elqty');
- $objectline->remise_percent = GETPOST('elremise_percent');
+ $objectline->price_ht = price2num(GETPOST('elprice'), 'MU');
+ $objectline->subprice = price2num(GETPOST('elprice'), 'MU');
+ $objectline->qty = price2num(GETPOST('elqty'), 'MS');
+ $objectline->remise_percent = price2num(GETPOST('elremise_percent'), 2);
$objectline->tva_tx = ($txtva ? $txtva : 0); // Field may be disabled, so we use vat rate 0
$objectline->vat_src_code = $vat_src_code;
$objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0;
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 74b091865ff..b632bf44110 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -514,9 +514,9 @@ function dol_get_last_day($year, $month = 12, $gm = false)
}
/**
- * Return GMT time for last hour of a given GMT date (it removes hours, min and second part)
+ * Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59)
*
- * @param int $date Date
+ * @param int $date Date GMT
* @return int Date for last hour of a given date
*/
function dol_get_last_hour($date)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 68941b92387..5e97eceaaea 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4830,13 +4830,13 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* should be roundtext2num().
*
* @param string|float $amount Amount to convert/clean or round
- * @param string $rounding ''=No rounding
+ * @param string|int $rounding ''=No rounding
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CU'=Round to Max unit price of foreign currency accuracy
* 'CT'=Round to Max for totals with Tax of foreign currency accuracy
- * Numeric = Nb of digits for rounding
+ * Numeric = Nb of digits for rounding (For example 2 for a percentage)
* @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done)
* Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator).
* @return string Amount with universal numeric format (Example: '99.99999').
@@ -4911,7 +4911,7 @@ function price2num($amount, $rounding = '', $option = 0)
elseif ($rounding == 'CT') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); // TODO Use param of currency
}
- elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
+ elseif (is_numeric($rounding)) $nbofdectoround = (int) $rounding;
//print "RR".$amount.' - '.$nbofdectoround.'
';
if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.
else return 'ErrorBadParameterProvidedToFunction';
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index c00e1d2d6e2..4238d0ee041 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -372,7 +372,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = GETPOST('remise_percent'.$predef);
+ $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
// Extrafields
@@ -721,21 +721,21 @@ if (empty($reshook))
$result = $object->updateline(
$lineid,
- $_POST['product_desc'],
+ GETPOST('product_desc', 'restricthtml'),
$ht,
- GETPOST('qty', 'int'),
- $_POST['remise_percent'],
+ price2num(GETPOST('qty'), 'MS'),
+ price2num(GETPOST('remise_percent'), 2),
$vat_rate,
$localtax1_rate,
$localtax2_rate,
$price_base_type,
0,
- isset($_POST["type"]) ? $_POST["type"] : $line->product_type,
+ GETPOSTISSET("type") ? GETPOST("type") : $line->product_type,
false,
$date_start,
$date_end,
$array_options,
- $_POST['units'],
+ GETPOST('units'),
$pu_ht_devise,
GETPOST('fourn_ref', 'alpha')
);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index bfac45b15ac..9b8d0d959f3 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1137,8 +1137,8 @@ if (empty($reshook))
$localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
- $remise_percent = GETPOST('remise_percent');
- $pu_ht_devise = GETPOST('multicurrency_subprice');
+ $remise_percent = price2num(GETPOST('remise_percent'), 2);
+ $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU');
// Extrafields Lines
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -1150,7 +1150,7 @@ if (empty($reshook))
}
}
- $result = $object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha'));
+ $result = $object->updateline(GETPOST('lineid', 'int'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, price2num(GETPOST('qty'), 'MS'), GETPOST('productid', 'int'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, GETPOST('units'), $pu_ht_devise, GETPOST('fourn_ref', 'alpha'));
if ($result >= 0)
{
unset($_POST['label']);
@@ -1206,7 +1206,7 @@ if (empty($reshook))
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
- $remise_percent = GETPOST('remise_percent'.$predef);
+ $remise_percent = price2num(GETPOST('remise_percent'.$predef), 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
// Extrafields
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index c6dfd68d2c4..55c29aa1381 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -743,7 +743,7 @@ if (empty($reshook))
if (GETPOST('propalid') > 0) {
// Define cost price for margin calculation
$buyprice = 0;
- if (($result = $propal->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0)
+ if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), 2), $object->id)) < 0)
{
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
@@ -754,12 +754,12 @@ if (empty($reshook))
$result = $propal->addline(
$desc,
$pu_ht,
- GETPOST('qty'),
+ price2num(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$object->id,
- GETPOST('remise_percent'),
+ price2num(GETPOST('remise_percent'), 2),
$price_base_type,
$pu_ttc,
0,
@@ -784,7 +784,7 @@ if (empty($reshook))
} elseif (GETPOST('commandeid') > 0) {
// Define cost price for margin calculation
$buyprice = 0;
- if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0)
+ if (($result = $commande->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0)
{
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
@@ -795,12 +795,12 @@ if (empty($reshook))
$result = $commande->addline(
$desc,
$pu_ht,
- GETPOST('qty'),
+ price2num(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx, // localtax1
$localtax2_tx, // localtax2
$object->id,
- GETPOST('remise_percent'),
+ price2num(GETPOST('remise_percent'), 2),
'',
'',
$price_base_type,
@@ -825,7 +825,7 @@ if (empty($reshook))
} elseif (GETPOST('factureid') > 0) {
// Define cost price for margin calculation
$buyprice = 0;
- if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent'), $object->id)) < 0)
+ if (($result = $facture->defineBuyPrice($pu_ht, GETPOST('remise_percent', 2), $object->id)) < 0)
{
dol_syslog($langs->trans('FailedToGetCostPrice'));
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
@@ -836,12 +836,12 @@ if (empty($reshook))
$result = $facture->addline(
$desc,
$pu_ht,
- GETPOST('qty'),
+ price2nm(GETPOST('qty'), 'MS'),
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$object->id,
- GETPOST('remise_percent'),
+ price2num(GETPOST('remise_percent'), 2),
'',
'',
'',
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 2aadd4b3813..88c5259f48d 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -160,7 +160,7 @@ if (empty($reshook))
if (empty($ref_fourn_old)) $ref_fourn_old = $ref_fourn;
$quantity = price2num(GETPOST("qty", 'nohtml'), 'MS');
$remise_percent = price2num(GETPOST('remise_percent', 'alpha'));
- $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0;
+ $npr = preg_match('/\*/', GETPOST('tva_tx', 'alpha')) ? 1 : 0;
$tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha'));
$tva_tx = price2num($tva_tx);
$price_expression = GETPOST('eid', 'int') ? GETPOST('eid', 'int') : ''; // Discard expression if not in expression mode
@@ -697,14 +697,14 @@ END;
print '