From 616ede1643ba8c900bb0de7867ac48be0088d8dd Mon Sep 17 00:00:00 2001 From: BoboTiG Date: Mon, 6 Jun 2016 19:05:24 +0200 Subject: [PATCH 1/2] Unpayed invoices box: fix status icon --- htdocs/core/boxes/box_factures_imp.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 783aa8b2c64..a3d1e3357b5 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -77,8 +77,10 @@ class box_factures_imp extends ModeleBoxes $sql.= " f.tva as total_tva,"; $sql.= " f.total_ttc,"; $sql.= " f.paye, f.fk_statut, f.rowid as facid"; + $sql.= ", sum(pf.amount) as am"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.paye = 0"; @@ -146,7 +148,7 @@ class box_factures_imp extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3), + 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3,$objp->am), ); $line++; @@ -186,4 +188,3 @@ class box_factures_imp extends ModeleBoxes } } - From 2f8915947f6733162f5f08ea973b775f67f8cd43 Mon Sep 17 00:00:00 2001 From: BoboTiG Date: Tue, 7 Jun 2016 10:16:20 +0200 Subject: [PATCH 2/2] Add GROUP BY to be SQL standart compliant --- htdocs/core/boxes/box_factures_imp.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index a3d1e3357b5..bcc26f60e4c 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -87,6 +87,8 @@ class box_factures_imp extends ModeleBoxes $sql.= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; + $sql.= " GROUP BY s.nom, s.rowid, s.code_client, s.logo, f.facnumber, f.date_lim_reglement,"; + $sql.= " f.type, f.amount, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.facnumber DESC "; $sql.= " ORDER BY datelimite ASC, f.facnumber ASC "; $sql.= $db->plimit($max, 0);