* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2024 MDW * * 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 */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); // Security check if ($user->socid) { $socid = $user->socid; } $result = restrictedArea($user, 'banque'); /* * View */ $companystatic = new Societe($db); $title = $langs->trans('ListTransactionsByCategory'); $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas'; llxHeader('', $title, $help_url); // List movements bu category for bank transactions print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account'); 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."category_bank as c"; $sql .= ", ".MAIN_DB_PREFIX."category_bankline 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; while ($i < $num) { $objp = $db->fetch_object($result); 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(price2num(abs($objp->somme / $objp->nombre), 'MT'))."
'.$langs->trans("Total").''.price($total).''.price($totalnb ? price2num($total / $totalnb, 'MT') : 0).'
"; // End of page llxFooter(); $db->close();