diff --git a/htdocs/energie/graph.php b/htdocs/energie/graph.php
index aa2320dadb1..36e4c805bc9 100644
--- a/htdocs/energie/graph.php
+++ b/htdocs/energie/graph.php
@@ -57,82 +57,68 @@ if ($_POST["action"] == 'addvalue')
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
-$html = new Form($db);
-
-/*********************************************************************
- *
- * Mode creation
- *
- *
- ************************************************************************/
-if ($_GET["action"] == 'create')
+if ($_GET["period"] == '')
{
- print_titre("Ajouter une compteur");
+ $period = "day";
+}
+else
+{
+ $period = $_GET["period"];
+}
-}
-else
-/* *************************************************************************** */
-/* */
-/* Mode vue */
-/* */
-/* *************************************************************************** */
-{
- if ($_GET["id"] > 0)
+$head[0][0] = DOL_URL_ROOT.'/energie/graph.php?period=day';
+$head[0][1] = $langs->trans("Day");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=week';
+$head[$h][1] = $langs->trans("Week");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=month';
+$head[$h][1] = $langs->trans("Month");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=year';
+$head[$h][1] = $langs->trans("Year");
+$h++;
+
+$as["day"] = 0;
+$as["week"] = 1;
+$as["month"] = 2;
+$as["year"] = 3;
+
+dolibarr_fiche_head($head, $as[$period], $soc->nom);
+
+print '
';
+
+$sql = "SELECT c.rowid, c.libelle";
+$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
+$sql .= " ORDER BY c.libelle DESC";
+$resql = $db->query($sql);
+if ( $resql)
+{
+ $num = $db->num_rows($resql);
+ if ($num)
{
- $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/graph.php?id='.$compteur->id;
- $head[$h][1] = "Graph";
- $a = 1;
-
- dolibarr_fiche_head($head, $a, $soc->nom);
-
- print '';
- print "| ".$langs->trans("Compteur")." | ";
- print '';
- print $compteur->libelle;
- print " |
";
- print "
";
+ $i = 0;
+
+ $var = True;
+ while ($i < $num)
+ {
+ $var=!$var;
+ $obj = $db->fetch_object($resql);
- print '';
-
-
- print '';
-
print '';
- $file = "day.".$compteur->id.".png";
- print ' ';
- print ' | ';
- $file = "week.".$compteur->id.".png";
+ $file = $period.".".$obj->rowid.".png";
print ' ';
print ' |
';
-
- print '';
- $file = "month.".$compteur->id.".png";
- print ' ';
- print ' | ';
- $file = "year.".$compteur->id.".png";
- print ' ';
- print ' |
';
-
- print "
\n";
+
+ $i++;
}
- else
- {
- /* Commande non trouvée */
- print "Compteur inexistant";
- }
- }
- else
- {
- print "Compteur inexistant";
+
}
}
+print '
';
$db->close();