From f7d1ce1e099b95d83046556c60d734c4a3f0539b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 00:25:30 +0200 Subject: [PATCH] FIX Can use decimal value in virtual products --- htdocs/product/composition/card.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index cb95f10d79f..88945342af5 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -70,13 +70,15 @@ if ($cancel) $action =''; if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer)) { $error=0; - for ($i=0; $i<$_POST["max_prod"]; $i++) + var_dump(GETPOST("max_prod", 'int')); + for ($i=0; $i < GETPOST("max_prod", 'int'); $i++) { - if ($_POST["prod_qty_".$i] > 0) + $qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS'); + if ($qty > 0) { - if ($object->add_sousproduit($id, $_POST["prod_id_".$i], $_POST["prod_qty_".$i], $_POST["prod_incdec_".$i]) > 0) + if ($object->add_sousproduit($id, GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')) > 0) { - //var_dump($id.' - '.$_POST["prod_id_".$i].' - '.$_POST["prod_qty_".$i]);exit; + //var_dump($i.' '.GETPOST("prod_id_".$i, 'int'), $qty, GETPOST("prod_incdec_".$i, 'int')); $action = 'edit'; } else @@ -94,7 +96,7 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se } else { - if ($object->del_sousproduit($id, $_POST["prod_id_".$i]) > 0) + if ($object->del_sousproduit($id, GETPOST("prod_id_".$i, 'int')) > 0) { $action = 'edit'; } @@ -106,6 +108,7 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se } } } + if (! $error) { header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -540,7 +543,9 @@ if ($id > 0 || ! empty($ref)) if($num == 0) print ''.$langs->trans("NoMatchFound").''; - while ($i < $num) + $MAX = 100; + + while ($i < min($num, $MAX)) { $objp = $db->fetch_object($resql); if($objp->rowid != $id) @@ -572,7 +577,8 @@ if ($id > 0 || ! empty($ref)) } } - print "\n".''; + print "\n"; + print ''; $productstatic->id=$objp->rowid; $productstatic->ref=$objp->ref; @@ -620,6 +626,14 @@ if ($id > 0 || ! empty($ref)) } $i++; } + if ($num > $MAX) { + print ''; + print ''.$langs->trans("More").'...'; + print ''; + print ''; + print ''; + print ''; + } } else {