From 36bb4eece9cedc71e0f17578d84a1f161f72c48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:34:05 +0100 Subject: [PATCH] $key is overwriting a variable from outer foreach loop --- scripts/bank/export-bank-receipts.php | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 8b6ab1d60e1..45c6969d4de 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -253,10 +253,11 @@ if ($resql) { $paymentstatic->fetch($links[$key]['url_id']); $tmparray = $paymentstatic->getBillsArray(''); if (is_array($tmparray)) { - foreach ($tmparray as $key => $val) { - $invoicestatic->fetch($val); - if ($accountelem) + foreach ($tmparray as $tmpkey => $tmpval) { + $invoicestatic->fetch($tmpval); + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $invoicestatic->ref; } } @@ -264,28 +265,32 @@ if ($resql) { $paymentsupplierstatic->fetch($links[$key]['url_id']); $tmparray = $paymentsupplierstatic->getBillsArray(''); if (is_array($tmparray)) { - foreach ($tmparray as $key => $val) { - $invoicesupplierstatic->fetch($val); - if ($accountelem) + foreach ($tmparray as $tmpkey => $tmpval) { + $invoicesupplierstatic->fetch($tmpval); + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $invoicesupplierstatic->ref; } } } elseif ($links[$key]['type'] == 'payment_sc') { $paymentsocialcontributionstatic->fetch($links[$key]['url_id']); - if ($accountelem) + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $langs->transnoentitiesnoconv("SocialContribution") . ' ' . $paymentsocialcontributionstatic->ref; } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->fetch($links[$key]['url_id']); - if ($accountelem) + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $langs->transnoentitiesnoconv("VATPayments") . ' ' . $paymentvatstatic->ref; } elseif ($links[$key]['type'] == 'banktransfert') { $comment = $outputlangs->transnoentitiesnoconv("Transfer"); if ($objp->amount > 0) { - if ($comment) + if ($comment) { $comment .= ' '; + } $banklinestatic->fetch($links[$key]['url_id']); $bankstatic->id = $banklinestatic->fk_account; $bankstatic->label = $banklinestatic->bank_account_label; @@ -297,8 +302,9 @@ if ($resql) { $comment .= $bankstatic->getNomUrl(1, ''); $comment .= ')'; } else { - if ($comment) + if ($comment) { $comment .= ' '; + } $bankstatic->id = $objp->bankid; $bankstatic->label = $objp->bankref; $comment .= ' (' . $langs->transnoentitiesnoconv("from") . ' '; @@ -311,13 +317,15 @@ if ($resql) { $comment .= ')'; } } elseif ($links[$key]['type'] == 'company') { - if ($thirdparty) + if ($thirdparty) { $thirdparty .= ', '; + } $thirdparty .= dol_trunc($links[$key]['label'], 24); $newline = 0; } elseif ($links[$key]['type'] == 'member') { - if ($thirdparty) + if ($thirdparty) { $accountelem .= ', '; + } $thirdparty .= $links[$key]['label']; $newline = 0; }