dolibarr/htdocs/compta/bank/bilan.php

98 lines
2.6 KiB
PHP
Raw Normal View History

<?php
2003-09-03 02:17:19 +02:00
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2004-01-28 00:15:17 +01:00
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2002-05-11 20:53:13 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2002-05-11 20:53:13 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2009-07-15 15:50:36 +02:00
*/
/**
* \file htdocs/compta/bank/bilan.php
* \ingroup banque
* \brief Page de bilan
2002-05-11 20:53:13 +02:00
*/
2018-07-26 11:57:25 +02:00
require '../../main.inc.php';
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
2018-05-27 09:40:17 +02:00
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories'));
2002-05-11 20:53:13 +02:00
2021-10-23 07:20:30 +02:00
if (empty($user->rights->banque->lire)) {
2021-02-23 21:09:01 +01:00
accessforbidden();
}
2002-05-11 20:53:13 +02:00
2012-03-18 19:23:01 +01:00
/**
* Get result of sql for field amount
*
* @param string $sql SQL string
* @return int Amount
*/
2003-08-26 12:10:42 +02:00
function valeur($sql)
{
global $db;
2017-12-15 22:14:28 +01:00
$valeur = 0;
$resql = $db->query($sql);
2021-02-23 21:09:01 +01:00
if ($resql) {
$obj = $db->fetch_object($resql);
$valeur = $obj->amount;
$db->free($resql);
2003-08-26 12:10:42 +02:00
}
return $valeur;
2002-05-11 20:53:13 +02:00
}
2009-08-07 20:39:01 +02:00
/*
* View
*/
llxHeader();
print load_fiche_titre("Bilan");
print '<br>';
2002-05-11 20:53:13 +02:00
2021-04-30 15:22:17 +02:00
print '<table class="noborder" width="100%" cellpadding="2">';
print "<tr class=\"liste_titre\">";
2009-08-07 20:39:01 +02:00
echo '<td colspan="2">'.$langs->trans("Summary").'</td>';
print "</tr>\n";
2002-05-11 20:53:13 +02:00
$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."paiement";
2002-05-11 20:53:13 +02:00
$paiem = valeur($sql);
2017-05-11 09:13:51 +02:00
print "<tr class=\"oddeven\"><td>Somme des paiements (associes a une facture)</td><td align=\"right\">".price($paiem)."</td></tr>";
2002-05-11 20:53:13 +02:00
$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount > 0";
2002-05-11 20:53:13 +02:00
$credits = valeur($sql);
2017-05-11 09:15:35 +02:00
print "<tr class=\"oddeven\"><td>Somme des credits</td><td align=\"right\">".price($credits)."</td></tr>";
2002-05-11 20:53:13 +02:00
$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount < 0";
2002-05-11 20:53:13 +02:00
$debits = valeur($sql);
2017-05-11 09:16:44 +02:00
print "<tr class=\"oddeven\"><td>Somme des debits</td><td align=\"right\">".price($debits)."</td></tr>";
2002-05-11 20:53:13 +02:00
$sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank ";
2002-05-11 20:53:13 +02:00
$solde = valeur($sql);
2017-05-11 09:17:43 +02:00
print "<tr class=\"oddeven\"><td>".$langs->trans("BankBalance")."</td><td align=\"right\">".price($solde)."</td></tr>";
2002-05-11 20:53:13 +02:00
print "</table>";
2018-07-29 19:16:28 +02:00
// End of page
llxFooter();
$db->close();