From ed813b872f17116d34b6c8f7f791f01c957a4230 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 28 Oct 2019 10:40:07 +0100 Subject: [PATCH] Fix count array for invoice supplier --- htdocs/fourn/facture/card.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 369ab812d4e..88632a1f4af 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2086,12 +2086,21 @@ if ($action == 'create') print ''.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, '', 'invoice_supplier'); - $cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']); - if ($cntinvoice>=1) + + $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; + + // count function need a array as argument (Note: the array must implement Countable too) + if(is_array($invoice_supplier)) { - setEventMessages('WarningBillExist', null, 'warnings'); - echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['invoice_supplier'])->getNomUrl(1).')'; + $cntinvoice = count($invoice_supplier); + + if ($cntinvoice >= 1) + { + setEventMessages('WarningBillExist', null, 'warnings'); + echo ' ('.$langs->trans('LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).')'; + } } + echo ''; print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."";