From 2e7f588cacd3731b037db4f3ff2a4bf6154312d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Sep 2020 19:34:20 +0200 Subject: [PATCH] FIX using decimal on stock correction Conflicts: htdocs/product/stock/product.php --- htdocs/product/stock/product.php | 77 +++++++++++++++++--------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 69f9dc89d9a..dcb87c9dcbc 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1,14 +1,14 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013-2018 Juanjo Menent - * Copyright (C) 2014-2015 Cédric Gross - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018-2019 Frédéric France +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2013-2018 Juanjo Menent + * Copyright (C) 2014-2015 Cédric Gross + * Copyright (C) 2015 Marcos García + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,8 +67,8 @@ $stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); $fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; -$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); -$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); +$d_eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); +$d_sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $pdluoid = GETPOST('pdluoid', 'int'); $batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { @@ -224,7 +224,8 @@ if ($action == "correct_stock" && !$cancel) if (!$error) { $priceunit = price2num(GETPOST("unitprice")); - if (is_numeric(GETPOST("nbpiece")) && $id) + $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); + if (is_numeric($nbpiece) && $nbpiece != 0 && $id) { $origin_element = ''; $origin_id = null; @@ -243,15 +244,15 @@ if ($action == "correct_stock" && !$cancel) { $result = $object->correct_stock_batch( $user, - GETPOST("id_entrepot"), - GETPOST("nbpiece"), - GETPOST("mouvement"), - GETPOST("label"), // label movement + GETPOST("id_entrepot", 'int'), + $nbpiece, + GETPOST("mouvement", 'int'), + GETPOST("label", 'alphanohtml'), // label movement $priceunit, $d_eatby, $d_sellby, $batchnumber, - GETPOST('inventorycode'), + GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -260,12 +261,12 @@ if ($action == "correct_stock" && !$cancel) { $result = $object->correct_stock( $user, - GETPOST("id_entrepot"), - GETPOST("nbpiece"), - GETPOST("mouvement"), - GETPOST("label"), + GETPOST("id_entrepot", 'int'), + $nbpiece, + GETPOST("mouvement", 'int'), + GETPOST("label", 'alphanohtml'), $priceunit, - GETPOST('inventorycode'), + GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -343,6 +344,8 @@ if ($action == "transfert_stock" && !$cancel) if (isset($object->pmp)) $pricesrc = $object->pmp; $pricedest = $pricesrc; + $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -377,12 +380,12 @@ if ($action == "transfert_stock" && !$cancel) $result1 = $object->correct_stock_batch( $user, $srcwarehouseid, - GETPOST("nbpiece", 'int'), + $nbpiece, 1, - GETPOST("label", 'san_alpha'), + GETPOST("label", 'alphanohtml'), $pricesrc, $eatby, $sellby, $batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result1 < 0) $error++; } @@ -392,12 +395,12 @@ if ($action == "transfert_stock" && !$cancel) $result2 = $object->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), - GETPOST("nbpiece", 'int'), + $nbpiece, 0, - GETPOST("label", 'san_alpha'), + GETPOST("label", 'alphanohtml'), $pricedest, $eatby, $sellby, $batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result2 < 0) $error++; } @@ -409,12 +412,12 @@ if ($action == "transfert_stock" && !$cancel) // Remove stock $result1 = $object->correct_stock( $user, - GETPOST("id_entrepot"), - GETPOST("nbpiece"), + GETPOST("id_entrepot", 'int'), + $nbpiece, 1, - GETPOST("label"), + GETPOST("label", 'alphanohtml'), $pricesrc, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result1 < 0) $error++; } @@ -423,12 +426,12 @@ if ($action == "transfert_stock" && !$cancel) // Add stock $result2 = $object->correct_stock( $user, - GETPOST("id_entrepot_destination"), - GETPOST("nbpiece"), + GETPOST("id_entrepot_destination", 'int'), + $nbpiece, 0, - GETPOST("label"), + GETPOST("label", 'alphanohtml'), $pricedest, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result2 < 0) $error++; }