diff --git a/htdocs/energie/EnergieCompteur.class.php b/htdocs/energie/EnergieCompteur.class.php
new file mode 100644
index 0000000000000000000000000000000000000000..ee791a27f5fea6d284d6081a97337f8ca868c9a0
--- /dev/null
+++ b/htdocs/energie/EnergieCompteur.class.php
@@ -0,0 +1,207 @@
+<?php
+/* Copyright (C) 2005 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$
+ *
+ */
+
+/**
+ \file htdocs/energie/EnergieCompteur.class.php
+ \ingroup energie
+ \brief Fichier des classes de compteur
+ \version $Revision$
+*/
+
+
+/**
+ \class Compteur
+ \brief Classe de gestion des compteurs
+*/
+
+class EnergieCompteur
+{
+ var $db ;
+ var $id ;
+ var $user;
+
+ /** \brief Constructeur
+ */
+ function EnergieCompteur($DB, $user)
+ {
+ $this->db = $DB;
+ $this->user = $user;
+
+ $this->energies[1] = "Electricit�";
+ $this->energies[2] = "Eau";
+ $this->energies[3] = "Gaz naturel";
+
+ $this->couleurs[1] = "gray";
+ $this->couleurs[2] = "blue";
+ $this->couleurs[3] = "yellow";
+ }
+
+
+ /**
+ * Lecture
+ *
+ */
+ function fetch ($id)
+ {
+ $sql = "SELECT c.rowid, c.libelle, fk_energie";
+ $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
+ $sql .= " WHERE c.rowid = ".$id;
+
+ $resql = $this->db->query($sql) ;
+
+ if ( $resql )
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+ $this->libelle = $obj->libelle;
+ $this->energie = $obj->fk_energie;
+ $this->db->free();
+
+ return 0;
+ }
+ else
+ {
+ dolibarr_syslog("");
+ return -1;
+ }
+ }
+
+ /**
+ * Lecture
+ *
+ */
+ function Create ($libelle, $energie)
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur";
+ $sql .= " (libelle, datec, fk_user_author, fk_energie, note)";
+ $sql .= " VALUES (";
+ $sql .= "'".trim($libelle)."'";
+ $sql .= ",now()";
+ $sql .= ",'".$this->user->id."'";
+ $sql .= ",'".$energie."'";
+ $sql .= ",'');";
+
+ $resql = $this->db->query($sql) ;
+
+ if ( $resql )
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur");
+
+ return 0;
+ }
+ else
+ {
+ dolibarr_syslog("EnergieCompteur::Create Erreur 1");
+ dolibarr_syslog($this->db->error());
+ return -1;
+ }
+ }
+
+ /**
+ * Ajout d'une valeur relev�e
+ *
+ */
+ function AjoutReleve ($date_releve, $valeur)
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_releve";
+ $sql .= " (fk_compteur, date_releve, valeur, datec, fk_user_author)";
+ $sql .= " VALUES (";
+ $sql .= "'".$this->id."'";
+ $sql .= ",'".$this->db->idate($date_releve)."'";
+ $sql .= ",'".$valeur."'";
+ $sql .= ",now()";
+ $sql .= ",'".$this->user->id."');";
+
+ $resql = $this->db->query($sql) ;
+
+ if ( $resql )
+ {
+ return 0;
+ }
+ else
+ {
+ dolibarr_syslog("EnergieCompteur::AjoutReleve Erreur 1");
+ dolibarr_syslog($this->db->error());
+ return -1;
+ }
+ }
+ /**
+ * Ajout d'une valeur relev�e
+ *
+ */
+ function AddGroup ($groupe)
+ {
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_groupe";
+ $sql .= " (fk_energie_compteur, fk_energie_groupe)";
+ $sql .= " VALUES ('".$this->id."','".$groupe."');";
+
+ $resql = $this->db->query($sql);
+
+ if ( $resql )
+ {
+ return 0;
+ }
+ else
+ {
+ dolibarr_syslog("EnergieCompteur::AddGroup Erreur 1");
+ dolibarr_syslog($this->db->error());
+ return -1;
+ }
+ }
+ /**
+ *
+ *
+ */
+ function GroupsAvailable ()
+ {
+ $this->groups_available = array();
+
+ $sql = "SELECT g.rowid, g.libelle";
+ $sql .= " FROM ".MAIN_DB_PREFIX."energie_groupe as g";
+
+ $resql = $this->db->query($sql) ;
+
+ if ( $resql )
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->groups_available[$obj->rowid] = $obj->libelle;
+ $i++;
+ }
+ $this->db->free();
+
+ return 0;
+ }
+ else
+ {
+ dolibarr_syslog("");
+ return -1;
+ }
+ }
+}
+?>
diff --git a/htdocs/energie/compteur.php b/htdocs/energie/compteur.php
new file mode 100644
index 0000000000000000000000000000000000000000..6b9d41e575a4abab2e87fdddaed62ae7ad6b9587
--- /dev/null
+++ b/htdocs/energie/compteur.php
@@ -0,0 +1,227 @@
+<?php
+/* Copyright (C) 2005 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$
+ *
+ */
+
+/**
+ \file htdocs/energie/compteur.php
+ \ingroup energie
+ \brief Fiche compteur
+ \version $Revision$
+*/
+
+require("./pre.inc.php");
+
+/*
+ *
+ */
+
+if ($_POST["action"] == 'add')
+{
+ $compteur = new EnergieCompteur($db, $user);
+
+ if ( $compteur->create($_POST["libelle"],$_POST["energie"]) == 0)
+ {
+ Header("Location: compteur.php?id=".$compteur->id);
+ }
+ else
+ {
+ Header("Location: compteur.php?action=create");
+ }
+}
+
+
+if ($_POST["action"] == 'addvalue')
+{
+ if ($_POST["releve"] > 0)
+ {
+ $compteur = new EnergieCompteur($db, $user);
+ if ( $compteur->fetch($_GET["id"]) == 0)
+ {
+ $date = mktime(12,
+ 0 ,
+ 0,
+ $_POST["remonth"],
+ $_POST["reday"],
+ $_POST["reyear"]);
+
+ $compteur->AjoutReleve($date, $_POST["releve"]);
+ Header("Location: compteur.php?id=".$_GET["id"]);
+ }
+ }
+}
+/*
+ *
+ */
+
+llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
+
+/*********************************************************************
+ *
+ * Mode creation
+ *
+ *
+ ************************************************************************/
+if ($_GET["action"] == 'create')
+{
+ $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create';
+ $head[0][1] = "Nouveau compteur";
+ $h++;
+ $a = 0;
+
+ dolibarr_fiche_head($head, $a, $soc->nom);
+
+ $html = new Form($db);
+ $compteur = new EnergieCompteur($db, $user);
+
+ print '<form action="compteur.php" method="post">';
+ print '<input type="hidden" name="action" value="add">';
+
+ print '<table class="border" width="100%">';
+
+ print "<tr $bc[$var]>";
+
+ print '<td>Libell�</td>';
+
+ print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
+
+ print "<tr $bc[$var]>";
+ print '<td>Energie</td><td>';
+ print $html->select_array("energie", $compteur->energies);
+ print '</td></tr>';
+
+ print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
+
+ print "</table></form><br>";
+ print '</div>';
+
+}
+else
+/* *************************************************************************** */
+/* */
+/* Mode vue */
+/* */
+/* *************************************************************************** */
+{
+ if ($_GET["id"] > 0)
+ {
+ $compteur = new EnergieCompteur($db, $user);
+ if ( $compteur->fetch($_GET["id"]) == 0)
+ {
+
+ $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
+ $head[0][1] = "Compteur";
+ $h++;
+ $a = 0;
+
+ $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
+ $head[$h][1] = "Graph";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
+ $head[$h][1] = "Groupe";
+ $h++;
+
+ dolibarr_fiche_head($head, $a, $soc->nom);
+
+
+ print '<table class="border" width="100%">';
+ print "<tr><td>".$langs->trans("Compteur")."</td>";
+ print '<td width="50%">';
+ print $compteur->libelle;
+ print "</td></tr>";
+ print "</table><br>";
+
+
+ $html = new Form($db);
+ print '<form action="compteur.php?id='.$compteur->id.'" method="post">';
+ print '<input type="hidden" name="action" value="addvalue">';
+ print '<table class="border" width="100%">';
+
+ $var=!$var;
+ print "<tr $bc[$var]>";
+
+ print '<td>Date</td><td>';
+ print $html->select_date();
+ print '</td><td>Valeur relev�e</td>';
+
+ print '<td align="center"><input type="text" size="11" maxlength="10" name="releve"></td>';
+
+ print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
+
+ print "</table></form><br>";
+
+ print '</div>';
+
+
+
+ print '<table class="noborder" width="100%">';
+ print '<tr><td align="center">';
+ $file = "week.".$compteur->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td><td align="center">';
+ $file = "month.".$compteur->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td></tr></table><br>';
+
+ print '<table class="noborder" width="100%">';
+ print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
+ print '<td>'.$langs->trans("Relev�").'</td></tr>';
+
+ $sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur";
+ $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr";
+ $sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'";
+ $sql .= " ORDER BY ecr.date_releve DESC LIMIT 5";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+ $var=True;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+ $var=!$var;
+ print "<tr $bc[$var]><td>";
+ print strftime("%a %e %B %Y",$obj->date_releve);
+ print '</td><td>'.$obj->valeur.'</td>';
+
+ $i++;
+ }
+ }
+ print '</table>';
+ print "<br>\n";
+ }
+ else
+ {
+ /* Commande non trouv�e */
+ print "Compteur inexistant";
+ }
+ }
+ else
+ {
+ print "Compteur inexistant";
+ }
+}
+
+$db->close();
+
+llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
+?>
diff --git a/htdocs/energie/compteur_groupe.php b/htdocs/energie/compteur_groupe.php
new file mode 100644
index 0000000000000000000000000000000000000000..0bcf01f9754da39b87cbde0de9d5627c3c68fbb5
--- /dev/null
+++ b/htdocs/energie/compteur_groupe.php
@@ -0,0 +1,114 @@
+<?php
+/* Copyright (C) 2005 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$
+ *
+ */
+
+/**
+ \file htdocs/energie/compteur_groupe.php
+ \ingroup energie
+ \brief Fiche de gestion des groupes des compteurs
+ \version $Revision$
+*/
+
+require("./pre.inc.php");
+
+
+if ($_POST["action"] == 'addvalue')
+{
+ $compteur = new EnergieCompteur($db, $user);
+ if ( $compteur->fetch($_GET["id"]) == 0)
+ {
+ if ( $compteur->AddGroup($_POST["groupe"]) == 0)
+ {
+ Header("Location: compteur.php?id=".$_GET["id"]);
+ }
+ }
+}
+/*
+ *
+ */
+
+llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
+
+if ($_GET["id"] > 0)
+{
+ $compteur = new EnergieCompteur($db, $user);
+ if ( $compteur->fetch($_GET["id"]) == 0)
+ {
+
+ $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
+ $head[0][1] = "Compteur";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
+ $head[$h][1] = "Graph";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
+ $head[$h][1] = "Groupe";
+ $h++;
+ $a = 2;
+
+
+ dolibarr_fiche_head($head, $a, $soc->nom);
+
+
+ print '<table class="border" width="100%">';
+ print "<tr><td>".$langs->trans("Compteur")."</td>";
+ print '<td width="50%">';
+ print $compteur->libelle;
+ print "</td></tr>";
+ print "</table><br>";
+
+ $html = new Form($db);
+ print '<form action="compteur_groupe.php?id='.$compteur->id.'" method="post">';
+ print '<input type="hidden" name="action" value="addvalue">';
+ print '<table class="border" width="100%">';
+
+ $var=!$var;
+ print "<tr $bc[$var]>";
+
+ $compteur->GroupsAvailable();
+
+ print '<td>Groupe</td><td>';
+ print $html->select_array("groupe", $compteur->groups_available);
+ print '</td>';
+
+ print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
+
+ print "</table></form><br>";
+ print '</div>';
+ print "<br>\n";
+ }
+ else
+ {
+ /* Commande non trouv�e */
+ print "Compteur inexistant";
+ }
+}
+else
+{
+ print "Compteur inexistant";
+}
+
+$db->close();
+
+llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
+?>
diff --git a/htdocs/energie/groupe.php b/htdocs/energie/groupe.php
new file mode 100644
index 0000000000000000000000000000000000000000..92ba9e6350e7a0e4df255983ba728b231abae3f6
--- /dev/null
+++ b/htdocs/energie/groupe.php
@@ -0,0 +1,157 @@
+<?php
+/* Copyright (C) 2005 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$
+ *
+ */
+
+/**
+ \file htdocs/energie/groupe.php
+ \ingroup energie
+ \brief Fiche groupe
+ \version $Revision$
+*/
+
+require("./pre.inc.php");
+
+/*
+ *
+ */
+
+if ($_POST["action"] == 'add')
+{
+ $groupe = new EnergieGroupe($db, $user);
+
+ if ( $groupe->create($_POST["libelle"]) == 0)
+ {
+ Header("Location: groupe.php?id=".$groupe->id);
+ }
+ else
+ {
+ Header("Location: groupe.php?action=create");
+ }
+}
+
+/*
+ *
+ */
+
+llxHeader($langs, '',$langs->trans("Groupe"),"Groupe");
+
+/*********************************************************************
+ *
+ * Mode creation
+ *
+ *
+ ************************************************************************/
+if ($_GET["action"] == 'create')
+{
+ $head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?action=create';
+ $head[0][1] = "Nouveau groupe";
+ $h++;
+ $a = 0;
+
+ dolibarr_fiche_head($head, $a, $soc->nom);
+
+ $html = new Form($db);
+
+ print '<form action="groupe.php" method="post">';
+ print '<input type="hidden" name="action" value="add">';
+
+ print '<table class="border" width="100%">';
+ print "<tr $bc[$var]>";
+ print '<td>Libell�</td>';
+
+ print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
+
+ print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
+
+ print "</table></form><br>";
+
+ print '</div>';
+
+}
+else
+/* *************************************************************************** */
+/* */
+/* Mode vue */
+/* */
+/* *************************************************************************** */
+{
+ if ($_GET["id"] > 0)
+ {
+ $groupe = new EnergieGroupe($db, $user);
+ if ( $groupe->fetch($_GET["id"]) == 0)
+ {
+
+ $head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?id='.$commande->id;
+ $head[0][1] = "Groupe";
+ $h++;
+ $a = 0;
+
+ dolibarr_fiche_head($head, $a, $soc->nom);
+
+ print '<table class="border" width="100%">';
+ print "<tr><td>".$langs->trans("Groupe")."</td>";
+ print '<td width="50%">';
+ print $groupe->libelle;
+ print "</td></tr>";
+ print "</table><br>";
+
+ /*
+ *
+ */
+
+
+ print '<table class="noborder" width="100%">';
+
+ print '<tr><td align="center">';
+ $file = "groupe.day.".$groupe->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td><td align="center">';
+ $file = "groupe.week.".$groupe->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td></tr>';
+
+ print '<tr><td align="center">';
+ $file = "groupe.month.".$groupe->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td><td align="center">';
+ $file = "groupe.year.".$groupe->id.".png";
+ print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
+ print '</td></tr></table><br>';
+
+ print '</div>';
+ print "<br>\n";
+ }
+ else
+ {
+ /* Commande non trouv�e */
+ print "Groupe inexistant";
+ }
+ }
+ else
+ {
+ print "Groupe inexistant";
+ }
+}
+
+$db->close();
+
+llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
+?>