dolibarr/htdocs/compta/ca.php3

97 lines
2.1 KiB
PHP
Raw Normal View History

2002-04-29 22:13:06 +02:00
<?PHP
2003-03-23 16:19:03 +01:00
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2002-04-29 22:13:06 +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.
*
2003-03-23 16:19:03 +01:00
* $Id$
* $Source$
*
2002-04-29 22:13:06 +02:00
*/
require("./pre.inc.php3");
/*
*
*/
2003-03-23 16:19:03 +01:00
$db = new Db();
2002-04-29 22:13:06 +02:00
2003-03-23 16:19:03 +01:00
llxHeader();
2002-04-29 22:13:06 +02:00
2003-03-23 16:19:03 +01:00
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
2002-04-29 22:13:06 +02:00
}
2002-05-06 21:10:48 +02:00
print_titre("Chiffres d'affaires en euros HT");
2002-04-29 22:13:06 +02:00
$sql = "SELECT sum(f.amount) as amount , date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM llx_facture as f WHERE f.paye = 1";
2003-05-13 13:48:33 +02:00
2003-03-23 16:19:03 +01:00
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
2002-04-29 22:13:06 +02:00
$sql .= " GROUP BY dm DESC";
2003-05-13 13:48:33 +02:00
$result = $db->query($sql);
2003-05-13 14:23:15 +02:00
if ($result)
{
2003-05-13 13:48:33 +02:00
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$cum[$row[1]] = $row[0];
$i++;
}
}
2002-04-29 22:13:06 +02:00
2003-05-13 13:48:33 +02:00
print '<table width="100%" border="1">';
print '<tr class="liste_titre"><td></td>';
for ($annee = 2001 ; $annee < 2006 ; $annee++)
2003-03-23 16:19:03 +01:00
{
2003-05-13 13:48:33 +02:00
print '<td align="center" width="14%">'.$annee.'</td>';
2003-03-23 16:19:03 +01:00
}
2003-05-13 13:48:33 +02:00
print '</tr>';
for ($mois = 1 ; $mois < 13 ; $mois++)
{
print '<tr>';
print "<td>".strftime("%B",mktime(1,1,1,$mois,1,2000))."</td>";
for ($annee = 2001 ; $annee < 2006 ; $annee++)
{
print '<td align="right">&nbsp;';
$case = strftime("%Y-%m",mktime(1,1,1,$mois,1,$annee));
if ($cum[$case]>0)
{
print price($cum[$case]);
}
print "</td>";
}
2002-04-29 22:13:06 +02:00
2003-05-13 13:48:33 +02:00
print '</tr>';
}
2002-04-29 22:13:06 +02:00
2003-05-13 13:48:33 +02:00
print "</table>";
2002-04-29 22:13:06 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
2003-03-23 16:19:03 +01:00
2002-04-29 22:13:06 +02:00
?>