* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * * 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 3 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, see . */ /** * \file htdocs/compta/bank/budget.php * \ingroup banque * \brief Page de budget */ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("banks"); $langs->load("categories"); // Security check if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'banque'); /* * View */ $companystatic=new Societe($db); llxHeader(); // List movements bu category for bank transactions print_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'title_bank.png'); print ''; print ""; 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"; $sql.= ", ".MAIN_DB_PREFIX."bank_class as l"; $sql.= ", ".MAIN_DB_PREFIX."bank as d"; $sql.= " WHERE c.entity = ".$conf->entity; $sql.= " AND c.rowid = l.fk_categ"; $sql.= " AND d.rowid = l.lineid"; $sql.= " GROUP BY c.label, c.rowid"; $sql.= " ORDER BY c.label"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; $totalnb = 0; $var=true; while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print ""; print ""; print ''; print '"; print '"; print ""; $i++; $total += abs($objp->somme); $totalnb += $objp->nombre; } $db->free($result); print ''; print ''; print ''; } else { dol_print_error($db); } print "
'.$langs->trans("Rubrique").''.$langs->trans("Nb").''.$langs->trans("Total").''.$langs->trans("Average").'
rowid\">$objp->label'.$objp->nombre.''.price(abs($objp->somme))."'.price(abs(price2num($objp->somme / $objp->nombre,'MT')))."
'.$langs->trans("Total").''.price($total).''.price($totalnb?price2num($total / $totalnb, 'MT'):0).'
"; $db->close(); llxFooter();