From 3df35c02033949f7cb24a708fa9dd25a90a924e4 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 19 Jan 2005 14:49:54 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/compta/prelevement/stats.php | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 htdocs/compta/prelevement/stats.php diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php new file mode 100644 index 00000000000..bb75e848fea --- /dev/null +++ b/htdocs/compta/prelevement/stats.php @@ -0,0 +1,121 @@ + + * + * 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. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) accessforbidden(); + +llxHeader('','Statistiques prélèvements'); + +print_titre("Statistiques prélèvements"); + + +$sql = "SELECT sum(f.total_ttc)"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; +$sql .= " WHERE pf.fk_facture = f.rowid"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + $i = 0; + + if ( $num >0 ) + { + $row = $db->fetch_row(); + $total = $row[0]; + } +} + +/* + * Stats + * + */ +$sql = "SELECT sum(f.total_ttc), pf.statut"; +$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; +$sql .= " WHERE pf.fk_facture = f.rowid"; +$sql .= " GROUP BY pf.statut"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + $i = 0; + + print"\n\n"; + print ''; + print ''; + print ''; + + $var=True; + + $st[0] = "En attente"; + $st[1] = "Crédité"; + $st[2] = "Rejeté"; + + while ($i < $num) + { + $row = $db->fetch_row(); + + print "'; + + print "\n"; + + $var=!$var; + $i++; + } + + print "".''; + + print "\n"; + + + print "
StatutMontant%
"; + print $st[$row[1]]; + print ''; + print price($row[0]); + + print ''; + print round($row[0]/$total*100,2)." %"; + print '
Total'; + print ''; + print price($total); + print ' '; + print '
"; + + + + + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>