dolibarr 21.0.0-beta
budget.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32
41// Load translation files required by the page
42$langs->loadLangs(array('banks', 'categories'));
43
44// Security check
45if ($user->socid) {
46 $socid = $user->socid;
47}
48$result = restrictedArea($user, 'banque');
49
50
51/*
52 * View
53 */
54
55$companystatic = new Societe($db);
56
57$title = $langs->trans('ListTransactionsByCategory');
58$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
59
60llxHeader('', $title, $help_url);
61
62// List movements bu category for bank transactions
63print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account');
64
65print '<table class="noborder centpercent">';
66print "<tr class=\"liste_titre\">";
67print '<td>'.$langs->trans("Rubrique").'</td>';
68print '<td class="right">'.$langs->trans("Nb").'</td>';
69print '<td class="right">'.$langs->trans("Total").'</td>';
70print '<td class="right">'.$langs->trans("Average").'</td>';
71print "</tr>\n";
72
73$sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
74$sql .= " FROM ".MAIN_DB_PREFIX."categorie as c";
75$sql .= ", ".MAIN_DB_PREFIX."category_bankline as l";
76$sql .= ", ".MAIN_DB_PREFIX."bank as d";
77$sql .= " WHERE c.entity = ".$conf->entity;
78$sql .= " AND c.rowid = l.fk_categ";
79$sql .= " AND d.rowid = l.lineid";
80$sql .= " GROUP BY c.label, c.rowid";
81$sql .= " ORDER BY c.label";
82
83$result = $db->query($sql);
84if ($result) {
85 $num = $db->num_rows($result);
86 $i = 0;
87 $total = 0;
88 $totalnb = 0;
89
90 while ($i < $num) {
91 $objp = $db->fetch_object($result);
92
93 print '<tr class="oddeven">';
94 print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries_list.php?bid=$objp->rowid\">$objp->label</a></td>";
95 print '<td class="right">'.$objp->nombre.'</td>';
96 print '<td class="right"><span class="amount">'.price(abs($objp->somme))."</span></td>";
97 print '<td class="right"><span class="amount">'.price(price2num(abs($objp->somme / $objp->nombre), 'MT'))."</span></td>";
98 print "</tr>";
99 $i++;
100 $total += abs($objp->somme);
101 $totalnb += $objp->nombre;
102 }
103 $db->free($result);
104
105 print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
106 print '<td class="liste_total right">'.price($total).'</td>';
107 print '<td colspan="2" class="liste_total right">'.price($totalnb ? price2num($total / $totalnb, 'MT') : 0).'</td></tr>';
108} else {
109 dol_print_error($db);
110}
111print "</table>";
112
113// End of page
114llxFooter();
115$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage third parties objects (customers, suppliers, prospects...)
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.