* Copyright (C) 2004-2005 Laurent Destailleur * * 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$ * */ /** \file htdocs/compta/bank/budget.php \ingroup banque \brief Page de budget \version $Revision$ */ require("./pre.inc.php"); if (!$user->rights->banque->lire) accessforbidden(); llxHeader(); /* * * */ if ($_GET["bid"] == 0) { /* * Liste mouvements par catégories d'écritures financières */ print_titre("Ecritures bancaires par catégories"); print '
'; print ''; print ""; print ''; print "\n"; $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid "; $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c, ".MAIN_DB_PREFIX."bank_class as l, ".MAIN_DB_PREFIX."bank as d"; $sql .= " WHERE d.rowid=l.lineid AND c.rowid = l.fk_categ GROUP BY c.label, c.rowid ORDER BY c.label"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; $var=true; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; print ""; print ''; print ""; print ""; print ""; $i++; $total = $total + abs($objp->somme); } $db->free($result); print ''; print ''; } else { dolibarr_print_error($db); } print "
'.$langs->trans("Description").''.$langs->trans("Nb").''.$langs->trans("Total").''.$langs->trans("Average").'
rowid\">$objp->label'.$objp->nombre.'".price(abs($objp->somme))."".price(abs($objp->somme / $objp->nombre))."
'.$langs->trans("Total").''.price($total).' 
"; } else { /* * Rapport mouvements pour une catégorie donnée */ $sql = "SELECT label FROM ".MAIN_DB_PREFIX."bank_categ WHERE rowid=".$_GET["bid"]; if ( $db->query($sql) ) { if ( $db->num_rows() ) { $budget_name = $db->result(0,0); } $db->free(); } print_titre("Ecriture bancaire pour la catégorie: $budget_name"); print '
'; print ''; print ""; print ''; print ''; print ''; print "\n"; $sql = "SELECT b.amount, b.label, ".$db->pdate("b.dateo")." as do, b.rowid, ba.label as labelcompte, ba.rowid as bankid"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as l, ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= " WHERE b.rowid=l.lineid AND l.fk_categ=".$_GET["bid"]; $sql.= " AND b.fk_account = ba.rowid"; $sql.= " ORDER BY b.dateo DESC"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; $var=True; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; print "\n"; print ""; print "'; print ""; print ""; $i++; $total = $total + (0 - $objp->amount); } $db->free(); print '"; } else { dolibarr_print_error($db); } print "
'.$langs->trans("Date").''.$langs->trans("Bank").''.$langs->trans("Description").''.$langs->trans("Amount").' 
".dolibarr_print_date($objp->do)."bankid\">$objp->labelcompterowid\">".img_object($langs->trans("ShowPayment"),"payment").' '.$objp->label.'".price(0 - $objp->amount)." 
'.$langs->trans("Total")."".price(abs($total))."".$conf->monnaie."
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>