From f403449d9a2856beeef28e1c23ec34d202816fe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Jul 2009 17:12:23 +0000 Subject: [PATCH] Fix on energy module --- htdocs/energie/EnergieCompteur.class.php | 366 ++++++++++++----------- htdocs/energie/compteur.php | 98 +++--- htdocs/energie/compteur_graph.php | 55 ++-- htdocs/energie/compteur_groupe.php | 149 ++++----- htdocs/energie/groupe.php | 69 ++--- htdocs/energie/releve.php | 67 +++-- 6 files changed, 412 insertions(+), 392 deletions(-) diff --git a/htdocs/energie/EnergieCompteur.class.php b/htdocs/energie/EnergieCompteur.class.php index bcb94c6d6c0..5d2ffed8774 100644 --- a/htdocs/energie/EnergieCompteur.class.php +++ b/htdocs/energie/EnergieCompteur.class.php @@ -21,209 +21,211 @@ */ /** - \file htdocs/energie/EnergieCompteur.class.php - \ingroup energie - \brief Fichier des classes de compteur - \version $Revision$ -*/ + \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 Compteur + \brief Classe de gestion des compteurs + */ class EnergieCompteur { - var $db ; - var $id ; - var $user; + var $db ; + var $id ; + var $user; - /** \brief Constructeur - */ - function EnergieCompteur($DB, $user) - { - $this->db = $DB; - $this->user = $user; + /** \brief Constructeur + */ + function EnergieCompteur($DB, $user) + { + global $langs; - $this->energies[1] = "Electricité"; - $this->energies[2] = "Eau"; - $this->energies[3] = "Gaz naturel"; + $this->db = $DB; + $this->user = $user; - $this->couleurs[1] = "gray"; - $this->couleurs[2] = "blue"; - $this->couleurs[3] = "yellow"; - } + $this->energies[1] = $langs->trans("Electricity"); + $this->energies[2] = $langs->trans("Water"); + $this->energies[3] = $langs->trans("NaturalGaz"); + + $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 - { - dol_syslog(""); - return -1; - } - } + /** + * 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; - /** - * 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) ; - $resql = $this->db->query($sql) ; + if ( $resql ) + { + $obj = $this->db->fetch_object($resql); - if ( $resql ) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur"); + $this->id = $obj->rowid; + $this->libelle = $obj->libelle; + $this->energie = $obj->fk_energie; + $this->db->free(); - return 0; - } - else - { - dol_syslog("EnergieCompteur::Create Erreur 1"); - dol_syslog($this->db->error()); - return -1; - } - } + return 0; + } + else + { + dol_syslog(""); + 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) ; + /** + * 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 .= ",'');"; - if ( $resql ) - { - 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) ; + $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é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 ) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur"); - if ( $resql ) - { - return 0; - } - else - { - dol_syslog("EnergieCompteur::AddGroup Erreur 1"); - dol_syslog($this->db->error()); - return -1; - } - } - /** - * - * - */ - function GroupsAvailable () - { - $this->groups_available = array(); + return 0; + } + else + { + dol_syslog("EnergieCompteur::Create Erreur 1"); + dol_syslog($this->db->error()); + return -1; + } + } - $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; + /** + * 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."');"; - 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�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�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); - - $this->groups_available[$obj->rowid] = $obj->libelle; - $i++; + $obj = $this->db->fetch_object($resql); + + $this->groups_available[$obj->rowid] = $obj->libelle; + $i++; } - $this->db->free(); - - return 0; - } - else - { - dol_syslog(""); - return -1; - } - } + $this->db->free(); + + return 0; + } + else + { + dol_syslog(""); + return -1; + } + } } ?> diff --git a/htdocs/energie/compteur.php b/htdocs/energie/compteur.php index 8bb55f5db9f..6015caaee3c 100644 --- a/htdocs/energie/compteur.php +++ b/htdocs/energie/compteur.php @@ -21,17 +21,17 @@ */ /** - \file htdocs/energie/compteur.php - \ingroup energie - \brief Fiche compteur - \version $Revision$ -*/ + * \file htdocs/energie/compteur.php + * \ingroup energie + * \brief Fiche compteur + * \version $Revision$ + */ require("./pre.inc.php"); /* - * - */ + * Actions + */ if ($_POST["action"] == 'add') { @@ -55,21 +55,24 @@ if ($_POST["action"] == 'addvalue') $compteur = new EnergieCompteur($db, $user); if ( $compteur->fetch($_GET["id"]) == 0) { - $date = mktime(12, - 0 , - 0, - $_POST["remonth"], - $_POST["reday"], + $date = mktime(12, + 0 , + 0, + $_POST["remonth"], + $_POST["reday"], $_POST["reyear"]); - + $compteur->AjoutReleve($date, $_POST["releve"]); Header("Location: compteur.php?id=".$_GET["id"]); } } } + + + /* - * - */ + * Views + */ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); @@ -77,9 +80,8 @@ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); * * Mode creation * - * ************************************************************************/ -if ($_GET["action"] == 'create') +if ($_GET["action"] == 'create') { $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create'; $head[0][1] = "Nouveau compteur"; @@ -94,84 +96,84 @@ if ($_GET["action"] == 'create') print '
'; print ''; print ''; - + print ''; print ""; - - print ''; - + + print ''; + print ''; - + print ""; print ''; print ''; - - print "
Libellé'.$langs->trans("Label").'
Energie'; print $html->select_array("energie", $compteur->energies); print '
"; + + print ""; print ''; - -} -else + +} +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"; + $head[0][1] = $langs->trans("Compteur"); $h++; $a = 0; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; - $head[$h][1] = "Graph"; + $head[$h][1] = $langs->trans("Graph"); $h++; $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; - $head[$h][1] = "Relevés"; + $head[$h][1] = $langs->trans("Releves"); $h++; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; - $head[$h][1] = "Groupe"; + $head[$h][1] = $langs->trans("Groups"); $h++; dol_fiche_head($head, $a, $soc->nom); - - + + print ''; print ""; print '"; + print ""; print "
".$langs->trans("Compteur")."'; print $compteur->libelle; - print "

"; - - + + $html = new Form($db); print '
'; print ''; print ''; - print ''; + print '
'; $var=!$var; print ""; - + print ''; + print ''; print ''; print ''; print "
Date'; print $html->select_date('','','','','',"addvalue"); - print 'Valeur relevéeValeur relevee

"; - + print ''; print '
'; $file = "all.".$compteur->id.".png"; @@ -182,8 +184,8 @@ else print ''; print ''; - print ''; - + print ''; + $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."'"; @@ -210,10 +212,10 @@ else } else { - /* Commande non trouvée */ + /* Commande non trouv�e */ print "Compteur inexistant"; } - } + } else { print "Compteur inexistant"; @@ -222,5 +224,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/energie/compteur_graph.php b/htdocs/energie/compteur_graph.php index 46f6fabc15d..1cea34103f0 100644 --- a/htdocs/energie/compteur_graph.php +++ b/htdocs/energie/compteur_graph.php @@ -14,13 +14,22 @@ * 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_graph.php + * \ingroup energie + * \brief Fiche de gestion des graphs des compteurs + * \version $Id$ */ require("./pre.inc.php"); + + +/* + * View + */ + llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); /* *************************************************************************** */ @@ -28,50 +37,50 @@ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); /* 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"; + $head[0][1] = $langs->trans("Compteur"); $h++; - + $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; $h++; - + $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; - $head[$h][1] = "Relevés"; + $head[$h][1] = $langs->trans("Releves"); $h++; - + $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; - $head[$h][1] = "Groupe"; + $head[$h][1] = $langs->trans("Groups"); $h++; - - dol_fiche_head($head, $a, $soc->nom); - + + dol_fiche_head($head, $a, $soc->nom); + print '
'.$langs->trans("Date").''.$langs->trans("Relevé").'
'.$langs->trans("Releve").'
'; print ""; print '"; + print ""; print "
".$langs->trans("Compteur")."'; print $compteur->libelle; - print "

"; - + print ''; - + print ''; - + print ''; - + print '
'; $file = "day.".$compteur->id.".png"; print ''; print '
'; $file = "week.".$compteur->id.".png"; print ''; print '
'; $file = "month.".$compteur->id.".png"; print ''; @@ -83,10 +92,10 @@ if ($_GET["id"] > 0) } else { - /* Compteur non trouvée */ + /* Compteur non trouv�e */ print "Compteur inexistant"; } -} +} else { print "Compteur inexistant"; diff --git a/htdocs/energie/compteur_groupe.php b/htdocs/energie/compteur_groupe.php index b0a328d86f3..e4a7ce0fbee 100644 --- a/htdocs/energie/compteur_groupe.php +++ b/htdocs/energie/compteur_groupe.php @@ -14,102 +14,105 @@ * 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$ -*/ + * \file htdocs/energie/compteur_groupe.php + * \ingroup energie + * \brief Fiche de gestion des groupes des compteurs + * \version $Id$ + */ require("./pre.inc.php"); +/* + * Actions + */ + if ($_POST["action"] == 'addvalue') { - $compteur = new EnergieCompteur($db, $user); - if ( $compteur->fetch($_GET["id"]) == 0) - { - if ( $compteur->AddGroup($_POST["groupe"]) == 0) + $compteur = new EnergieCompteur($db, $user); + if ( $compteur->fetch($_GET["id"]) == 0) { + if ( $compteur->AddGroup($_POST["groupe"]) == 0) + { Header("Location: compteur.php?id=".$_GET["id"]); + } } - } } + + + /* - * - */ + * View + */ 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++; + $compteur = new EnergieCompteur($db, $user); + if ( $compteur->fetch($_GET["id"]) == 0) + { - $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; - $head[$h][1] = "Relevés"; - $h++; + $head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id; + $head[0][1] = $langs->trans("Compteur"); + $h++; - $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; - $head[$h][1] = "Groupe"; - $a = $h; - $h++; - - dol_fiche_head($head, $a, $soc->nom); - - - print ''; - print ""; - print '"; - print "
".$langs->trans("Compteur")."'; - print $compteur->libelle; - print "

"; - - $html = new Form($db); - print '
'; - print ''; - print ''; - print ''; - - $var=!$var; - print ""; - - $compteur->GroupsAvailable(); - - print ''; - - print ''; - - print "
Groupe'; - print $html->select_array("groupe", $compteur->groups_available); - print '

"; - print ''; - print "
\n"; - } - else - { - /* Commande non trouvée */ - print "Compteur inexistant"; - } -} + $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; + $head[$h][1] = $langs->trans("Graph"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; + $head[$h][1] = $langs->trans("Releves"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; + $head[$h][1] = $langs->trans("Groups"); + $a = $h; + $h++; + + dol_fiche_head($head, $a, $soc->nom); + + + print ''; + print ""; + print '"; + print "
".$langs->trans("Compteur")."'; + print $compteur->libelle; + print "

"; + + $html = new Form($db); + print '
'; + print ''; + print ''; + print ''; + + $var=!$var; + print ""; + + $compteur->GroupsAvailable(); + + print ''; + + print ''; + + print "
Groupe'; + print $html->select_array("groupe", $compteur->groups_available); + print '

"; + print ''; + print "
\n"; + } + else + { + /* Commande non trouv�e */ + print "Compteur inexistant"; + } +} else { - print "Compteur inexistant"; + print "Compteur inexistant"; } $db->close(); diff --git a/htdocs/energie/groupe.php b/htdocs/energie/groupe.php index d4920b19bf8..071e053bd70 100644 --- a/htdocs/energie/groupe.php +++ b/htdocs/energie/groupe.php @@ -21,17 +21,17 @@ */ /** - \file htdocs/energie/groupe.php - \ingroup energie - \brief Fiche groupe - \version $Revision$ -*/ + * \file htdocs/energie/groupe.php + * \ingroup energie + * \brief Fiche groupe + * \version $Revision$ + */ require("./pre.inc.php"); /* - * - */ + * Actions + */ 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][1] = "Nouveau groupe"; + $head[0][1] = $langs->trans("NewGroup"); $h++; $a = 0; @@ -73,50 +74,50 @@ if ($_GET["action"] == 'create') print '
'; print ''; print ''; - + print ''; print ""; - print ''; - + print ''; + print ''; - + print ''; - + print "
Libellé'.$langs->trans("Label").'
"; - + print ''; - -} -else + +} +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"; + $head[0][1] = $langs->trans("Group"); $h++; $a = 0; dol_fiche_head($head, $a, $soc->nom); - + print ''; - print ""; + print ""; print '"; + print ""; print "
".$langs->trans("Groupe")."
".$langs->trans("Group")."'; print $groupe->libelle; - print "

"; - + /* * - */ + */ print ''; @@ -137,15 +138,15 @@ else print ''; print '

'; - print ''; + print ''; print "
\n"; } else { - /* Commande non trouvée */ + /* Commande non trouv�e */ print "Groupe inexistant"; } - } + } else { print "Groupe inexistant"; diff --git a/htdocs/energie/releve.php b/htdocs/energie/releve.php index c2f17fdc9e8..2b7cfd63bf8 100644 --- a/htdocs/energie/releve.php +++ b/htdocs/energie/releve.php @@ -21,17 +21,18 @@ */ /** - \file htdocs/energie/compteur.php - \ingroup energie - \brief Fiche compteur - \version $Revision$ -*/ + * \file htdocs/energie/compteur.php + * \ingroup energie + * \brief Fiche compteur + * \version $Revision$ + */ require("./pre.inc.php"); + /* - * - */ + * Actions + */ if ($_GET["action"] == 'delete') { @@ -44,9 +45,11 @@ if ($_GET["action"] == 'delete') } } } + + /* - * - */ + * View + */ llxHeader($langs, '',$langs->trans("Compteur"),"Compteur"); @@ -55,59 +58,59 @@ 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"; + $head[0][1] = $langs->trans("Compteur"); $h++; - + $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id; - $head[$h][1] = "Graph"; + $head[$h][1] = $langs->trans("Graph"); $h++; - + $head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id; - $head[$h][1] = "Relevés"; + $head[$h][1] = $langs->trans("Releves"); $h++; $a = 2; $head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id; - $head[$h][1] = "Groupe"; + $head[$h][1] = $langs->trans("Groups"); $h++; - + dol_fiche_head($head, $a, $soc->nom); - + print ''; print ""; print '"; + print ""; print "
".$langs->trans("Compteur")."'; print $compteur->libelle; - print "

"; print ''; - - $page = $_GET["page"]; + + $page = $_GET["page"]; $limit = $conf->liste_limit; $offset = $limit * $page ; - + $sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur, rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr"; $sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'"; - + $sql .= " ORDER BY ecr.date_releve DESC"; $sql .= $db->plimit($limit + 1 ,$offset); - + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $var=True; - - print_barre_liste("Relevés", $page, "", "&id=".$compteur->id, $sortfield, $sortorder,'',$num); - + + print_barre_liste("Releves", $page, "", "&id=".$compteur->id, $sortfield, $sortorder,'',$num, 0, ''); + print ''; print ''; - print ''; - + print ''; + while ($i < $num) { $obj = $db->fetch_object($resql); @@ -125,10 +128,10 @@ if ($_GET["id"] > 0) } else { - /* Commande non trouvée */ + /* Commande non trouv�e */ print "Compteur inexistant"; } -} +} else { print "Compteur inexistant";
'.$langs->trans("Date").''.$langs->trans("Relevé").'
'.$langs->trans("Releve").'