Gestion des différentes vues
This commit is contained in:
parent
c276356041
commit
ebf68baa56
@ -57,82 +57,68 @@ if ($_POST["action"] == 'addvalue')
|
|||||||
|
|
||||||
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
|
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
|
||||||
|
|
||||||
$html = new Form($db);
|
if ($_GET["period"] == '')
|
||||||
|
|
||||||
/*********************************************************************
|
|
||||||
*
|
|
||||||
* Mode creation
|
|
||||||
*
|
|
||||||
*
|
|
||||||
************************************************************************/
|
|
||||||
if ($_GET["action"] == 'create')
|
|
||||||
{
|
{
|
||||||
print_titre("Ajouter une compteur");
|
$period = "day";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* *************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* Mode vue */
|
|
||||||
/* */
|
|
||||||
/* *************************************************************************** */
|
|
||||||
{
|
{
|
||||||
if ($_GET["id"] > 0)
|
$period = $_GET["period"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
|
$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);
|
$i = 0;
|
||||||
if ( $compteur->fetch($_GET["id"]) == 0)
|
|
||||||
|
$var = True;
|
||||||
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
|
$var=!$var;
|
||||||
$head[0][1] = "Compteur";
|
$obj = $db->fetch_object($resql);
|
||||||
$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 '<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>";
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
|
|
||||||
print '<tr><td align="center">';
|
print '<tr><td align="center">';
|
||||||
$file = "day.".$compteur->id.".png";
|
$file = $period.".".$obj->rowid.".png";
|
||||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
|
|
||||||
print '</td><td align="center">';
|
|
||||||
$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">';
|
$i++;
|
||||||
$file = "month.".$compteur->id.".png";
|
}
|
||||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
|
|
||||||
print '</td><td align="center">';
|
|
||||||
$file = "year.".$compteur->id.".png";
|
|
||||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
|
|
||||||
print '</td></tr></table><br>';
|
|
||||||
|
|
||||||
print "<br>\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Commande non trouvée */
|
|
||||||
print "Compteur inexistant";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "Compteur inexistant";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print '</table><br>';
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user