dolibarr 24.0.0-beta
bilan.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
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
28// Load Dolibarr environment
29require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
38
39
40// Load translation files required by the page
41$langs->loadLangs(array('banks', 'categories'));
42
43// Security Check Access Control
44if (!$user->hasRight('banque', 'lire')) {
46}
47
48
55function getAmount($sql)
56{
57 global $db;
58
59 $amount = 0;
60
61 $resql = $db->query($sql);
62 if ($resql) {
63 $obj = $db->fetch_object($resql);
64 $amount = $obj->amount;
65 $db->free($resql);
66 }
67 return $amount;
68}
69
70
71/*
72 * View
73 */
74
75llxHeader();
76
77print load_fiche_titre("Bilan");
78print '<br>';
79
80print '<table class="noborder" width="100%" cellpadding="2">';
81print "<tr class=\"liste_titre\">";
82echo '<td colspan="2">'.$langs->trans("Summary").'</td>';
83print "</tr>\n";
84
85
86$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."paiement";
87$paiem = getAmount($sql);
88print "<tr class=\"oddeven\"><td>Somme des paiements (associes a une facture)</td><td align=\"right\">".price($paiem)."</td></tr>";
89
90
91$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount > 0";
92$credits = getAmount($sql);
93print "<tr class=\"oddeven\"><td>Somme des credits</td><td align=\"right\">".price($credits)."</td></tr>";
94
95
96$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount < 0";
97$debits = getAmount($sql);
98print "<tr class=\"oddeven\"><td>Somme des debits</td><td align=\"right\">".price($debits)."</td></tr>";
99
100
101$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank ";
102$solde = getAmount($sql);
103print "<tr class=\"oddeven\"><td>".$langs->trans("BankBalance")."</td><td align=\"right\">".price($solde)."</td></tr>";
104
105
106print "</table>";
107
108// End of page
109llxFooter();
110$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
if(! $user->hasRight( 'banque', 'lire')) getAmount($sql)
Get result of sql for field amount.
Definition bilan.php:55
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.