Fix on energy module

This commit is contained in:
Laurent Destailleur 2009-07-08 17:12:23 +00:00
parent 4ac98658c3
commit f403449d9a
6 changed files with 412 additions and 392 deletions

View File

@ -21,209 +21,211 @@
*/ */
/** /**
\file htdocs/energie/EnergieCompteur.class.php \file htdocs/energie/EnergieCompteur.class.php
\ingroup energie \ingroup energie
\brief Fichier des classes de compteur \brief Fichier des classes de compteur
\version $Revision$ \version $Revision$
*/ */
/** /**
\class Compteur \class Compteur
\brief Classe de gestion des compteurs \brief Classe de gestion des compteurs
*/ */
class EnergieCompteur class EnergieCompteur
{ {
var $db ; var $db ;
var $id ; var $id ;
var $user; var $user;
/** \brief Constructeur /** \brief Constructeur
*/ */
function EnergieCompteur($DB, $user) function EnergieCompteur($DB, $user)
{ {
$this->db = $DB; global $langs;
$this->user = $user;
$this->energies[1] = "Electricité"; $this->db = $DB;
$this->energies[2] = "Eau"; $this->user = $user;
$this->energies[3] = "Gaz naturel";
$this->couleurs[1] = "gray"; $this->energies[1] = $langs->trans("Electricity");
$this->couleurs[2] = "blue"; $this->energies[2] = $langs->trans("Water");
$this->couleurs[3] = "yellow"; $this->energies[3] = $langs->trans("NaturalGaz");
}
$this->couleurs[1] = "gray";
$this->couleurs[2] = "blue";
$this->couleurs[3] = "yellow";
}
/** /**
* Lecture * Lecture
* *
*/ */
function fetch ($id) function fetch ($id)
{ {
$sql = "SELECT c.rowid, c.libelle, fk_energie"; $sql = "SELECT c.rowid, c.libelle, fk_energie";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c"; $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
$sql .= " WHERE c.rowid = ".$id; $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
{
dol_syslog("");
return -1;
}
}
/** $resql = $this->db->query($sql) ;
* 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 )
{
$obj = $this->db->fetch_object($resql);
if ( $resql ) $this->id = $obj->rowid;
{ $this->libelle = $obj->libelle;
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur"); $this->energie = $obj->fk_energie;
$this->db->free();
return 0; return 0;
} }
else else
{ {
dol_syslog("EnergieCompteur::Create Erreur 1"); dol_syslog("");
dol_syslog($this->db->error()); return -1;
return -1; }
} }
}
/** /**
* Ajout d'une valeur relevée * Lecture
* *
*/ */
function AjoutReleve ($date_releve, $valeur) function Create ($libelle, $energie)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_releve"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur";
$sql .= " (fk_compteur, date_releve, valeur, datec, fk_user_author)"; $sql .= " (libelle, datec, fk_user_author, fk_energie, note)";
$sql .= " VALUES ("; $sql .= " VALUES (";
$sql .= "'".$this->id."'"; $sql .= "'".trim($libelle)."'";
$sql .= ",'".$this->db->idate($date_releve)."'"; $sql .= ",now()";
$sql .= ",'".$valeur."'"; $sql .= ",'".$this->user->id."'";
$sql .= ",now()"; $sql .= ",'".$energie."'";
$sql .= ",'".$this->user->id."');"; $sql .= ",'');";
$resql = $this->db->query($sql) ;
if ( $resql ) $resql = $this->db->query($sql) ;
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Suppression d'une valeur relevée
*
*/
function DeleteReleve ($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."energie_compteur_releve";
$sql .= " WHERE rowid = '".$rowid."';";
$resql = $this->db->query($sql) ;
if ( $resql ) if ( $resql )
{ {
return 0; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur");
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_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;
{ }
return 0; else
} {
else dol_syslog("EnergieCompteur::Create Erreur 1");
{ dol_syslog($this->db->error());
dol_syslog("EnergieCompteur::AddGroup Erreur 1"); return -1;
dol_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"; * Ajout d'une valeur relev<EFBFBD>e
*
$resql = $this->db->query($sql) ; */
function AjoutReleve ($date_releve, $valeur)
if ( $resql ) {
{ $sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_releve";
$num = $this->db->num_rows($resql); $sql .= " (fk_compteur, date_releve, valeur, datec, fk_user_author)";
$i = 0; $sql .= " VALUES (";
$sql .= "'".$this->id."'";
$sql .= ",'".$this->db->idate($date_releve)."'";
$sql .= ",'".$valeur."'";
$sql .= ",now()";
$sql .= ",'".$this->user->id."');";
while ($i < $num) $resql = $this->db->query($sql) ;
if ( $resql )
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Suppression d'une valeur relev<EFBFBD>e
*
*/
function DeleteReleve ($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."energie_compteur_releve";
$sql .= " WHERE rowid = '".$rowid."';";
$resql = $this->db->query($sql) ;
if ( $resql )
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Ajout d'une valeur relev<EFBFBD>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
{
dol_syslog("EnergieCompteur::AddGroup Erreur 1");
dol_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); $obj = $this->db->fetch_object($resql);
$this->groups_available[$obj->rowid] = $obj->libelle; $this->groups_available[$obj->rowid] = $obj->libelle;
$i++; $i++;
} }
$this->db->free(); $this->db->free();
return 0; return 0;
} }
else else
{ {
dol_syslog(""); dol_syslog("");
return -1; return -1;
} }
} }
} }
?> ?>

View File

@ -21,17 +21,17 @@
*/ */
/** /**
\file htdocs/energie/compteur.php * \file htdocs/energie/compteur.php
\ingroup energie * \ingroup energie
\brief Fiche compteur * \brief Fiche compteur
\version $Revision$ * \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
/* /*
* * Actions
*/ */
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
@ -55,21 +55,24 @@ if ($_POST["action"] == 'addvalue')
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) if ( $compteur->fetch($_GET["id"]) == 0)
{ {
$date = mktime(12, $date = mktime(12,
0 , 0 ,
0, 0,
$_POST["remonth"], $_POST["remonth"],
$_POST["reday"], $_POST["reday"],
$_POST["reyear"]); $_POST["reyear"]);
$compteur->AjoutReleve($date, $_POST["releve"]); $compteur->AjoutReleve($date, $_POST["releve"]);
Header("Location: compteur.php?id=".$_GET["id"]); Header("Location: compteur.php?id=".$_GET["id"]);
} }
} }
} }
/* /*
* * Views
*/ */
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
@ -77,9 +80,8 @@ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
* *
* Mode creation * Mode creation
* *
*
************************************************************************/ ************************************************************************/
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create'; $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create';
$head[0][1] = "Nouveau compteur"; $head[0][1] = "Nouveau compteur";
@ -94,84 +96,84 @@ if ($_GET["action"] == 'create')
print '<form action="compteur.php" method="post">'; print '<form action="compteur.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>Libellé</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>'; print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>Energie</td><td>'; print '<td>Energie</td><td>';
print $html->select_array("energie", $compteur->energies); print $html->select_array("energie", $compteur->energies);
print '</td></tr>'; print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'" class="button"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'" class="button"></td></tr>';
print "</table></form>"; print "</table></form>";
print '</div>'; print '</div>';
} }
else else
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
/* Mode vue */ /* Mode vue */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
{ {
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) if ( $compteur->fetch($_GET["id"]) == 0)
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id; $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = "Compteur"; $head[0][1] = $langs->trans("Compteur");
$h++; $h++;
$a = 0; $a = 0;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = "Graph"; $head[$h][1] = $langs->trans("Graph");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = "Relevés"; $head[$h][1] = $langs->trans("Releves");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = "Groupe"; $head[$h][1] = $langs->trans("Groups");
$h++; $h++;
dol_fiche_head($head, $a, $soc->nom); dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>"; print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">'; print '<td width="50%">';
print $compteur->libelle; print $compteur->libelle;
print "</td></tr>"; print "</td></tr>";
print "</table><br>"; print "</table><br>";
$html = new Form($db); $html = new Form($db);
print '<form name="addvalue" action="compteur.php?id='.$compteur->id.'" method="post">'; print '<form name="addvalue" action="compteur.php?id='.$compteur->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addvalue">'; print '<input type="hidden" name="action" value="addvalue">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>Date</td><td>'; print '<td>Date</td><td>';
print $html->select_date('','','','','',"addvalue"); print $html->select_date('','','','','',"addvalue");
print '</td><td>Valeur relevée</td>'; print '</td><td>Valeur relevee</td>';
print '<td align="center"><input type="text" size="11" maxlength="10" name="releve"></td>'; print '<td align="center"><input type="text" size="11" maxlength="10" name="releve"></td>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>'; print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print "</table></form><br>"; print "</table></form><br>";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr><td><a href="compteur_graph.php?id='.$compteur->id.'">'; print '<tr><td><a href="compteur_graph.php?id='.$compteur->id.'">';
$file = "all.".$compteur->id.".png"; $file = "all.".$compteur->id.".png";
@ -182,8 +184,8 @@ else
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Relevé").'</td></tr>'; print '<td>'.$langs->trans("Releve").'</td></tr>';
$sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur"; $sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr"; $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr";
$sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'"; $sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'";
@ -210,10 +212,10 @@ else
} }
else else
{ {
/* Commande non trouvée */ /* Commande non trouv<EFBFBD>e */
print "Compteur inexistant"; print "Compteur inexistant";
} }
} }
else else
{ {
print "Compteur inexistant"; print "Compteur inexistant";
@ -222,5 +224,5 @@ else
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -14,13 +14,22 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* */
* $Id$
* $Source$ /**
* * \file htdocs/energie/compteur_graph.php
* \ingroup energie
* \brief Fiche de gestion des graphs des compteurs
* \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
/*
* View
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
/* *************************************************************************** */ /* *************************************************************************** */
@ -28,50 +37,50 @@ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
/* Mode vue */ /* Mode vue */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) if ( $compteur->fetch($_GET["id"]) == 0)
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id; $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = "Compteur"; $head[0][1] = $langs->trans("Compteur");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = "Graph"; $head[$h][1] = $langs->trans("Graph");
$a = $h; $a = $h;
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = "Relevés"; $head[$h][1] = $langs->trans("Releves");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = "Groupe"; $head[$h][1] = $langs->trans("Groups");
$h++; $h++;
dol_fiche_head($head, $a, $soc->nom); dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>"; print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">'; print '<td width="50%">';
print $compteur->libelle; print $compteur->libelle;
print "</td></tr>"; print "</td></tr>";
print "</table><br>"; print "</table><br>";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
$file = "day.".$compteur->id.".png"; $file = "day.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
$file = "week.".$compteur->id.".png"; $file = "week.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "month.".$compteur->id.".png"; $file = "month.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
@ -83,10 +92,10 @@ if ($_GET["id"] > 0)
} }
else else
{ {
/* Compteur non trouvée */ /* Compteur non trouv<EFBFBD>e */
print "Compteur inexistant"; print "Compteur inexistant";
} }
} }
else else
{ {
print "Compteur inexistant"; print "Compteur inexistant";

View File

@ -14,102 +14,105 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/ */
/** /**
\file htdocs/energie/compteur_groupe.php * \file htdocs/energie/compteur_groupe.php
\ingroup energie * \ingroup energie
\brief Fiche de gestion des groupes des compteurs * \brief Fiche de gestion des groupes des compteurs
\version $Revision$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
/*
* Actions
*/
if ($_POST["action"] == 'addvalue') if ($_POST["action"] == 'addvalue')
{ {
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) if ( $compteur->fetch($_GET["id"]) == 0)
{
if ( $compteur->AddGroup($_POST["groupe"]) == 0)
{ {
if ( $compteur->AddGroup($_POST["groupe"]) == 0)
{
Header("Location: compteur.php?id=".$_GET["id"]); Header("Location: compteur.php?id=".$_GET["id"]);
}
} }
}
} }
/* /*
* * View
*/ */
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) 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/releve.php?id='.$compteur->id; $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[$h][1] = "Relevés"; $head[0][1] = $langs->trans("Compteur");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = "Groupe"; $head[$h][1] = $langs->trans("Graph");
$a = $h; $h++;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
dol_fiche_head($head, $a, $soc->nom); $head[$h][1] = $langs->trans("Releves");
$h++;
print '<table class="border" width="100%">'; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
print "<tr><td>".$langs->trans("Compteur")."</td>"; $head[$h][1] = $langs->trans("Groups");
print '<td width="50%">'; $a = $h;
print $compteur->libelle; $h++;
print "</td></tr>";
print "</table><br>"; dol_fiche_head($head, $a, $soc->nom);
$html = new Form($db);
print '<form action="compteur_groupe.php?id='.$compteur->id.'" method="post">'; print '<table class="border" width="100%">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<input type="hidden" name="action" value="addvalue">'; print '<td width="50%">';
print '<table class="border" width="100%">'; print $compteur->libelle;
print "</td></tr>";
$var=!$var; print "</table><br>";
print "<tr $bc[$var]>";
$html = new Form($db);
$compteur->GroupsAvailable(); print '<form action="compteur_groupe.php?id='.$compteur->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<td>Groupe</td><td>'; print '<input type="hidden" name="action" value="addvalue">';
print $html->select_array("groupe", $compteur->groups_available); print '<table class="border" width="100%">';
print '</td>';
$var=!$var;
print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>'; print "<tr $bc[$var]>";
print "</table></form><br>"; $compteur->GroupsAvailable();
print '</div>';
print "<br>\n"; print '<td>Groupe</td><td>';
} print $html->select_array("groupe", $compteur->groups_available);
else print '</td>';
{
/* Commande non trouvée */ print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
print "Compteur inexistant";
} print "</table></form><br>";
} print '</div>';
print "<br>\n";
}
else
{
/* Commande non trouv<75>e */
print "Compteur inexistant";
}
}
else else
{ {
print "Compteur inexistant"; print "Compteur inexistant";
} }
$db->close(); $db->close();

View File

@ -21,17 +21,17 @@
*/ */
/** /**
\file htdocs/energie/groupe.php * \file htdocs/energie/groupe.php
\ingroup energie * \ingroup energie
\brief Fiche groupe * \brief Fiche groupe
\version $Revision$ * \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
/* /*
* * Actions
*/ */
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
@ -47,11 +47,12 @@ if ($_POST["action"] == 'add')
} }
} }
/*
*
*/
llxHeader($langs, '',$langs->trans("Groupe"),"Groupe"); /*
* View
*/
llxHeader($langs, '',$langs->trans("Group"), "Group");
/********************************************************************* /*********************************************************************
* *
@ -59,10 +60,10 @@ llxHeader($langs, '',$langs->trans("Groupe"),"Groupe");
* *
* *
************************************************************************/ ************************************************************************/
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?action=create'; $head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?action=create';
$head[0][1] = "Nouveau groupe"; $head[0][1] = $langs->trans("NewGroup");
$h++; $h++;
$a = 0; $a = 0;
@ -73,50 +74,50 @@ if ($_GET["action"] == 'create')
print '<form action="groupe.php" method="post">'; print '<form action="groupe.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>Libellé</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>'; print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print "</table></form>"; print "</table></form>";
print '</div>'; print '</div>';
} }
else else
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
/* Mode vue */ /* Mode vue */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
{ {
if ($_GET["id"] > 0) if ($_GET["id"] > 0)
{ {
$groupe = new EnergieGroupe($db, $user); $groupe = new EnergieGroupe($db, $user);
if ( $groupe->fetch($_GET["id"]) == 0) if ( $groupe->fetch($_GET["id"]) == 0)
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?id='.$commande->id; $head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?id='.$commande->id;
$head[0][1] = "Groupe"; $head[0][1] = $langs->trans("Group");
$h++; $h++;
$a = 0; $a = 0;
dol_fiche_head($head, $a, $soc->nom); dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Groupe")."</td>"; print "<tr><td>".$langs->trans("Group")."</td>";
print '<td width="50%">'; print '<td width="50%">';
print $groupe->libelle; print $groupe->libelle;
print "</td></tr>"; print "</td></tr>";
print "</table><br>"; print "</table><br>";
/* /*
* *
*/ */
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -137,15 +138,15 @@ else
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr></table><br>'; print '</td></tr></table><br>';
print '</div>'; print '</div>';
print "<br>\n"; print "<br>\n";
} }
else else
{ {
/* Commande non trouvée */ /* Commande non trouv<EFBFBD>e */
print "Groupe inexistant"; print "Groupe inexistant";
} }
} }
else else
{ {
print "Groupe inexistant"; print "Groupe inexistant";

View File

@ -21,17 +21,18 @@
*/ */
/** /**
\file htdocs/energie/compteur.php * \file htdocs/energie/compteur.php
\ingroup energie * \ingroup energie
\brief Fiche compteur * \brief Fiche compteur
\version $Revision$ * \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
/* /*
* * Actions
*/ */
if ($_GET["action"] == 'delete') if ($_GET["action"] == 'delete')
{ {
@ -44,9 +45,11 @@ if ($_GET["action"] == 'delete')
} }
} }
} }
/* /*
* * View
*/ */
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
@ -55,59 +58,59 @@ if ($_GET["id"] > 0)
{ {
$compteur = new EnergieCompteur($db, $user); $compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0) if ( $compteur->fetch($_GET["id"]) == 0)
{ {
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id; $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = "Compteur"; $head[0][1] = $langs->trans("Compteur");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = "Graph"; $head[$h][1] = $langs->trans("Graph");
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = "Relevés"; $head[$h][1] = $langs->trans("Releves");
$h++; $h++;
$a = 2; $a = 2;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = "Groupe"; $head[$h][1] = $langs->trans("Groups");
$h++; $h++;
dol_fiche_head($head, $a, $soc->nom); dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>"; print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">'; print '<td width="50%">';
print $compteur->libelle; print $compteur->libelle;
print "</td></tr>"; print "</td></tr>";
print "</table><br>"; print "</table><br>";
print '</div>'; print '</div>';
$page = $_GET["page"]; $page = $_GET["page"];
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
$sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur, rowid"; $sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur, rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr"; $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr";
$sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'"; $sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'";
$sql .= " ORDER BY ecr.date_releve DESC"; $sql .= " ORDER BY ecr.date_releve DESC";
$sql .= $db->plimit($limit + 1 ,$offset); $sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$var=True; $var=True;
print_barre_liste("Relevés", $page, "", "&amp;id=".$compteur->id, $sortfield, $sortorder,'',$num); print_barre_liste("Releves", $page, "", "&amp;id=".$compteur->id, $sortfield, $sortorder,'',$num, 0, '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
print '<td colspan="2">'.$langs->trans("Relevé").'</td></tr>'; print '<td colspan="2">'.$langs->trans("Releve").'</td></tr>';
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
@ -125,10 +128,10 @@ if ($_GET["id"] > 0)
} }
else else
{ {
/* Commande non trouvée */ /* Commande non trouv<EFBFBD>e */
print "Compteur inexistant"; print "Compteur inexistant";
} }
} }
else else
{ {
print "Compteur inexistant"; print "Compteur inexistant";