From 85776f7529dbc3d969e827a82d6fcf1c1b168159 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 20:08:00 +0100 Subject: [PATCH] Avoid function calls in a FOR loop test part --- htdocs/core/lib/fourn.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 27ebc98635d..25bbd52e413 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -162,14 +162,17 @@ function ordersupplier_prepare_head($object) //If dispach process running we add the number of item to dispatch into the head if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { - $lines = $object->fetch_lines(); + $object->fetch_lines(); + $nbLinesOrdered = count($object->lines); $dispachedLines = $object->getDispachedLines(1); + $nbDispachedLines = count($dispachedLines); + $sumQtyAllreadyDispatched = 0; - for ($line = 0 ; $line < count($dispachedLines); $line++) { + for ($line = 0 ; $line < $nbDispachedLines; $line++) { $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } $sumQtyOrdered = 0; - for ($line = 0 ; $line < count($object->lines); $line++) { + for ($line = 0 ; $line < $nbLinesOrdered; $line++) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; } $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.'';