Fix on energy module
This commit is contained in:
parent
4ac98658c3
commit
f403449d9a
@ -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<EFBFBD>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<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);
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -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 '<form action="compteur.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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 "<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").'" class="button"></td></tr>';
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
print "</table></form>";
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
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 '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Compteur")."</td>";
|
||||
print '<td width="50%">';
|
||||
print $compteur->libelle;
|
||||
print "</td></tr>";
|
||||
print "</td></tr>";
|
||||
print "</table><br>";
|
||||
|
||||
|
||||
|
||||
|
||||
$html = new Form($db);
|
||||
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="action" value="addvalue">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
print '<td>Date</td><td>';
|
||||
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="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
print "</table></form><br>";
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td><a href="compteur_graph.php?id='.$compteur->id.'">';
|
||||
$file = "all.".$compteur->id.".png";
|
||||
@ -182,8 +184,8 @@ else
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
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 .= " 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<EFBFBD>e */
|
||||
print "Compteur inexistant";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Compteur inexistant";
|
||||
@ -222,5 +224,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Compteur")."</td>";
|
||||
print '<td width="50%">';
|
||||
print $compteur->libelle;
|
||||
print "</td></tr>";
|
||||
print "</td></tr>";
|
||||
print "</table><br>";
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
|
||||
print '<tr><td align="center" colspan="2">';
|
||||
$file = "day.".$compteur->id.".png";
|
||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td align="center" colspan="2">';
|
||||
$file = "week.".$compteur->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 = "month.".$compteur->id.".png";
|
||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
|
||||
@ -83,10 +92,10 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Compteur non trouvée */
|
||||
/* Compteur non trouv<EFBFBD>e */
|
||||
print "Compteur inexistant";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Compteur inexistant";
|
||||
|
||||
@ -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 '<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="token" value="'.$_SESSION['newtoken'].'">';
|
||||
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";
|
||||
}
|
||||
}
|
||||
$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 '<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="token" value="'.$_SESSION['newtoken'].'">';
|
||||
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<75>e */
|
||||
print "Compteur inexistant";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Compteur inexistant";
|
||||
print "Compteur inexistant";
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -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 '<form action="groupe.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
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 '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
||||
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
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 '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Groupe")."</td>";
|
||||
print "<tr><td>".$langs->trans("Group")."</td>";
|
||||
print '<td width="50%">';
|
||||
print $groupe->libelle;
|
||||
print "</td></tr>";
|
||||
print "</td></tr>";
|
||||
print "</table><br>";
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
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 '</td></tr></table><br>';
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print "<br>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
/* Commande non trouv<EFBFBD>e */
|
||||
print "Groupe inexistant";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Groupe inexistant";
|
||||
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
print "<tr><td>".$langs->trans("Compteur")."</td>";
|
||||
print '<td width="50%">';
|
||||
print $compteur->libelle;
|
||||
print "</td></tr>";
|
||||
print "</td></tr>";
|
||||
print "</table><br>";
|
||||
print '</div>';
|
||||
|
||||
$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 '<table class="noborder" width="100%">';
|
||||
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)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
@ -125,10 +128,10 @@ if ($_GET["id"] > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Commande non trouvée */
|
||||
/* Commande non trouv<EFBFBD>e */
|
||||
print "Compteur inexistant";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Compteur inexistant";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user