dolibarr  19.0.0-dev
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 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array('banks', 'categories'));
33 
34 // Security check
35 if ($user->socid) {
36  $socid = $user->socid;
37 }
38 $result = restrictedArea($user, 'banque');
39 
40 
41 /*
42  * View
43  */
44 
45 $companystatic = new Societe($db);
46 
47 $title = $langs->trans('ListTransactionsByCategory');
48 $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
49 
50 llxHeader('', $title, $help_url);
51 
52 // List movements bu category for bank transactions
53 print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account');
54 
55 print '<table class="noborder centpercent">';
56 print "<tr class=\"liste_titre\">";
57 print '<td>'.$langs->trans("Rubrique").'</td>';
58 print '<td class="right">'.$langs->trans("Nb").'</td>';
59 print '<td class="right">'.$langs->trans("Total").'</td>';
60 print '<td class="right">'.$langs->trans("Average").'</td>';
61 print "</tr>\n";
62 
63 $sql = "SELECT sum(d.amount) as somme, count(*) as nombre, c.label, c.rowid ";
64 $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c";
65 $sql .= ", ".MAIN_DB_PREFIX."bank_class as l";
66 $sql .= ", ".MAIN_DB_PREFIX."bank as d";
67 $sql .= " WHERE c.entity = ".$conf->entity;
68 $sql .= " AND c.rowid = l.fk_categ";
69 $sql .= " AND d.rowid = l.lineid";
70 $sql .= " GROUP BY c.label, c.rowid";
71 $sql .= " ORDER BY c.label";
72 
73 $result = $db->query($sql);
74 if ($result) {
75  $num = $db->num_rows($result);
76  $i = 0;
77  $total = 0;
78  $totalnb = 0;
79 
80  while ($i < $num) {
81  $objp = $db->fetch_object($result);
82 
83  print '<tr class="oddeven">';
84  print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries_list.php?bid=$objp->rowid\">$objp->label</a></td>";
85  print '<td class="right">'.$objp->nombre.'</td>';
86  print '<td class="right"><span class="amount">'.price(abs($objp->somme))."</span></td>";
87  print '<td class="right"><span class="amount">'.price(abs(price2num($objp->somme / $objp->nombre, 'MT')))."</span></td>";
88  print "</tr>";
89  $i++;
90  $total += abs($objp->somme);
91  $totalnb += $objp->nombre;
92  }
93  $db->free($result);
94 
95  print '<tr class="liste_total"><td colspan="2">'.$langs->trans("Total").'</td>';
96  print '<td class="liste_total right">'.price($total).'</td>';
97  print '<td colspan="2" class="liste_total right">'.price($totalnb ?price2num($total / $totalnb, 'MT') : 0).'</td></tr>';
98 } else {
99  dol_print_error($db);
100 }
101 print "</table>";
102 
103 // End of page
104 llxFooter();
105 $db->close();
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:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->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') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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 '.
dol_print_error($db='', $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.