dolibarr 21.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 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
30
39// Load translation files required by the page
40$langs->loadLangs(array('banks', 'categories'));
41
42// Security Check Access Control
43if (!$user->hasRight('banque', 'lire')) {
45}
46
47
54function valeur($sql)
55{
56 global $db;
57
58 $valeur = 0;
59
60 $resql = $db->query($sql);
61 if ($resql) {
62 $obj = $db->fetch_object($resql);
63 $valeur = $obj->amount;
64 $db->free($resql);
65 }
66 return $valeur;
67}
68
69
70/*
71 * View
72 */
73
74llxHeader();
75
76print load_fiche_titre("Bilan");
77print '<br>';
78
79print '<table class="noborder" width="100%" cellpadding="2">';
80print "<tr class=\"liste_titre\">";
81echo '<td colspan="2">'.$langs->trans("Summary").'</td>';
82print "</tr>\n";
83
84
85$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."paiement";
86$paiem = valeur($sql);
87print "<tr class=\"oddeven\"><td>Somme des paiements (associes a une facture)</td><td align=\"right\">".price($paiem)."</td></tr>";
88
89
90$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount > 0";
91$credits = valeur($sql);
92print "<tr class=\"oddeven\"><td>Somme des credits</td><td align=\"right\">".price($credits)."</td></tr>";
93
94
95$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount < 0";
96$debits = valeur($sql);
97print "<tr class=\"oddeven\"><td>Somme des debits</td><td align=\"right\">".price($debits)."</td></tr>";
98
99
100$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank ";
101$solde = valeur($sql);
102print "<tr class=\"oddeven\"><td>".$langs->trans("BankBalance")."</td><td align=\"right\">".price($solde)."</td></tr>";
103
104
105print "</table>";
106
107// End of page
108llxFooter();
109$db->close();
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:71
if(! $user->hasRight( 'banque', 'lire')) valeur($sql)
Get result of sql for field amount.
Definition bilan.php:54
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.