diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php index 18c096d38c7..7dcd8fb3835 100644 --- a/htdocs/commande/list_det.php +++ b/htdocs/commande/list_det.php @@ -1415,8 +1415,11 @@ if ($resql) { // Détail commande $totalqty = 0; + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['cdet.total_tva'] = 0; + $totalarray['val']['cdet.total_ttc'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); - $last_num = min($num, $limit); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); @@ -1517,9 +1520,6 @@ if ($resql) { // Product QtyOrdered if (!empty($arrayfields['cdet.qty']['checked'])) { print ''.$obj->qty.''; - if (!$i) { - $totalarray['nbfield']++; - } if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty'; } @@ -1528,6 +1528,9 @@ if ($resql) { } else { $totalarray['val']['cdet.qty'] = $obj->qty; } + if (!$i) { + $totalarray['nbfield']++; + } } // Ref @@ -1898,7 +1901,7 @@ if ($resql) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; } - if ($i >= $last_num - 1) { + if ($i >= $imaxinloop - 1) { if (!empty($total_ht)) { $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); } else {