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 '
| Statut | Montant | % |
| "; + print $st[$row[1]]; + print ' | '; + print price($row[0]); + + print ' | '; + print round($row[0]/$total*100,2)." %"; + print ' | '; + + print "
| Total'; + print ' | '; + print price($total); + print ' | '; + print ' | '; + + print "