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