dolibarr 20.0.0
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
26// Load Dolibarr environment
27require '../../main.inc.php';
28require_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 Access Control
34if (!$user->hasRight('banque', 'lire')) {
36}
37
38
45function valeur($sql)
46{
47 global $db;
48
49 $valeur = 0;
50
51 $resql = $db->query($sql);
52 if ($resql) {
53 $obj = $db->fetch_object($resql);
54 $valeur = $obj->amount;
55 $db->free($resql);
56 }
57 return $valeur;
58}
59
60
61/*
62 * View
63 */
64
65llxHeader();
66
67print load_fiche_titre("Bilan");
68print '<br>';
69
70print '<table class="noborder" width="100%" cellpadding="2">';
71print "<tr class=\"liste_titre\">";
72echo '<td colspan="2">'.$langs->trans("Summary").'</td>';
73print "</tr>\n";
74
75
76$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."paiement";
77$paiem = valeur($sql);
78print "<tr class=\"oddeven\"><td>Somme des paiements (associes a une facture)</td><td align=\"right\">".price($paiem)."</td></tr>";
79
80
81$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount > 0";
82$credits = valeur($sql);
83print "<tr class=\"oddeven\"><td>Somme des credits</td><td align=\"right\">".price($credits)."</td></tr>";
84
85
86$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount < 0";
87$debits = valeur($sql);
88print "<tr class=\"oddeven\"><td>Somme des debits</td><td align=\"right\">".price($debits)."</td></tr>";
89
90
91$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank ";
92$solde = valeur($sql);
93print "<tr class=\"oddeven\"><td>".$langs->trans("BankBalance")."</td><td align=\"right\">".price($solde)."</td></tr>";
94
95
96print "</table>";
97
98// End of page
99llxFooter();
100$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
if(! $user->hasRight( 'banque', 'lire')) valeur($sql)
Get result of sql for field amount.
Definition bilan.php:45
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.