dolibarr/htdocs/compta/stats/prev.php

135 lines
3.3 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>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
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$
*/
2010-03-27 15:40:39 +01:00
require('../../main.inc.php');
// Security check
if ($user->societe_id > 0)
2003-06-29 11:02:11 +02:00
{
$socid = $user->societe_id;
2003-06-29 11:02:11 +02:00
}
function pt ($db, $sql, $title) {
global $bc;
2005-08-16 09:38:25 +02:00
global $langs,$conf;
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";
2010-03-27 15:40:39 +01:00
2003-06-29 11:02:11 +02:00
$result = $db->query($sql);
2010-03-27 15:40:39 +01:00
if ($result)
2003-06-29 11:02:11 +02:00
{
2010-08-14 04:44:07 +02:00
$num = $db->num_rows($result);
2003-06-29 11:02:11 +02:00
$i = 0; $total = 0 ;
2010-03-27 15:40:39 +01:00
2003-06-29 11:02:11 +02:00
$var=True;
2010-03-27 15:40:39 +01:00
while ($i < $num)
2003-06-29 11:02:11 +02:00
{
$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>';
2010-03-27 15:40:39 +01: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> ".$langs->trans("Currency".$conf->monnaie)."</td></tr>";
2010-03-27 15:40:39 +01:00
2003-06-29 11:02:11 +02:00
$db->free();
2010-03-27 15:40:39 +01:00
}
else
2003-06-29 11:02:11 +02:00
{
dol_print_error($db);
2003-06-29 11:02:11 +02:00
}
print "</table>";
2010-03-27 15:40:39 +01:00
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
2010-03-27 15:40:39 +01: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">';
$sql = "SELECT sum(p.price) as amount, date_format(p.datep,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " WHERE p.fk_statut in ".$in;
$sql.= " AND p.entity = ".$conf->entity;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
$sql.= " GROUP BY dm DESC";
2003-06-29 11:02:11 +02:00
pt($db, $sql, $langs->trans("Month"));
2003-06-29 11:02:11 +02:00
print '</td><td valign="top">';
$sql = "SELECT sum(p.price) as amount, year(p.datep) as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " WHERE p.fk_statut in ".$in;
$sql.= " AND p.entity = ".$conf->entity;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
$sql.= " GROUP BY dm DESC";
2003-06-29 11:02:11 +02:00
2010-03-27 15:40:39 +01:00
pt($db, $sql, "Ann<EFBFBD>e");
2003-06-29 11:02:11 +02:00
2003-09-16 06:36:16 +02:00
print "<br>";
2003-06-29 11:02:11 +02:00
$sql = "SELECT sum(p.price) as amount, month(p.datep) as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " WHERE p.fk_statut in ".$in;
$sql.= " AND p.entity = ".$conf->entity;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
$sql.= " GROUP BY dm";
2003-06-29 11:02:11 +02:00
2010-03-27 15:40:39 +01:00
pt($db, $sql, "Mois cumul<75>s");
2003-06-29 11:02:11 +02:00
print "</td></tr></table>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>