diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index eaf78c514d0..a3e44fea630 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -222,8 +222,14 @@ if ($conf->commande->enabled && $user->rights->commande->lire) { $langs->load("orders"); - $sql = "SELECT p.rowid, p.ref, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as p, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut >= 1 AND p.facture = 0"; + $sql = "SELECT sum(f.total) as tot_fht,sum(f.total_ttc) as tot_fttc, p.rowid, p.ref, s.nom, s.idp, p.total_ht, p.total_ttc + FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s + LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid + LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid + WHERE p.fk_soc = s.idp + AND p.fk_statut >=1 + AND p.facture =0 + GROUP BY p.rowid"; if ($socidp) { $sql .= " AND p.fk_soc = $socidp"; @@ -237,20 +243,30 @@ if ($conf->commande->enabled && $user->rights->commande->lire) $i = 0; print '
| '.$langs->trans("OrdersToBill").' ('.$num.') | '.$langs->trans("OrdersToBill").' ('.$num.') | '; + print ''.$langs->trans("AmountHT").' | '.$langs->trans("AmountTTC").' | '; $var = True; + $tot_ht=0; + $tot_ttc=0; while ($i < $num) { $var=!$var; $obj = $db->fetch_object(); - print " |
| rowid\">".img_object($langs->trans("ShowOrder"),"order").' '; - print "rowid\">".$obj->ref.' | '; - - print ''.img_object($langs->trans("ShowCompany"),"company").' '; - print ''.$obj->nom.' | ||
| rowid\">".img_object($langs->trans("ShowOrder"),"order").' '; + print "rowid\">".$obj->ref.' | '; + + print ''.img_object($langs->trans("ShowCompany"),"company").' '; + print ''.$obj->nom.' | '; + print ''.price($obj->total_ht-$obj->tot_fht).' | '; + print ''.price($obj->total_ttc-$obj->tot_fttc).' |
| '.$langs->trans("Total").' (Reste à facturer : '.price($tot_ttc).') | '.price($tot_ht)." | ".price($tot_ttc)." | |