* * $Id$ * $Source$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ require("./pre.inc.php3"); llxHeader(); $db = new Db(); print_barre_liste("Chiffre d'affaire par société", $page, $PHP_SELF); /* * Ca total * */ $sql = "SELECT sum(f.amount) as ca"; $sql .= " FROM llx_facture as f"; $result = $db->query($sql); if ($result) { if ($db->num_rows() > 0) { $objp = $db->fetch_object(0); $catotal = $objp->ca; } } if ($catotal == 0) { $catotal = 1; }; $sql = "SELECT s.nom, s.idp, sum(f.amount) as ca"; $sql .= " FROM societe as s,llx_facture as f WHERE f.fk_soc = s.idp GROUP BY s.nom, s.idp ORDER BY ca DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows(); if ($num > 0) { $i = 0; print "

"; print ""; print ""; print ""; print "\n"; $var=True; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print "\n"; print ""; print ''; $total = $total + $objp->ca; print "\n"; $i++; } print ""; print ""; print "
SociétéMontant 
idp\">$objp->nom".price($objp->ca)."'.price(100 / $catotal * $objp->ca).'%
Total : ".price($total)."euros HT
Moyenne : ".price($total/$i)."euros HT
"; } $db->free(); } else { print $db->error(); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>