dolibarr  20.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  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Load Dolibarr environment
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('banks', 'categories'));
34 
35 // Security check
36 if ($user->socid) {
37  $socid = $user->socid;
38 }
39 $result = restrictedArea($user, 'banque');
40 
41 
42 /*
43  * View
44  */
45 
46 $companystatic = new Societe($db);
47 
48 $title = $langs->trans('ListTransactionsByCategory');
49 $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
50 
51 llxHeader('', $title, $help_url);
52 
53 // List movements bu category for bank transactions
54 print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account');
55 
56 print '<table class="noborder centpercent">';
57 print "<tr class=\"liste_titre\">";
58 print '<td>'.$langs->trans("Rubrique").'</td>';
59 print '<td class="right">'.$langs->trans("Nb").'</td>';
60 print '<td class="right">'.$langs->trans("Total").'</td>';
61 print '<td class="right">'.$langs->trans("Average").'</td>';
62 print "</tr>\n";
63 
64 $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
65 $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c";
66 $sql .= ", ".MAIN_DB_PREFIX."bank_class as l";
67 $sql .= ", ".MAIN_DB_PREFIX."bank as d";
68 $sql .= " WHERE c.entity = ".$conf->entity;
69 $sql .= " AND c.rowid = l.fk_categ";
70 $sql .= " AND d.rowid = l.lineid";
71 $sql .= " GROUP BY c.label, c.rowid";
72 $sql .= " ORDER BY c.label";
73 
74 $result = $db->query($sql);
75 if ($result) {
76  $num = $db->num_rows($result);
77  $i = 0;
78  $total = 0;
79  $totalnb = 0;
80 
81  while ($i < $num) {
82  $objp = $db->fetch_object($result);
83 
84  print '<tr class="oddeven">';
85  print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries_list.php?bid=$objp->rowid\">$objp->label</a></td>";
86  print '<td class="right">'.$objp->nombre.'</td>';
87  print '<td class="right"><span class="amount">'.price(abs($objp->somme))."</span></td>";
88  print '<td class="right"><span class="amount">'.price(price2num(abs($objp->somme / $objp->nombre), 'MT'))."</span></td>";
89  print "</tr>";
90  $i++;
91  $total += abs($objp->somme);
92  $totalnb += $objp->nombre;
93  }
94  $db->free($result);
95 
96  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
97  print '<td class="liste_total right">'.price($total).'</td>';
98  print '<td colspan="2" class="liste_total right">'.price($totalnb ? price2num($total / $totalnb, 'MT') : 0).'</td></tr>';
99 } else {
100  dol_print_error($db);
101 }
102 print "</table>";
103 
104 // End of page
105 llxFooter();
106 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:55
llxFooter()
Empty footer.
Definition: wrapper.php:69
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
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.