bilan.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. /**
  19. * \file htdocs/compta/bank/bilan.php
  20. * \ingroup compta/bank
  21. * \brief Page of Balance sheet
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array('banks', 'categories'));
  28. // Security Check Access Control
  29. if (empty($user->rights->banque->lire)) {
  30. accessforbidden();
  31. }
  32. /**
  33. * Get result of sql for field amount
  34. *
  35. * @param string $sql SQL string
  36. * @return int Amount
  37. */
  38. function valeur($sql)
  39. {
  40. global $db;
  41. $valeur = 0;
  42. $resql = $db->query($sql);
  43. if ($resql) {
  44. $obj = $db->fetch_object($resql);
  45. $valeur = $obj->amount;
  46. $db->free($resql);
  47. }
  48. return $valeur;
  49. }
  50. /*
  51. * View
  52. */
  53. llxHeader();
  54. print load_fiche_titre("Bilan");
  55. print '<br>';
  56. print '<table class="noborder" width="100%" cellpadding="2">';
  57. print "<tr class=\"liste_titre\">";
  58. echo '<td colspan="2">'.$langs->trans("Summary").'</td>';
  59. print "</tr>\n";
  60. $sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."paiement";
  61. $paiem = valeur($sql);
  62. print "<tr class=\"oddeven\"><td>Somme des paiements (associes a une facture)</td><td align=\"right\">".price($paiem)."</td></tr>";
  63. $sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount > 0";
  64. $credits = valeur($sql);
  65. print "<tr class=\"oddeven\"><td>Somme des credits</td><td align=\"right\">".price($credits)."</td></tr>";
  66. $sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank WHERE amount < 0";
  67. $debits = valeur($sql);
  68. print "<tr class=\"oddeven\"><td>Somme des debits</td><td align=\"right\">".price($debits)."</td></tr>";
  69. $sql = "SELECT sum(amount) as amount FROM ".MAIN_DB_PREFIX."bank ";
  70. $solde = valeur($sql);
  71. print "<tr class=\"oddeven\"><td>".$langs->trans("BankBalance")."</td><td align=\"right\">".price($solde)."</td></tr>";
  72. print "</table>";
  73. // End of page
  74. llxFooter();
  75. $db->close();