dolibarr/htdocs/compta/stats/prev.php

140 lines
3.1 KiB
PHP
Raw Normal View History

<?php
2003-06-29 11:02:11 +02:00
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
2003-06-29 11:02:11 +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.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$socidp = $user->societe_id;
}
function pt ($db, $sql, $title) {
global $bc;
2004-09-10 23:52:52 +02:00
global $langs;
2003-06-29 11:02:11 +02:00
print '<table class="border" width="100%">';
2003-10-28 13:40:08 +01:00
print '<tr class="liste_titre">';
print "<td>$title</td>";
print "<td align=\"right\">Montant</td>";
print "</tr>\n";
2003-06-29 11:02:11 +02:00
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0; $total = 0 ;
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($result);
2003-06-29 11:02:11 +02:00
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$obj->dm.'</td>';
print '<td align="right">'.price($obj->amount).'</td>';
2003-06-29 11:02:11 +02:00
print "</tr>\n";
2003-06-29 11:02:11 +02:00
$total = $total + $obj->amount;
$i++;
}
print "<tr class=\"total\"><td colspan=\"2\" align=\"right\"><b>".$langs->trans("TotalHT").": ".price($total)."</b> ".$conf->monnaie."</td></tr>";
2003-06-29 11:02:11 +02:00
$db->free();
}
else
{
dolibarr_print_error($db);
2003-06-29 11:02:11 +02:00
}
print "</table>";
2003-06-29 11:02:11 +02:00
}
/*
*
*/
llxHeader();
2003-08-26 12:16:57 +02:00
2003-06-29 11:02:11 +02:00
if ($sortfield == "")
{
$sortfield="lower(p.label)";
}
if ($sortorder == "")
{
$sortorder="ASC";
}
2003-09-04 23:53:10 +02:00
$in = "(1,2,4)";
2003-06-29 11:02:11 +02:00
2003-09-04 23:53:10 +02:00
print_titre ("CA Pr<50>visionnel bas<61> sur les propositions <b>ouvertes</b> et <b>sign<67>es</b>");
2003-06-29 11:02:11 +02:00
print '<table width="100%">';
print '<tr><td valign="top">';
2003-09-05 21:46:54 +02:00
$sql = "SELECT sum(f.price) as amount, date_format(f.datep,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
2003-06-29 11:02:11 +02:00
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY dm DESC";
pt($db, $sql, $langs->trans("Month"));
2003-06-29 11:02:11 +02:00
print '</td><td valign="top">';
2003-09-05 21:46:54 +02:00
$sql = "SELECT sum(f.price) as amount, year(f.datep) as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
2003-06-29 11:02:11 +02:00
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY dm DESC";
pt($db, $sql, "Ann<EFBFBD>e");
2003-09-16 06:36:16 +02:00
print "<br>";
2003-06-29 11:02:11 +02:00
2003-09-05 21:46:54 +02:00
$sql = "SELECT sum(f.price) as amount, month(f.datep) as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as f WHERE fk_statut in $in";
2003-06-29 11:02:11 +02:00
if ($socidp)
{
$sql .= " AND f.fk_soc = $socidp";
}
$sql .= " GROUP BY dm";
pt($db, $sql, "Mois cumul<75>s");
print "</td></tr></table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>