From f3a315b6e79f767d9d6a963481c7f9fdfe76d866 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 19 Jan 2005 14:38:59 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/compta/prelevement/fiche-stat.php | 129 +++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 htdocs/compta/prelevement/fiche-stat.php diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php new file mode 100644 index 00000000000..57f640d60e5 --- /dev/null +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -0,0 +1,129 @@ + + * + * 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('','Statistique Bon de prélèvement'); + +$h = 0; +$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Fiche"); +$h++; + +$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Factures"); +$h++; + +$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Statistiques"); +$hselected = $h; +$h++; + +$prev_id = $_GET["id"]; + +if ($prev_id) +{ + $bon = new BonPrelevement($db,""); + + if ($bon->fetch($_GET["id"]) == 0) + { + dolibarr_fiche_head($head, $hselected, 'Prélèvement : '. $bon->ref); + + print ''; + + print ''; + + print '
Référence'.$bon->ref.'

'; + } + else + { + print "Erreur"; + } + + /* + * 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_prelevement = ".$prev_id; + $sql .= " AND 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; + + while ($i < $num) + { + $row = $db->fetch_row(); + + print "'; + + print "\n"; + + $var=!$var; + $i++; + } + + print "
StatutMontant%
"; + + if ($row[1] == 1) + { + print 'Crédité'; + } + elseif ($row[1] == 2) + { + print 'Rejeté'; + } + + print ''; + print price($row[0]); + + print ''; + print round($row[0]/$bon->amount*100,2)." %"; + print '
"; + $db->free(); + } + else + { + print $db->error() . ' ' . $sql; + } +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>