dolibarr  13.0.2
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) $socid = $user->socid;
35 $result = restrictedArea($user, 'banque');
36 
37 
38 /*
39  * View
40  */
41 
42 $companystatic = new Societe($db);
43 
44 llxHeader();
45 
46 // List movements bu category for bank transactions
47 print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account');
48 
49 print '<table class="noborder centpercent">';
50 print "<tr class=\"liste_titre\">";
51 print '<td>'.$langs->trans("Rubrique").'</td>';
52 print '<td class="right">'.$langs->trans("Nb").'</td>';
53 print '<td class="right">'.$langs->trans("Total").'</td>';
54 print '<td class="right">'.$langs->trans("Average").'</td>';
55 print "</tr>\n";
56 
57 $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
58 $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c";
59 $sql .= ", ".MAIN_DB_PREFIX."bank_class as l";
60 $sql .= ", ".MAIN_DB_PREFIX."bank as d";
61 $sql .= " WHERE c.entity = ".$conf->entity;
62 $sql .= " AND c.rowid = l.fk_categ";
63 $sql .= " AND d.rowid = l.lineid";
64 $sql .= " GROUP BY c.label, c.rowid";
65 $sql .= " ORDER BY c.label";
66 
67 $result = $db->query($sql);
68 if ($result)
69 {
70  $num = $db->num_rows($result);
71  $i = 0; $total = 0; $totalnb = 0;
72 
73  while ($i < $num)
74  {
75  $objp = $db->fetch_object($result);
76 
77  print '<tr class="oddeven">';
78  print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries_list.php?bid=$objp->rowid\">$objp->label</a></td>";
79  print '<td class="right">'.$objp->nombre.'</td>';
80  print '<td class="right">'.price(abs($objp->somme))."</td>";
81  print '<td class="right">'.price(abs(price2num($objp->somme / $objp->nombre, 'MT')))."</td>";
82  print "</tr>";
83  $i++;
84  $total += abs($objp->somme);
85  $totalnb += $objp->nombre;
86  }
87  $db->free($result);
88 
89  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
90  print '<td class="liste_total right">'.price($total).'</td>';
91  print '<td colspan="2" class="liste_total right">'.price($totalnb ?price2num($total / $totalnb, 'MT') : 0).'</td></tr>';
92 } else {
93  dol_print_error($db);
94 }
95 print "</table>";
96 
97 // End of page
98 llxFooter();
99 $db->close();
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $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 &#39;...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59