From 6be499e9215bff1d6244f704353047259835f79f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Dec 2021 20:06:27 +0100 Subject: [PATCH] Fix report --- htdocs/compta/resultat/clientfourn.php | 36 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 83d100e86d1..74685c8cbd6 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -280,7 +280,10 @@ if ($modecompta == 'BOOKKEEPING') { $charofaccountstring = $conf->global->CHARTOFACCOUNTS; $charofaccountstring = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); - $sql = "SELECT f.thirdparty_code as name, -1 as socid, aa.pcg_type, SUM(f.credit - f.debit) as amount"; + $sql = "SELECT -1 as socid, aa.pcg_type, SUM(f.credit - f.debit) as amount"; + if ($showaccountdetail == 'no') { + $sql .= ", f.thirdparty_code as name"; + } $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f"; $sql .= ", ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " WHERE f.numero_compte = aa.account_number"; @@ -290,7 +293,10 @@ if ($modecompta == 'BOOKKEEPING') { if (!empty($date_start) && !empty($date_end)) { $sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; } - $sql .= " GROUP BY pcg_type DESC, name, socid"; + $sql .= " GROUP BY pcg_type DESC"; + if ($showaccountdetail == 'no') { + $sql .= ", name, socid"; // group by "accounting group" (INCOME/EXPENSE), then "customer". + } $sql .= $db->order($sortfield, $sortorder); $oldpcgtype = ''; @@ -305,17 +311,21 @@ if ($modecompta == 'BOOKKEEPING') { while ($i < $num) { $objp = $db->fetch_object($result); - if ($objp->pcg_type != $oldpcgtype) { - print ''.$objp->pcg_type.''; - $oldpcgtype = $objp->pcg_type; + if ($showaccountdetail == 'no') { + if ($objp->pcg_type != $oldpcgtype) { + print ''.$objp->pcg_type.''; + $oldpcgtype = $objp->pcg_type; + } + } else { + print ''; + print ' '; + print ''.$objp->pcg_type; + print ($objp->name ? ' ('.$objp->name.')' : ''); + print "\n"; + print ''.price($objp->amount)."\n"; + print "\n"; } - print ''; - print ' '; - print ''.$objp->pcg_type.($objp->name ? ' ('.$objp->name.')' : '')."\n"; - print ''.price($objp->amount)."\n"; - print "\n"; - $total_ht += (isset($objp->amount) ? $objp->amount : 0); $total_ttc += (isset($objp->amount) ? $objp->amount : 0); @@ -333,7 +343,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere = "pcg_type = '".$db->escape($objp->pcg_type)."'"; $tmppredefinedgroupwhere .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; - //$tmppredefinedgroupwhere.= " AND thirdparty_code = '".$db->escape($objp->name)."'"; + //$tmppredefinedgroupwhere .= " AND thirdparty_code = '".$db->escape($objp->name)."'"; // Get cpts of category/group $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere); @@ -637,7 +647,7 @@ if ($modecompta == 'BOOKKEEPING') { $objp = $db->fetch_object($result); print ' '; - print "".$langs->trans("Bills")." socid."\">".$objp->name."\n"; + print "".$langs->trans("Bills").' '.$objp->name.''."\n"; if ($modecompta == 'CREANCES-DETTES') { print ''.price(-$objp->amount_ht)."\n";