Nouveau fichier
This commit is contained in:
parent
7c61cd03d2
commit
c0d339b744
95
htdocs/rapport/AtomeFactureValidee.class.php
Normal file
95
htdocs/rapport/AtomeFactureValidee.class.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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$
|
||||
*
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/rapport/Atome.class.php');
|
||||
|
||||
class AtomeFactureValidee extends Atome
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $periode;
|
||||
|
||||
/**
|
||||
* Initialisation de la classe
|
||||
*
|
||||
*/
|
||||
Function AtomeFactureValidee($DB, $periode, $daystart)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->name = 'AtomeFactureValidee';
|
||||
$this->AtomeInitialize($periode,'AtomeFactureValidee', $daystart);
|
||||
$this->datas = array();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
Function fetch()
|
||||
{
|
||||
if ($this->periode == 'year')
|
||||
{
|
||||
$sql = "SELECT date_format(f.datef,'%Y%m'), sum(f.amount) as am";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.fk_statut = 1";
|
||||
|
||||
$sql .= " AND date_format(f.datef,'%Y') = $this->year ";
|
||||
$sql .= " GROUP BY date_format(f.datef,'%Y%m') ASC ;";
|
||||
}
|
||||
|
||||
if ($this->periode == 'month')
|
||||
{
|
||||
$sql = "SELECT date_format(f.datef,'%Y%m%d'), sum(f.amount) as am";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.fk_statut = 1";
|
||||
$sql .= " AND date_format(f.datef,'%Y%m') = ".$this->year.$this->month;
|
||||
$sql .= " GROUP BY date_format(f.datef,'%Y%m%d') ASC ;";
|
||||
}
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows();
|
||||
$arr = array();
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_row($i);
|
||||
|
||||
$arr[$row[0]] = $row[1];
|
||||
//print $row[0] .'-'.$row[1]. '<br>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->free();
|
||||
$this->datas = $arr;
|
||||
return $arr;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print "<br>$sql";
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
101
htdocs/rapport/index.php
Normal file
101
htdocs/rapport/index.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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");
|
||||
|
||||
require("./AtomeFactureValidee.class.php");
|
||||
require("./AtomePropaleValidee.class.php");
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_fiche_titre("Rapports");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialisation d'un atome
|
||||
*
|
||||
* Parametre
|
||||
* - id de connexion à la bdd
|
||||
* - période 'year' ou 'month' (Reste à faire les hebdo)
|
||||
* - une date dans la période voulue
|
||||
* -> retourne un objet
|
||||
*
|
||||
*/
|
||||
$x = new AtomeFactureValidee($db,'year', time());
|
||||
|
||||
/*
|
||||
* Lecture des données
|
||||
* -> retourne un tableau
|
||||
*/
|
||||
$arr = $x->fetch();
|
||||
/*
|
||||
* Création du graph
|
||||
* -> retounre le nom du fichier
|
||||
*/
|
||||
$img = $x->BarGraph();
|
||||
print $img."<br>";
|
||||
|
||||
|
||||
//
|
||||
|
||||
$x = new AtomeFactureValidee($db,'year', mktime(12,0,0,1,12,2003));
|
||||
$arr = $x->fetch('year');
|
||||
|
||||
$img = $x->BarGraph();
|
||||
print $img."<br>";
|
||||
for ($i = 1 ; $i < 5; $i++)
|
||||
{
|
||||
$x = new AtomeFactureValidee($db,'month', mktime(12,0,0,$i,12,2003));
|
||||
$x->periode = 'month';
|
||||
|
||||
$arr = $x->fetch('month');
|
||||
|
||||
|
||||
$img = $x->BarGraph();
|
||||
print $img."<br>";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
$x = new AtomePropaleValidee($db,'year',mktime(12,0,0,1,12,2003));
|
||||
|
||||
$arr = $x->fetch();
|
||||
|
||||
var_dump($arr);
|
||||
|
||||
$img = $x->BarGraph();
|
||||
print $img."<br>";
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user