Merge pull request #12593 from frederic34/patch-7

$key is overwriting a variable from outer foreach loop
This commit is contained in:
Laurent Destailleur 2019-12-03 13:17:42 +01:00 committed by GitHub
commit e921bf4acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -253,10 +253,11 @@ if ($resql) {
$paymentstatic->fetch($links[$key]['url_id']); $paymentstatic->fetch($links[$key]['url_id']);
$tmparray = $paymentstatic->getBillsArray(''); $tmparray = $paymentstatic->getBillsArray('');
if (is_array($tmparray)) { if (is_array($tmparray)) {
foreach ($tmparray as $key => $val) { foreach ($tmparray as $tmpkey => $tmpval) {
$invoicestatic->fetch($val); $invoicestatic->fetch($tmpval);
if ($accountelem) if ($accountelem) {
$accountelem .= ', '; $accountelem .= ', ';
}
$accountelem .= $invoicestatic->ref; $accountelem .= $invoicestatic->ref;
} }
} }
@ -264,28 +265,32 @@ if ($resql) {
$paymentsupplierstatic->fetch($links[$key]['url_id']); $paymentsupplierstatic->fetch($links[$key]['url_id']);
$tmparray = $paymentsupplierstatic->getBillsArray(''); $tmparray = $paymentsupplierstatic->getBillsArray('');
if (is_array($tmparray)) { if (is_array($tmparray)) {
foreach ($tmparray as $key => $val) { foreach ($tmparray as $tmpkey => $tmpval) {
$invoicesupplierstatic->fetch($val); $invoicesupplierstatic->fetch($tmpval);
if ($accountelem) if ($accountelem) {
$accountelem .= ', '; $accountelem .= ', ';
}
$accountelem .= $invoicesupplierstatic->ref; $accountelem .= $invoicesupplierstatic->ref;
} }
} }
} elseif ($links[$key]['type'] == 'payment_sc') { } elseif ($links[$key]['type'] == 'payment_sc') {
$paymentsocialcontributionstatic->fetch($links[$key]['url_id']); $paymentsocialcontributionstatic->fetch($links[$key]['url_id']);
if ($accountelem) if ($accountelem) {
$accountelem .= ', '; $accountelem .= ', ';
}
$accountelem .= $langs->transnoentitiesnoconv("SocialContribution") . ' ' . $paymentsocialcontributionstatic->ref; $accountelem .= $langs->transnoentitiesnoconv("SocialContribution") . ' ' . $paymentsocialcontributionstatic->ref;
} elseif ($links[$key]['type'] == 'payment_vat') { } elseif ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->fetch($links[$key]['url_id']); $paymentvatstatic->fetch($links[$key]['url_id']);
if ($accountelem) if ($accountelem) {
$accountelem .= ', '; $accountelem .= ', ';
}
$accountelem .= $langs->transnoentitiesnoconv("VATPayments") . ' ' . $paymentvatstatic->ref; $accountelem .= $langs->transnoentitiesnoconv("VATPayments") . ' ' . $paymentvatstatic->ref;
} elseif ($links[$key]['type'] == 'banktransfert') { } elseif ($links[$key]['type'] == 'banktransfert') {
$comment = $outputlangs->transnoentitiesnoconv("Transfer"); $comment = $outputlangs->transnoentitiesnoconv("Transfer");
if ($objp->amount > 0) { if ($objp->amount > 0) {
if ($comment) if ($comment) {
$comment .= ' '; $comment .= ' ';
}
$banklinestatic->fetch($links[$key]['url_id']); $banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id = $banklinestatic->fk_account; $bankstatic->id = $banklinestatic->fk_account;
$bankstatic->label = $banklinestatic->bank_account_label; $bankstatic->label = $banklinestatic->bank_account_label;
@ -297,8 +302,9 @@ if ($resql) {
$comment .= $bankstatic->getNomUrl(1, ''); $comment .= $bankstatic->getNomUrl(1, '');
$comment .= ')'; $comment .= ')';
} else { } else {
if ($comment) if ($comment) {
$comment .= ' '; $comment .= ' ';
}
$bankstatic->id = $objp->bankid; $bankstatic->id = $objp->bankid;
$bankstatic->label = $objp->bankref; $bankstatic->label = $objp->bankref;
$comment .= ' (' . $langs->transnoentitiesnoconv("from") . ' '; $comment .= ' (' . $langs->transnoentitiesnoconv("from") . ' ';
@ -311,13 +317,15 @@ if ($resql) {
$comment .= ')'; $comment .= ')';
} }
} elseif ($links[$key]['type'] == 'company') { } elseif ($links[$key]['type'] == 'company') {
if ($thirdparty) if ($thirdparty) {
$thirdparty .= ', '; $thirdparty .= ', ';
}
$thirdparty .= dol_trunc($links[$key]['label'], 24); $thirdparty .= dol_trunc($links[$key]['label'], 24);
$newline = 0; $newline = 0;
} elseif ($links[$key]['type'] == 'member') { } elseif ($links[$key]['type'] == 'member') {
if ($thirdparty) if ($thirdparty) {
$accountelem .= ', '; $accountelem .= ', ';
}
$thirdparty .= $links[$key]['label']; $thirdparty .= $links[$key]['label'];
$newline = 0; $newline = 0;
} }