diff --git a/htdocs/compta/casoc.php3 b/htdocs/compta/casoc.php3 index 3b897c75fc4..3bbb380fb70 100644 --- a/htdocs/compta/casoc.php3 +++ b/htdocs/compta/casoc.php3 @@ -35,7 +35,7 @@ llxHeader(); $db = new Db(); -print_barre_liste("Chiffre d'affaire par société", $page, $PHP_SELF); +print_titre("Chiffre d'affaire par société"); /* * Ca total @@ -45,49 +45,57 @@ print_barre_liste("Chiffre d'affaire par soci $sql = "SELECT sum(f.amount) as ca 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 ($result) +{ + if ($db->num_rows() > 0) + { + $objp = $db->fetch_object(0); + $catotal = $objp->ca; + } } +print "Total : ".price($catotal).""; + if ($catotal == 0) { $catotal = 1; }; $sql = "SELECT s.nom, s.idp, sum(f.amount) as ca"; -$sql .= " FROM llx_societe as s,llx_facture as f WHERE f.fk_soc = s.idp GROUP BY s.nom, s.idp ORDER BY ca DESC"; +$sql .= " FROM llx_societe as s,llx_facture as f"; +$sql .= " WHERE f.fk_soc = s.idp GROUP BY s.nom, s.idp ORDER BY ca DESC"; $result = $db->query($sql); -if ($result) { +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++; + if ($num > 0) + { + $i = 0; + print "

SociétéMontant 
idp\">$objp->nom".price($objp->ca)."'.price(100 / $catotal * $objp->ca).'%
"; + print ""; + print ""; + print ''; + print "\n"; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + + print "\n"; + print ''; + print ''; + print "\n"; + + print "\n"; + $i++; + } + print "
SociétéMontantPourcentage 
idp\">$objp->nom'.price($objp->ca).''.price(100 / $catotal * $objp->ca).'%idp\">Voir les factures
"; } - print "Total : ".price($total)."euros HT"; - print "Moyenne : ".price($total/$i)."euros HT"; - print ""; - } $db->free(); -} else { +} +else +{ print $db->error(); }