dolibarr/htdocs/compta/bank/index.php

178 lines
4.3 KiB
PHP
Raw Normal View History

<?php
2002-05-11 20:52:36 +02:00
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2004-01-28 01:08:52 +01:00
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2002-05-11 20:52:36 +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 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
2002-06-19 13:16:45 +02:00
* $Id$
* $Source$
*
2002-05-11 20:52:36 +02:00
*/
/*!
\file htdocs/compta/bank/index.php
\ingroup banque
\brief Page accueil banque
\version $Revision$
*/
2003-09-11 22:18:51 +02:00
require("./pre.inc.php");
require("./bank.lib.php");
require("../../tva.class.php");
require("../../chargesociales.class.php");
2002-06-18 20:21:12 +02:00
$user->getrights('compta');
$user->getrights('banque');
2003-11-21 13:46:37 +01:00
if (!$user->rights->banque->lire)
accessforbidden();
2002-05-11 20:52:36 +02:00
llxHeader();
2002-05-12 15:00:08 +02:00
print_titre ("Comptes bancaires");
print '<br>';
2002-05-11 20:52:36 +02:00
$sql = "SELECT rowid, label,number,bank FROM ".MAIN_DB_PREFIX."bank_account";
2002-05-11 20:52:36 +02:00
$result = $db->query($sql);
2003-08-26 12:10:42 +02:00
if ($result)
{
2002-05-12 15:53:50 +02:00
$accounts = array();
2002-05-11 20:52:36 +02:00
$num = $db->num_rows();
2002-05-12 15:53:50 +02:00
$i = 0;
2002-05-11 20:52:36 +02:00
while ($i < $num) {
$objp = $db->fetch_object($result);
2002-05-12 15:53:50 +02:00
$accounts[$i] = $objp->rowid;
2002-05-12 15:00:08 +02:00
2002-05-11 20:52:36 +02:00
$i++;
}
$db->free();
}
/*
* Comptes
*/
print '<table class="noborder" width="100%">';
2003-10-21 16:09:11 +02:00
print '<tr class="liste_titre"><td>Comptes courants</td><td>Banque</td>';
print '<td align="left">Num<75>ro</td><td align="right">Solde</td><td align="center">Clos</td>';
2003-10-21 16:09:11 +02:00
print "</tr>\n";
2002-05-12 15:53:50 +02:00
$total = 0;
$var=True;
2003-06-20 16:30:08 +02:00
for ($i = 0 ; $i < sizeof($accounts) ; $i++)
{
$var = !$var;
2002-05-12 15:53:50 +02:00
$acc = new Account($db);
$acc->fetch($accounts[$i]);
2003-06-20 16:30:08 +02:00
if ($acc->courant)
{
$solde = $acc->solde();
2002-05-12 15:53:50 +02:00
print "<tr ".$bc[$var]."><td>";
2003-09-11 22:18:51 +02:00
print '<a href="account.php?account='.$acc->id.'">'.$acc->label.'</a>';
2002-08-25 22:06:55 +02:00
2003-06-20 16:30:08 +02:00
print "</td><td>$acc->bank</td><td>$acc->number</td>";
2002-08-25 22:06:55 +02:00
print '<td align="right">'.price($solde).'</td><td align="center">'.$yn[$acc->clos].'</td></tr>';
2002-05-12 15:53:50 +02:00
2003-06-20 16:30:08 +02:00
$total += $solde;
}
2002-05-12 15:53:50 +02:00
}
$var = !$var;
print "<tr>".'<td colspan="3" align="right"><b>'.$langs->trans("Total").'</b></td><td align="right"><b>'.price($total).'</b></td><td>&nbsp;</td></tr>';
2002-06-18 20:21:12 +02:00
print '<tr class="liste_titre"><td colspan="5">Dettes</td></tr>';
2004-11-16 21:42:37 +01:00
2002-06-18 20:21:12 +02:00
/*
* TVA
*/
2004-11-16 21:42:37 +01:00
if ($conf->compta->tva)
2002-12-30 21:20:27 +01:00
{
2004-11-16 21:42:37 +01:00
$var = !$var;
$tva = new Tva($db);
$tva_solde = $tva->solde();
$total = $total + $tva_solde;
print "<tr ".$bc[$var].">".'<td colspan="3">'.$langs->trans("VAT").'</td><td align="right">'.price($tva_solde).'</td><td>&nbsp;</td></tr>';
2002-12-30 21:20:27 +01:00
}
2002-06-19 00:01:03 +02:00
/*
2002-12-30 21:20:27 +01:00
* Charges sociales
2002-06-19 00:01:03 +02:00
*/
$var = !$var;
2002-06-19 00:01:03 +02:00
$chs = new ChargeSociales($db);
$chs_a_payer = $chs->solde();
$total = $total - $chs_a_payer;
print "<tr ".$bc[$var].">".'<td colspan="3">URSSAF</td><td align="right">'.price($chs_a_payer).'</td><td>&nbsp;</td></tr>';
2002-06-18 20:21:12 +02:00
/*
* Total
2002-06-18 20:21:12 +02:00
*/
print "<tr>".'<td colspan="3" align="right"><b>'.$langs->trans("Total").'</b></td><td align="right"><b>'.price($total).'</b></td><td>&nbsp;</td></tr>';
2002-06-18 20:21:12 +02:00
2002-08-25 22:06:55 +02:00
/*
* Comptes placements
2002-08-25 22:06:55 +02:00
*/
print '<tr class="liste_titre"><td colspan="5">Comptes placements</td></tr>';
for ($i = 0 ; $i < sizeof($accounts) ; $i++) {
$var = !$var;
2002-08-25 22:06:55 +02:00
$acc = new Account($db);
$acc->fetch($accounts[$i]);
if (!$acc->courant) {
$solde = $acc->solde();
print "<tr ".$bc[$var]."><td>";
2003-09-11 22:18:51 +02:00
print '<a href="account.php?account='.$acc->id.'">'.$acc->label.'</a>';
2002-08-25 22:06:55 +02:00
print "</td><td>$acc->bank</td><td>$acc->number</td>";
2003-10-21 16:12:44 +02:00
print '<td align="right">'.price($solde).'</td><td>&nbsp;</td></tr>';
2002-08-25 22:06:55 +02:00
$total += $solde;
}
}
2002-05-12 15:00:08 +02:00
print "</table>";
2002-05-11 20:52:36 +02:00
/*
* Boutons d'actions
*/
print "<br><div class=\"tabsAction\">\n";
if ($user->rights->banque->configurer) {
print '<a class="tabAction" href="fiche.php?action=create">Nouveau compte</a>';
print '<a class="tabAction" href="categ.php">Cat<61>gories</a>';
}
print "</div>";
2002-05-11 20:52:36 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>