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 '