Refactor code for improved readability and consistency across multiple files

This commit is contained in:
Le Stagiaire
2024-11-08 16:08:06 +01:00
parent 0cfc5938bd
commit 6aa7fea79c
19 changed files with 1677 additions and 1794 deletions

View File

@ -1,143 +1,135 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
$color = true;
$num_page = 1; // Initialisation du numéro de la page
$nb_per_page = 10; // Initialisation du nombre d'entréé par page
$index = 0; // Initialisation de l'index pour la selection dans la BDD
$color = true;
$num_page = 1; // Initialisation du numéro de la page
$nb_per_page = 10; // Initialisation du nombre d'entréé par page
$index = 0; // Initialisation de l'index pour la selection dans la BDD
// Si l'utilisateur change le nombre d'alertes par page
if(isset($_GET['npp']) && $_GET['npp'] > 0)
$nb_per_page = $_GET['npp']; // On modifie l'attribut
// Si l'utilisateur change le nombre d'alertes par page
if (isset($_GET['npp']) && $_GET['npp'] > 0)
$nb_per_page = $_GET['npp']; // On modifie l'attribut
// Si le numéro de la page est supérieur à 0
if(isset($_GET['page']) && $_GET['page'] > 0)
{
$num_page = $_GET['page']; // On modifie l'attribut
$index = $nb_per_page * ($num_page - 1); // Ainsi que l'attribut ci
}
// Sélection de l'affichage
$getaff = "";
if(isset($_POST['chateau']) or isset($_POST['relevage']) or isset($_POST['surpresseur']))
{
if(@$_POST['chateau']) $_SESSION['alerte_chateau'] = 1; else $_SESSION['alerte_chateau'] = 0;
if(@$_POST['relevage']) $_SESSION['alerte_relevage'] = 1; else $_SESSION['alerte_relevage'] = 0;
if(@$_POST['surpresseur']) $_SESSION['alerte_surpresseur'] = 1; else $_SESSION['alerte_surpresseur'] = 0;
}
if(!@$_SESSION['alerte_chateau'] && !@$_SESSION['alerte_relevage'] && !@$_SESSION['alerte_surpresseur'])
{
$_SESSION['alerte_chateau'] = 1;
$_SESSION['alerte_relevage'] = 1;
$_SESSION['alerte_surpresseur'] = 1;
}
$where = "WHERE ";
if($_SESSION['alerte_chateau'])
{ $where .= "equipement='Chateau'"; }
if($_SESSION['alerte_relevage'])
{
if($_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Station de Relevage'";
}
if($_SESSION['alerte_surpresseur'])
{
if($_SESSION['alerte_relevage'] or $_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Surpresseur'";
}
if(isset($_GET['acquitte_id']) && $_GET['acquitte_id'] >= 0)
{
if($connexion->query("UPDATE alertes SET acquitte='1' WHERE id_releve=".$_GET['acquitte_id']))
header("Location:".$_SERVER['HTTP_REFERER']); // On acquitte l'alerte avec l'ID $_GET['acquitte_id'] puis on revient
else echo 'Erreur..'; // sur la page précédente donc la page d'affichage des alertes
}
else
{
// Requête qui récupère les informations de la base de données
$result_alertes = $connexion->query("SELECT * FROM alertes ".$where." ORDER BY date DESC, heure DESC LIMIT $index, $nb_per_page");
echo '<h1>Gestion des alertes</h1>';
// Déclaration des titres du tableau
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>';
echo '<td>Equipement</td>';
echo '<td>Type</td>';
echo '<td>Date / Heure</td>';
echo '<td>Acquitte?</td>';
echo '</tr>';
while($alertes = $result_alertes->fetch()) // fetch() récupère un à un les alertes
{
$color = !$color; // $color est un booléen, pour l'alternance de couleur
if($color) $couleur = "#9CF"; else $couleur = "#9CC"; // 2 couleurs, pour la lisibilité du tableau
echo '<tr style="background-color:'.$couleur.';">'; // On défini la nouvelle ligne avec la couleur
echo '<td class="ligne">'.$alertes['equipement'].'</td>'; // Equipement
echo '<td class="ligne">'.utf8_encode(strtolower(str_replace('?', 'e', str_replace('_', ' ', $alertes['type'])))).'</td>';
// Type d'alerte en minuscule avec strtolower()
echo '<td class="ligne">'.$alertes['date'].' / '.$alertes['heure'].'</td>'; // Date et Heure
echo '<td class="ligne">';
// Si "acquitte" est a 1 on affiche "Oui" sinon on afficher un lien pour l'acquitter "Non-> Acquitter"
if($alertes['acquitte']) echo 'Oui';
else echo '<span id="acqu'.$alertes['id_releve'].'">Non &rarr; <a href="?acquitte_id='.$alertes['id_releve'].'" onClick="acqu'.$alertes['id_releve'].'.innerHTML=\'&rarr; Oui\'">Acquitter</a>';
echo '</td>';
echo '</tr>';
}
echo '</table>'; // Fermeture du tableau
// Nb pages
$nb_alertes = $connexion->query("SELECT count(*) FROM alertes ".$where."")->fetchColumn();
if($nb_alertes == 0) echo '<h1>Aucunes alertes</h1>';
else
{
if(isset($_GET['page']))
$pageActuelle = $_GET['page'];
else
$pageActuelle = '1';
function get_list_page($page, $nb_page, $link, $nb = 3){
$list_page = array();
for ($i=1; $i <= $nb_page; $i++)
{
if (($i < $nb) OR ($i > $nb_page - $nb) OR (($i < $page + $nb) AND ($i > $page -$nb)))
$list_page[] = ($i==$page)?'<a class="pagenumeroactuel">[ '.$i.' ]</a>':'<a class="pagenumero" href="'.$link.'page='.$i.'">'.$i.'</a>';
else
{
if ($i >= $nb AND $i <= $page - $nb)
$i = $page - $nb;
elseif ($i >= $page + $nb AND $i <= $nb_page - $nb)
$i = $nb_page - $nb;
$list_page[] = '...';
}
// Si le numéro de la page est supérieur à 0
if (isset($_GET['page']) && $_GET['page'] > 0) {
$num_page = $_GET['page']; // On modifie l'attribut
$index = $nb_per_page * ($num_page - 1); // Ainsi que l'attribut ci
}
$print= implode(' ', $list_page);
return $print;
}
echo '<br>Pages: ';
echo get_list_page($pageActuelle, (($nb_alertes -1 ) / $nb_per_page)+1, '?');
echo '<form method="GET"><input type="text" name="page" value="'.$pageActuelle.'" style="width:30px;"><input type="submit" value="Rechercher"></form>';
echo '<br>';
}
// Sélection de l'affichage
$getaff = "";
if (isset($_POST['chateau']) or isset($_POST['relevage']) or isset($_POST['surpresseur'])) {
if (@$_POST['chateau']) $_SESSION['alerte_chateau'] = 1;
else $_SESSION['alerte_chateau'] = 0;
if (@$_POST['relevage']) $_SESSION['alerte_relevage'] = 1;
else $_SESSION['alerte_relevage'] = 0;
if (@$_POST['surpresseur']) $_SESSION['alerte_surpresseur'] = 1;
else $_SESSION['alerte_surpresseur'] = 0;
}
if (!@$_SESSION['alerte_chateau'] && !@$_SESSION['alerte_relevage'] && !@$_SESSION['alerte_surpresseur']) {
$_SESSION['alerte_chateau'] = 1;
$_SESSION['alerte_relevage'] = 1;
$_SESSION['alerte_surpresseur'] = 1;
}
$where = "WHERE ";
if ($_SESSION['alerte_chateau']) {
$where .= "equipement='Chateau'";
}
if ($_SESSION['alerte_relevage']) {
if ($_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Station de Relevage'";
}
if ($_SESSION['alerte_surpresseur']) {
if ($_SESSION['alerte_relevage'] or $_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Surpresseur'";
}
if (isset($_GET['acquitte_id']) && $_GET['acquitte_id'] >= 0) {
if ($connexion->query("UPDATE alertes SET acquitte='1' WHERE id_releve=" . $_GET['acquitte_id']))
header("Location:" . $_SERVER['HTTP_REFERER']); // On acquitte l'alerte avec l'ID $_GET['acquitte_id'] puis on revient
else echo 'Erreur..'; // sur la page précédente donc la page d'affichage des alertes
} else {
// Requête qui récupère les informations de la base de données
$result_alertes = $connexion->query("SELECT * FROM alertes " . $where . " ORDER BY date DESC, heure DESC LIMIT $index, $nb_per_page");
echo '<h1>Gestion des alertes</h1>';
// Déclaration des titres du tableau
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>';
echo '<td>Equipement</td>';
echo '<td>Type</td>';
echo '<td>Date / Heure</td>';
echo '<td>Acquitte?</td>';
echo '</tr>';
while ($alertes = $result_alertes->fetch()) // fetch() récupère un à un les alertes
{
$color = !$color; // $color est un booléen, pour l'alternance de couleur
if ($color) $couleur = "#9CF";
else $couleur = "#9CC"; // 2 couleurs, pour la lisibilité du tableau
echo '<tr style="background-color:' . $couleur . ';">'; // On défini la nouvelle ligne avec la couleur
echo '<td class="ligne">' . $alertes['equipement'] . '</td>'; // Equipement
echo '<td class="ligne">' . utf8_encode(strtolower(str_replace('?', 'e', str_replace('_', ' ', $alertes['type'])))) . '</td>';
// Type d'alerte en minuscule avec strtolower()
echo '<td class="ligne">' . $alertes['date'] . ' / ' . $alertes['heure'] . '</td>'; // Date et Heure
echo '<td class="ligne">';
// Si "acquitte" est a 1 on affiche "Oui" sinon on afficher un lien pour l'acquitter "Non-> Acquitter"
if ($alertes['acquitte']) echo 'Oui';
else echo '<span id="acqu' . $alertes['id_releve'] . '">Non &rarr; <a href="?acquitte_id=' . $alertes['id_releve'] . '" onClick="acqu' . $alertes['id_releve'] . '.innerHTML=\'&rarr; Oui\'">Acquitter</a>';
echo '</td>';
echo '</tr>';
}
echo '</table>'; // Fermeture du tableau
// Nb pages
$nb_alertes = $connexion->query("SELECT count(*) FROM alertes " . $where . "")->fetchColumn();
if ($nb_alertes == 0) echo '<h1>Aucunes alertes</h1>';
else {
if (isset($_GET['page']))
$pageActuelle = $_GET['page'];
else
$pageActuelle = '1';
function get_list_page($page, $nb_page, $link, $nb = 3)
{
$list_page = array();
for ($i = 1; $i <= $nb_page; $i++) {
if (($i < $nb) or ($i > $nb_page - $nb) or (($i < $page + $nb) and ($i > $page - $nb)))
$list_page[] = ($i == $page) ? '<a class="pagenumeroactuel">[ ' . $i . ' ]</a>' : '<a class="pagenumero" href="' . $link . 'page=' . $i . '">' . $i . '</a>';
else {
if ($i >= $nb and $i <= $page - $nb)
$i = $page - $nb;
elseif ($i >= $page + $nb and $i <= $nb_page - $nb)
$i = $nb_page - $nb;
$list_page[] = '...';
}
}
$print = implode(' ', $list_page);
return $print;
}
echo '<br>Pages: ';
echo get_list_page($pageActuelle, (($nb_alertes - 1) / $nb_per_page) + 1, '?');
echo '<form method="GET"><input type="text" name="page" value="' . $pageActuelle . '" style="width:30px;"><input type="submit" value="Rechercher"></form>';
echo '<br>';
}
// Options d'affichage
echo '</br><div style class="options"><form method="post" action="alertes.php?npp='.$nb_per_page.'"><label><input type="checkbox" name="chateau" value="1" ';
if($_SESSION['alerte_chateau']) echo 'checked';
echo '>Ch&acirc;teau</label> <label><input type="checkbox" name="relevage" value="1" ';
if($_SESSION['alerte_relevage']) echo 'checked';
echo '>Station de Relevage</label> <label><input type="checkbox" name="surpresseur" value="1" ';
if($_SESSION['alerte_surpresseur']) echo 'checked';
echo '>Surpresseur</label><br/><input type="submit" value="Flitrer les r&eacute;sultats"></form></div>';
}
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>
// Options d'affichage
echo '</br><div style class="options"><form method="post" action="alertes.php?npp=' . $nb_per_page . '"><label><input type="checkbox" name="chateau" value="1" ';
if ($_SESSION['alerte_chateau']) echo 'checked';
echo '>Ch&acirc;teau</label> <label><input type="checkbox" name="relevage" value="1" ';
if ($_SESSION['alerte_relevage']) echo 'checked';
echo '>Station de Relevage</label> <label><input type="checkbox" name="surpresseur" value="1" ';
if ($_SESSION['alerte_surpresseur']) echo 'checked';
echo '>Surpresseur</label><br/><input type="submit" value="Flitrer les r&eacute;sultats"></form></div>';
}
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php');

View File

@ -14,7 +14,7 @@ function ds_getel(id) {
function ds_getleft(el) {
var tmp = el.offsetLeft;
el = el.offsetParent
while(el) {
while (el) {
tmp += el.offsetLeft;
el = el.offsetParent;
}
@ -23,7 +23,7 @@ function ds_getleft(el) {
function ds_gettop(el) {
var tmp = el.offsetTop;
el = el.offsetParent
while(el) {
while (el) {
tmp += el.offsetTop;
el = el.offsetParent;
}
@ -31,7 +31,7 @@ function ds_gettop(el) {
}
setTimeout(
function(){
function () {
// Output Element
ds_oe = ds_getel('ds_calclass');
// Container
@ -55,28 +55,28 @@ function ds_echo(t) {
var ds_element; // Text Element...
var ds_monthnames = [
'Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin',
'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre'
'Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin',
'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre'
]; // You can translate it for your language.
var ds_daynames = [
'Dim', 'Lun', 'Mar', 'Me', 'Jeu', 'Ven', 'Sam'
'Dim', 'Lun', 'Mar', 'Me', 'Jeu', 'Ven', 'Sam'
]; // You can translate it for your language.
// Calendar template
function ds_template_main_above(t) {
return '<table cellpadding="3" cellspacing="1" class="ds_tbl">'
+ '<tr>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_py();">&lt;&lt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_pm();">&lt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_hi();" colspan="3">[Fermer]</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_nm();">&gt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_ny();">&gt;&gt;</td>'
+ '</tr>'
+ '<tr>'
+ '<td colspan="7" class="ds_head">' + t + '</td>'
+ '</tr>'
+ '<tr>';
+ '<tr>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_py();">&lt;&lt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_pm();">&lt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_hi();" colspan="3">[Fermer]</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_nm();">&gt;</td>'
+ '<td class="ds_head" style="cursor: pointer" onclick="ds_ny();">&gt;&gt;</td>'
+ '</tr>'
+ '<tr>'
+ '<td colspan="7" class="ds_head">' + t + '</td>'
+ '</tr>'
+ '<tr>';
}
function ds_template_day_row(t) {
@ -106,9 +106,9 @@ function ds_draw_calendar(m, y) {
// First clean the output buffer.
ds_ob_clean();
// Here we go, do the header
ds_echo (ds_template_main_above(ds_monthnames[m - 1] + ' ' + y));
for (i = 0; i < 7; i ++) {
ds_echo (ds_template_day_row(ds_daynames[i]));
ds_echo(ds_template_main_above(ds_monthnames[m - 1] + ' ' + y));
for (i = 0; i < 7; i++) {
ds_echo(ds_template_day_row(ds_daynames[i]));
}
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
@ -120,33 +120,33 @@ function ds_draw_calendar(m, y) {
else {
days = (y % 4 == 0) ? 29 : 28;
}
var first_day = new Date(y, (m-1), 1).getDay();
var first_day = new Date(y, (m - 1), 1).getDay();
var first_loop = 1;
// Start the first week
ds_echo (ds_template_new_week());
ds_echo(ds_template_new_week());
// If sunday is not the first day of the month, make a blank cell...
if (first_day != 0) {
ds_echo (ds_template_blank_cell(first_day));
ds_echo(ds_template_blank_cell(first_day));
}
var j = first_day;
for (i = 0; i < days; i ++) {
for (i = 0; i < days; i++) {
// Today is sunday, make a new week.
// If this sunday is the first day of the month,
// we've made a new row for you already.
if (j == 0 && !first_loop) {
// New week!!
ds_echo (ds_template_new_week());
ds_echo(ds_template_new_week());
}
ds_echo (ds_template_day(i + 1, m, y)); // Make a row of that day!
ds_echo(ds_template_day(i + 1, m, y)); // Make a row of that day!
first_loop = 0; // This is not first loop anymore...
// What is the next day?
j ++;
j++;
j %= 7;
}
ds_echo (ds_template_main_below()); // Do the footer
ds_echo(ds_template_main_below()); // Do the footer
ds_ob_flush(); // And let's display..
ds_ce.scrollIntoView(); // Scroll it into view.
}
@ -158,13 +158,11 @@ function ds_sh(t) {
ds_element = t;
var date = t.value.split("-");
// Make a new date, and set the current month and year.
if(t != "")
{
if (t != "") {
ds_c_month = date[1];
ds_c_year = date[0];
}
else
{
else {
var ds_sh_date = new Date();
ds_c_month = ds_sh_date.getMonth() + 1;
ds_c_year = ds_sh_date.getFullYear();
@ -183,12 +181,12 @@ function ds_sh(t) {
}
// Hide the calendar.
function ds_hi() {ds_ce.style.display = 'none';}
function ds_hi() { ds_ce.style.display = 'none'; }
// Moves to the next month...
function ds_nm() {
// Increase the current month.
ds_c_month ++;
ds_c_month++;
// We have passed December, let's go to the next year.
// Increase the current year, and set the current month to January.
if (ds_c_month > 12) {
@ -238,17 +236,17 @@ function ds_format_date(d, m, y) {
function ds_onclick(d, m, y) {
ds_hi(); // Hide the calendar.
if (typeof(ds_element.value) != 'undefined') {
if (typeof (ds_element.value) != 'undefined') {
// Set the value of it, if we can.
ds_element.value = ds_format_date(d, m, y);
}
else if (typeof(ds_element.innerHTML) != 'undefined') {
else if (typeof (ds_element.innerHTML) != 'undefined') {
// Maybe we want to set the HTML in it.
ds_element.innerHTML = ds_format_date(d, m, y);
}
else {
// I don't know how should we display it, just alert it to user.
alert (ds_format_date(d, m, y));
alert(ds_format_date(d, m, y));
}
}
// ]]> -->

View File

@ -1,52 +1,38 @@
<?php require('head.php');
if(@$infos_user['token'] == @$_SESSION['token'] && @$_SESSION['token'] != '')
{
if(@$_GET['action'] == 'logout')
{
if (@$infos_user['token'] == @$_SESSION['token'] && @$_SESSION['token'] != '') {
if (@$_GET['action'] == 'logout') {
$_SESSION['user'] = '';
$_SESSION['token'] = '';
header('Refresh:1; url=connexion.php');
echo 'Vous êtes déconnecté!';
}
else
{
} else {
header('Refresh:1; url=index.php');
echo 'Vous êtes connecté en tant que: <b>'.$_SESSION['user'].'</b>';
echo 'Vous êtes connecté en tant que: <b>' . $_SESSION['user'] . '</b>';
}
}
elseif(@$_POST['user'] && @$_POST['pass'])
{
if($result_infos_userCO = $connexion->query("SELECT * FROM comptes WHERE pseudo='".$_POST['user']."'"))
{
} elseif (@$_POST['user'] && @$_POST['pass']) {
if ($result_infos_userCO = $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_POST['user'] . "'")) {
$infos_userCO = $result_infos_userCO->fetch();
//if($infos_userCO['mdp1'] == md5($_POST['pass']))
if($infos_userCO['mdp1'] == $_POST['pass'])
{
if ($infos_userCO['mdp1'] == $_POST['pass']) {
$tokenCO = rand(100000, 999999);
if($connexion->query("UPDATE comptes SET token='".$tokenCO."' WHERE pseudo='".$_POST['user']."'"))
{
if ($connexion->query("UPDATE comptes SET token='" . $tokenCO . "' WHERE pseudo='" . $_POST['user'] . "'")) {
$_SESSION['user'] = $_POST['user'];
$_SESSION['token'] = $tokenCO;
header('Refresh:1; url=index.php');
echo 'Vous êtes connecté en tant que: <b>'.$_SESSION['user'].'</b>';
}
else echo 'Erreur avec la BDD! 0x02';
}
else echo 'L\'utilisateur ou mot de passe incorrect!<br/><br/>-> <a href="connexion.php">On réésaye?</a>';
}
else echo 'Erreur avec la BDD! 0x01';
}
else
{
echo 'Vous êtes connecté en tant que: <b>' . $_SESSION['user'] . '</b>';
} else echo 'Erreur avec la BDD! 0x02';
} else echo 'L\'utilisateur ou mot de passe incorrect!<br/><br/>-> <a href="connexion.php">On réésaye?</a>';
} else echo 'Erreur avec la BDD! 0x01';
} else {
?>
<h2>Connexion</h2>
<form method="post">
Utilisateur :<br/>
<input type="text" name="user"><br/><br/>
Mot de passe :<br/>
<input type="password" name="pass">
<input type="submit" value="Se connecter">
</form>
<h2>Connexion</h2>
<form method="post">
Utilisateur :<br />
<input type="text" name="user"><br /><br />
Mot de passe :<br />
<input type="password" name="pass">
<input type="submit" value="Se connecter">
</form>
<?php
}
include('foot.php'); ?>

View File

@ -1,6 +1,4 @@
<?php
// message d'erreur lors d'un pb de connexion
// cr<63><72> en 2014 COPYRIGHT<48> C HANRION 2014
// cr<63><72> en 2014 COPYRIGHT<48> C HANRION 2014
echo 'Vous n\'etes pas autorise!';
?>

View File

@ -2,15 +2,17 @@
<!-- FIN CORPS -->
<!-- PIED -->
<div><hr style="width:800px; margin-top:20px;">
<em style="font-size:12px;">Exécuté en ~<?php
list($usec, $sec) = explode(" ", microtime());
$fin_ex = (float)$usec + (float)$sec;
echo round($fin_ex-$debut_ex,3);
?> s.<br/>Panel réalisé par BREGAND Alexis et HANRION Claude</a>.</em>
<div>
<hr style="width:800px; margin-top:20px;">
<em style="font-size:12px;">Exécuté en ~<?php
list($usec, $sec) = explode(" ", microtime());
$fin_ex = (float)$usec + (float)$sec;
echo round($fin_ex - $debut_ex, 3);
?> s.<br />Panel réalisé par BREGAND Alexis et HANRION Claude</a>.</em>
</div>
<!-- FIN PIED -->
</div>
</body>
</html>

View File

@ -1,166 +1,163 @@
<html>
<head>
<meta charset="utf-8">
<title>Volume Chateau</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/exporting.js"></script>
<link rel="stylesheet" href="ext_jquery-ui.css">
<script src="js/ext_jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$( "#datepicker" ).datepicker();
$( "#format" ).change(function() {
$( "#datepicker" ).datepicker( "option", "dateFormat", $( this ).val() );
});
});
</script>
<meta charset="utf-8">
<title>Volume Chateau</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/exporting.js"></script>
<link rel="stylesheet" href="ext_jquery-ui.css">
<script src="js/ext_jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
$("#format").change(function() {
$("#datepicker").datepicker("option", "dateFormat", $(this).val());
});
});
</script>
</head>
<?php
include('sql_connexion.php');
if (isset($_SESSION['pseudo']) && isset($_SESSION['token']))
{
if(isset ($_GET['datepicker']))
{
$datepicker=$_GET['datepicker'];
}
else
{
$datepicker=null;
}
echo'<form name=\'form\' method=\'get\' action="">';
echo'<select name="graphique" size="1">';
echo'<option>Volume dans la cuve';
echo'<option>Température colonne';
echo'<option>Température ambiante';
echo'</select> ';
echo'Date début: <input type="text" id="datepicker" name="datepicker" value="'.$datepicker.'">';
echo'<input type="submit" value="Valider">';
echo'</form>';
if(isset ($_GET['datepicker']))
{
if (($_GET['datepicker'])!=null)
{
echo'<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>';
if (isset($_SESSION['pseudo']) && isset($_SESSION['token'])) {
if (isset($_GET['datepicker'])) {
$datepicker = $_GET['datepicker'];
} else {
$datepicker = null;
}
echo '<form name=\'form\' method=\'get\' action="">';
echo '<select name="graphique" size="1">';
echo '<option>Volume dans la cuve';
echo '<option>Température colonne';
echo '<option>Température ambiante';
echo '</select> ';
echo 'Date début: <input type="text" id="datepicker" name="datepicker" value="' . $datepicker . '">';
echo '<input type="submit" value="Valider">';
echo '</form>';
if (isset($_GET['datepicker'])) {
if (($_GET['datepicker']) != null) {
echo '<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>';
echo '<br><a href="./menu.php">retour</a>';
}
}
}
else
{
include('connexion_erreur.php');
} else {
include('connexion_erreur.php');
}
?>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'x',
spacingRight: 20
},
title: {
text: '<?php if($_GET['graphique']=='Volume dans la cuve'){$text='Pompe';}else{ $text='Température';}echo $text;?> Château d\'eau'
},
subtitle: {<?php
echo " text: 'Rosière-en-Haye données du ".$_GET['datepicker']."'";
?>
},
xAxis: {
type: 'datetime',
tickInterval: 3600 * 1000,
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: '<?php if($_GET['graphique']=='Volume dans la cuve') echo'Volume (m³)';
else{ echo'température (°C)';}?>'
}
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: '<?php if($_GET['graphique']=='Volume dans la cuve') echo'volume';
else{ echo'température';}?>',
pointInterval: 900 * 1000,
pointStart: Date.UTC(<?php $date = (string)$datepicker; $date= str_replace ( '-', ',', $date);echo $date;?>, 0, 0, 0, 0),
data: [<?php
if(isset($datepicker))
{
if ($_GET['graphique']=='Température colonne')
{
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while($recup = $result_co->fetch(PDO::FETCH_ASSOC))
{
$tableautemp_colonne[] = $recup['temp_colonne'];
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'x',
spacingRight: 20
},
title: {
text: '<?php if ($_GET['graphique'] == 'Volume dans la cuve') {
$text = 'Pompe';
} else {
$text = 'Température';
}
for ($j=0;$j<count($tableautemp_colonne)-1;$j++)
{
if($j != 0) echo ", ";
echo $tableautemp_colonne[$j];
}
}
else if ($_GET['graphique']=='Température ambiante')
{
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while($recup = $result_co->fetch(PDO::FETCH_ASSOC))
{
$tableautemp_ambiante[] = $recup['temp_ambiante'];
}
for ($j=0;$j<count($tableautemp_ambiante)-1;$j++)
{
if($j != 0) echo ", ";
echo $tableautemp_ambiante[$j];
}
}
else
{
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while($recup = $result_co->fetch(PDO::FETCH_ASSOC))
{
$tableau_hauteurvol[] = $recup['volume'];
}
for ($j=0;$j<count($tableau_hauteurvol)-1;$j++)
{
if($j != 0) echo ", ";
echo $tableau_hauteurvol[$j];
}
}
echo $text; ?> Château d\'eau'
},
subtitle: {
<?php
echo " text: 'Rosière-en-Haye données du " . $_GET['datepicker'] . "'";
?>
},
xAxis: {
type: 'datetime',
tickInterval: 3600 * 1000,
title: {
text: null
}
?>
]
}]
});
});
</script>
},
yAxis: {
min: 0,
title: {
text: '<?php if ($_GET['graphique'] == 'Volume dans la cuve') echo 'Volume (m³)';
else {
echo 'température (°C)';
} ?>'
}
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
plotOptions: {
area: {
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
]
},
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [{
type: 'area',
name: '<?php if ($_GET['graphique'] == 'Volume dans la cuve') echo 'volume';
else {
echo 'température';
} ?>',
pointInterval: 900 * 1000,
pointStart: Date.UTC(<?php $date = (string)$datepicker;
$date = str_replace('-', ',', $date);
echo $date; ?>, 0, 0, 0, 0),
data: [<?php
if (isset($datepicker)) {
if ($_GET['graphique'] == 'Température colonne') {
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while ($recup = $result_co->fetch(PDO::FETCH_ASSOC)) {
$tableautemp_colonne[] = $recup['temp_colonne'];
}
for ($j = 0; $j < count($tableautemp_colonne) - 1; $j++) {
if ($j != 0) echo ", ";
echo $tableautemp_colonne[$j];
}
} else if ($_GET['graphique'] == 'Température ambiante') {
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while ($recup = $result_co->fetch(PDO::FETCH_ASSOC)) {
$tableautemp_ambiante[] = $recup['temp_ambiante'];
}
for ($j = 0; $j < count($tableautemp_ambiante) - 1; $j++) {
if ($j != 0) echo ", ";
echo $tableautemp_ambiante[$j];
}
} else {
$result_co = $bdd->query("SELECT * FROM chateau WHERE date='$datepicker' ORDER BY date, heure ASC");
while ($recup = $result_co->fetch(PDO::FETCH_ASSOC)) {
$tableau_hauteurvol[] = $recup['volume'];
}
for ($j = 0; $j < count($tableau_hauteurvol) - 1; $j++) {
if ($j != 0) echo ", ";
echo $tableau_hauteurvol[$j];
}
}
}
?>]
}]
});
});
</script>

View File

@ -5,37 +5,39 @@ $debut_ex = (float)$usec + (float)$sec;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Panel de Rosières-en-Haye</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<?php
require('mysql.php');
?>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Panel de Rosières-en-Haye</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<?php
require('mysql.php');
?>
</head>
<body>
<div style="width:800px; margin-left:auto; margin-right:auto;">
<div style="width:800px; margin-left:auto; margin-right:auto;">
<!-- LOGO -->
<div style="float:left"><img src="banniere_reh.png" width="600" height="200" alt=""/></div>
<!-- FIN LOGO -->
<!-- LOGO -->
<div style="float:left"><img src="banniere_reh.png" width="600" height="200" alt="" /></div>
<!-- FIN LOGO -->
<!-- MENU -->
<div style="height:200px; text-align:right;">
<?php if(@$infos_user){ echo strtoupper($infos_user['prenom'].' '.$infos_user['nom']); ?><br/>
(<?php echo strtolower($infos_user['pseudo']); ?>)<br/>
<a href="connexion.php?action=logout">Se déconnecter</a><br/><br/>
<a href="index.php">Menu</a><br/>
<a href="alertes.php"><?php echo $result_nb_alertes; ?> Alertes</a><br/>
<a href="membres.php">Membres</a>
<?php
}
else echo 'Bonjour à vous!<br/><br/><a href="connexion.php">Se connecter</a>'; ?>
</div>
<!-- FIN MENU -->
<!-- MENU -->
<div style="height:200px; text-align:right;">
<?php if (@$infos_user) {
echo strtoupper($infos_user['prenom'] . ' ' . $infos_user['nom']); ?><br />
(<?php echo strtolower($infos_user['pseudo']); ?>)<br />
<a href="connexion.php?action=logout">Se déconnecter</a><br /><br />
<a href="index.php">Menu</a><br />
<a href="alertes.php"><?php echo $result_nb_alertes; ?> Alertes</a><br />
<a href="membres.php">Membres</a>
<?php
} else echo 'Bonjour à vous!<br/><br/><a href="connexion.php">Se connecter</a>'; ?>
</div>
<!-- FIN MENU -->
<!-- CORPS -->
<div><hr style="width:800px;">
<!-- CORPS -->
<div>
<hr style="width:800px;">

View File

@ -1,20 +1,18 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<h2>Château d'eau</h2>
&rarr; <a href="temperatures.php">Températures ambiante et de la colonne</a><br>
&rarr; <a href="volumes.php">Volumes pompés</a><br>
<h2>Château d'eau</h2>
&rarr; <a href="temperatures.php">Températures ambiante et de la colonne</a><br>
&rarr; <a href="volumes.php">Volumes pompés</a><br>
<h2>Surpresseur</h2>
&rarr; <a href="volumes_surpresseur.php">Volume pompés</a><br>
&rarr; <a href="surpresseur.php">Temps de fonctionnement des pompes et volumes pompés</a><br>
<h2>Surpresseur</h2>
&rarr; <a href="volumes_surpresseur.php">Volume pompés</a><br>
&rarr; <a href="surpresseur.php">Temps de fonctionnement des pompes et volumes pompés</a><br>
<h2>Station de relevage</h2>
&rarr; <a href="pompes.php">Temps de fonctionnement cumulé des pompes</a><br>
&rarr; <a href="pompes_bar.php">Temps de fonctionnement des pompes</a><br>
&rarr; <a href="pompes_bar_volume.php">Temps de fonctionnement des pompes et volumes pompés</a><br>
<h2>Station de relevage</h2>
&rarr; <a href="pompes.php">Temps de fonctionnement cumulé des pompes</a><br>
&rarr; <a href="pompes_bar.php">Temps de fonctionnement des pompes</a><br>
&rarr; <a href="pompes_bar_volume.php">Temps de fonctionnement des pompes et volumes pompés</a><br>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,232 +1,224 @@
<?php require('head.php');
if(@$infos_user['droit'] > 3)
{
if (@$infos_user['droit'] > 3) {
function mdp_gen($taille)
{
$car = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*-$';
$mdp = NULL;
for($i=0;$i<$taille;$i++)
function mdp_gen($taille)
{
$mdp .= $car[rand(0, strlen($car) -1)];
}
return $mdp;
}
$s_droits = "* ToutLesDroits(4) - ToutLesDroitsSaufGestionUtilisateurs(3)";
$color = true;
if(isset($_GET['action']) && $_GET['action'] == "ajouter")
{
if(isset($_POST['pseudo']) && $_POST['pseudo'] != '' && !$connexion->query("SELECT * FROM comptes WHERE pseudo='".$_POST['pseudo']."'")->fetch() && isset($_POST['nom']) && $_POST['nom'] != '' && isset($_POST['prenom']) && $_POST['prenom'] != '' && isset($_POST['num_rue']) && $_POST['num_rue'] != '' && isset($_POST['rue']) && $_POST['rue'] != '' && isset($_POST['ville']) && $_POST['ville'] != '' && isset($_POST['tel']) && $_POST['tel'] != '' && isset($_POST['fonction']) && $_POST['fonction'] != '' && isset($_POST['mdp']) && $_POST['mdp'] != '')
{
echo '<div style="text-align:center">';
if($connexion->query("INSERT INTO `comptes` (`id_compte`, `nom`, `prenom`, `num_rue`, `rue`, `ville`, `tel`, `fonction`, `pseudo`, `mdp1`, `droit`, `suspendu`, `token`) VALUES (NULL, '".$_POST['nom']."', '".$_POST['prenom']."', '".$_POST['num_rue']."', '".$_POST['rue']."', '".$_POST['ville']."', '".$_POST['tel']."', '".$_POST['fonction']."', '".$_POST['pseudo']."', '".md5($_POST['mdp'])."', '".$_POST['droit']."', '".$_POST['suspendu']."', '0123');"))
{
echo 'Utilisateur ajoute!</br></br>';
echo '<sub>Utilisateur: '.$_POST['pseudo'].'</br>';
echo 'Mot de passe: '.$_POST['mdp'].'</sub>';
$car = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*-$';
$mdp = NULL;
for ($i = 0; $i < $taille; $i++) {
$mdp .= $car[rand(0, strlen($car) - 1)];
}
else
{
echo 'Une erreur est survenue.. (Aucun utilisateur n\'a ete ajoute)';
}
echo '<br/><br/><sub><a href="?action=retour">Retour</a></sub></div>';
return $mdp;
}
else
{
echo '<h1>Ajout d\'utilisateur</h1>';
echo '<form method="post">';
echo '<table width="800" border="0" cellspacing="3" cellpadding="0" align="center">';
echo '<tr> <td class="tab_ajout">Pseudo:</td> <td><input type="text" name="pseudo" id="pseudo" value="'.@$_POST['pseudo'].'">';
if(isset($_POST['pseudo']) && $connexion->query("SELECT * FROM comptes WHERE pseudo='".$_POST['pseudo']."'")->fetch())
echo '<span class="erreur_ajo">Pseudo deja utilise</span>';
elseif(isset($_POST['pseudo']) && $_POST['pseudo'] == '') echo '<span class="erreur_ajo">Pseudo manquant</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Nom:</td> <td><input type="text" name="nom" id="nom" value="'.@$_POST['nom'].'">';
if(isset($_POST['nom']) && $_POST['nom'] == '')
echo '<span class="erreur_ajo">Nom manquant</span>'; echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Prenom:</td> <td><input type="text" name="prenom" id="prenom" value="'.@$_POST['prenom'].'">';
if(isset($_POST['prenom']) && $_POST['prenom'] == '')
echo '<span class="erreur_ajo">Prenom manquant</span>'; echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Adresse:</td> <td><input name="num_rue" type="text" id="num_rue" size="10" maxlength="6" value="'.@$_POST['num_rue'].'">
<input name="rue" type="text" id="rue" size="45" value="'.@$_POST['rue'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Ville:</td> <td><input name="ville" type="text" id="ville" size="45" value="'.@$_POST['ville'].'">';
if(isset($_POST['num_rue']) && $_POST['num_rue'] == '' or isset($_POST['rue']) && $_POST['rue'] == '' or isset($_POST['ville']) && $_POST['ville'] == '')
echo '<span class="erreur_ajo">Adresse incomplete</span>'; echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Tel.:</td> <td><input type="text" name="tel" id="tel" value="'.@$_POST['ville'].'">';
if(isset($_POST['tel']) && $_POST['tel'] == '')
echo '<span class="erreur_ajo">Num. tel. manquant</span>'; echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Fonction:</td> <td><input type="text" name="fonction" id="fonction" value="'.@$_POST['fonction'].'">';
if(isset($_POST['fonction']) && $_POST['fonction'] == '')
echo '<span class="erreur_ajo">Fonction manquante</span>'; echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Droits*:</td> <td><select name="droit" id="droit">
<option value="1" '; if(@$_POST['droit'] == "1") echo 'selected="selected"'; echo '>1</option>
<option value="2" '; if(@$_POST['droit'] == "2") echo 'selected="selected"'; echo '>2</option>
<option value="3" '; if(@$_POST['droit'] == "3") echo 'selected="selected"'; echo '>3</option>
<option value="4" '; if(@$_POST['droit'] == "4") echo 'selected="selected"'; echo '>4</option>
$s_droits = "* ToutLesDroits(4) - ToutLesDroitsSaufGestionUtilisateurs(3)";
$color = true;
if (isset($_GET['action']) && $_GET['action'] == "ajouter") {
if (isset($_POST['pseudo']) && $_POST['pseudo'] != '' && !$connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_POST['pseudo'] . "'")->fetch() && isset($_POST['nom']) && $_POST['nom'] != '' && isset($_POST['prenom']) && $_POST['prenom'] != '' && isset($_POST['num_rue']) && $_POST['num_rue'] != '' && isset($_POST['rue']) && $_POST['rue'] != '' && isset($_POST['ville']) && $_POST['ville'] != '' && isset($_POST['tel']) && $_POST['tel'] != '' && isset($_POST['fonction']) && $_POST['fonction'] != '' && isset($_POST['mdp']) && $_POST['mdp'] != '') {
echo '<div style="text-align:center">';
if ($connexion->query("INSERT INTO `comptes` (`id_compte`, `nom`, `prenom`, `num_rue`, `rue`, `ville`, `tel`, `fonction`, `pseudo`, `mdp1`, `droit`, `suspendu`, `token`) VALUES (NULL, '" . $_POST['nom'] . "', '" . $_POST['prenom'] . "', '" . $_POST['num_rue'] . "', '" . $_POST['rue'] . "', '" . $_POST['ville'] . "', '" . $_POST['tel'] . "', '" . $_POST['fonction'] . "', '" . $_POST['pseudo'] . "', '" . md5($_POST['mdp']) . "', '" . $_POST['droit'] . "', '" . $_POST['suspendu'] . "', '0123');")) {
echo 'Utilisateur ajoute!</br></br>';
echo '<sub>Utilisateur: ' . $_POST['pseudo'] . '</br>';
echo 'Mot de passe: ' . $_POST['mdp'] . '</sub>';
} else {
echo 'Une erreur est survenue.. (Aucun utilisateur n\'a ete ajoute)';
}
echo '<br/><br/><sub><a href="?action=retour">Retour</a></sub></div>';
} else {
echo '<h1>Ajout d\'utilisateur</h1>';
echo '<form method="post">';
echo '<table width="800" border="0" cellspacing="3" cellpadding="0" align="center">';
echo '<tr> <td class="tab_ajout">Pseudo:</td> <td><input type="text" name="pseudo" id="pseudo" value="' . @$_POST['pseudo'] . '">';
if (isset($_POST['pseudo']) && $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_POST['pseudo'] . "'")->fetch())
echo '<span class="erreur_ajo">Pseudo deja utilise</span>';
elseif (isset($_POST['pseudo']) && $_POST['pseudo'] == '') echo '<span class="erreur_ajo">Pseudo manquant</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Nom:</td> <td><input type="text" name="nom" id="nom" value="' . @$_POST['nom'] . '">';
if (isset($_POST['nom']) && $_POST['nom'] == '')
echo '<span class="erreur_ajo">Nom manquant</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Prenom:</td> <td><input type="text" name="prenom" id="prenom" value="' . @$_POST['prenom'] . '">';
if (isset($_POST['prenom']) && $_POST['prenom'] == '')
echo '<span class="erreur_ajo">Prenom manquant</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Adresse:</td> <td><input name="num_rue" type="text" id="num_rue" size="10" maxlength="6" value="' . @$_POST['num_rue'] . '">
<input name="rue" type="text" id="rue" size="45" value="' . @$_POST['rue'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Ville:</td> <td><input name="ville" type="text" id="ville" size="45" value="' . @$_POST['ville'] . '">';
if (isset($_POST['num_rue']) && $_POST['num_rue'] == '' or isset($_POST['rue']) && $_POST['rue'] == '' or isset($_POST['ville']) && $_POST['ville'] == '')
echo '<span class="erreur_ajo">Adresse incomplete</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Tel.:</td> <td><input type="text" name="tel" id="tel" value="' . @$_POST['ville'] . '">';
if (isset($_POST['tel']) && $_POST['tel'] == '')
echo '<span class="erreur_ajo">Num. tel. manquant</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Fonction:</td> <td><input type="text" name="fonction" id="fonction" value="' . @$_POST['fonction'] . '">';
if (isset($_POST['fonction']) && $_POST['fonction'] == '')
echo '<span class="erreur_ajo">Fonction manquante</span>';
echo '</td> </tr>';
echo '<tr> <td class="tab_ajout">Droits*:</td> <td><select name="droit" id="droit">
<option value="1" ';
if (@$_POST['droit'] == "1") echo 'selected="selected"';
echo '>1</option>
<option value="2" ';
if (@$_POST['droit'] == "2") echo 'selected="selected"';
echo '>2</option>
<option value="3" ';
if (@$_POST['droit'] == "3") echo 'selected="selected"';
echo '>3</option>
<option value="4" ';
if (@$_POST['droit'] == "4") echo 'selected="selected"';
echo '>4</option>
</select></td> </tr>';
echo '<tr> <td class="tab_ajout">Suspendu:</td> <td><select name="suspendu" id="suspendu">
echo '<tr> <td class="tab_ajout">Suspendu:</td> <td><select name="suspendu" id="suspendu">
<option value="0">Non</option>
<option value="1" '; if(@$_POST['suspendu']) echo 'selected="selected"'; echo '>Oui</option>
<option value="1" ';
if (@$_POST['suspendu']) echo 'selected="selected"';
echo '>Oui</option>
</select></td> </tr>';
echo '<tr> <td class="tab_ajout">Mot de passe:</td> <td><input type="text" name="mdp" id="mdp" value="'.@$_POST['mdp'].'"> <a href="#" onClick="mdp.value=\''.mdp_gen(6).'\'; this.innerHTML=\'\'">Generer un mot de passe aleatoire</a>';
if(isset($_POST['mdp']) && $_POST['mdp'] == '')
echo '</br><span class="erreur_ajo">Mot de passe manquant</span>'; echo '</td> </tr>';
echo '</table><div style="text-align:center"><br/><input type="submit" value="Ajouter l\'utilisateur"></form>';
echo '<br/><br/><sub>'.$s_droits.'</sub></div>';
}
}
elseif(isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "modifier")
{
if(isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['num_rue']) && isset($_POST['rue']) && isset($_POST['ville']) && isset($_POST['tel']) && isset($_POST['fonction']))
{
$requ = "UPDATE `comptes` SET `token` ='0123'";
if(isset($_POST['nom']) && $_POST['nom'] != '') $requ .= ", `nom` = '".$_POST['nom']."'";
else echo '<span class="erreur_mod">- NOM non modifie -</span></br>';
if(isset($_POST['prenom']) && $_POST['prenom'] != '') $requ .= ", `prenom` = '".$_POST['prenom']."'";
else echo '<span class="erreur_mod">- PRENOM non modifie -</span></br>';
if(isset($_POST['num_rue']) && $_POST['num_rue'] != '') $requ .= ", `num_rue` = '".$_POST['num_rue']."'";
else echo '<span class="erreur_mod">- NUM. DE RUE non modifie -</span></br>';
if(isset($_POST['rue']) && $_POST['rue'] != '') $requ .= ", `rue` = '".$_POST['rue']."'";
else echo '<span class="erreur_mod">- RUE non modifie -</span></br>';
if(isset($_POST['ville']) && $_POST['ville'] != '') $requ .= ", `ville` = '".$_POST['ville']."'";
else echo '<span class="erreur_mod">- VILLE non modifie -</span></br>';
if(isset($_POST['tel']) && $_POST['tel'] != '') $requ .= ", `tel` = '".$_POST['tel']."'";
else echo '<span class="erreur_mod">- NUM. DE TEL. non modifie -</span></br>';
if(isset($_POST['fonction']) && $_POST['fonction'] != '') $requ .= ", `fonction` = '".$_POST['fonction']."'";
else echo '<span class="erreur_mod">- FONCTION non modifie -</span></br>';
if(isset($_POST['droit']) && $_POST['droit'] != '') $requ .= ", `droit` = '".$_POST['droit']."'";
if(isset($_POST['suspendu']) && $_POST['suspendu'] != '') $requ .= ", `suspendu` = '".$_POST['suspendu']."'";
if(isset($_POST['mdp']) && $_POST['mdp'] != '') $requ .= ", `mdp1` = '".md5($_POST['mdp'])."'";
$requ .= " WHERE `id_compte` =".$_GET['id'].";";
echo '<div style="text-align:center">';
if($connexion->query($requ))
{
echo 'Les modifications pour l\'utilisateur '.$_POST['pseudo'].' ont ete prises en compte!';
echo '<tr> <td class="tab_ajout">Mot de passe:</td> <td><input type="text" name="mdp" id="mdp" value="' . @$_POST['mdp'] . '"> <a href="#" onClick="mdp.value=\'' . mdp_gen(6) . '\'; this.innerHTML=\'\'">Generer un mot de passe aleatoire</a>';
if (isset($_POST['mdp']) && $_POST['mdp'] == '')
echo '</br><span class="erreur_ajo">Mot de passe manquant</span>';
echo '</td> </tr>';
echo '</table><div style="text-align:center"><br/><input type="submit" value="Ajouter l\'utilisateur"></form>';
echo '<br/><br/><sub>' . $s_droits . '</sub></div>';
}
else
{
echo 'Une erreur est survenue.. (Modifications non effectuees)';
}
echo '<br/><sub><a href="?action=retour">Retour</a></sub></div>';
}
else
{
if($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='".$_GET['id']."'"))
{
if($utilisateur = $result->fetch())
{
} elseif (isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "modifier") {
if (isset($_POST['nom']) && isset($_POST['prenom']) && isset($_POST['num_rue']) && isset($_POST['rue']) && isset($_POST['ville']) && isset($_POST['tel']) && isset($_POST['fonction'])) {
$requ = "UPDATE `comptes` SET `token` ='0123'";
if (isset($_POST['nom']) && $_POST['nom'] != '') $requ .= ", `nom` = '" . $_POST['nom'] . "'";
else echo '<span class="erreur_mod">- NOM non modifie -</span></br>';
if (isset($_POST['prenom']) && $_POST['prenom'] != '') $requ .= ", `prenom` = '" . $_POST['prenom'] . "'";
else echo '<span class="erreur_mod">- PRENOM non modifie -</span></br>';
if (isset($_POST['num_rue']) && $_POST['num_rue'] != '') $requ .= ", `num_rue` = '" . $_POST['num_rue'] . "'";
else echo '<span class="erreur_mod">- NUM. DE RUE non modifie -</span></br>';
if (isset($_POST['rue']) && $_POST['rue'] != '') $requ .= ", `rue` = '" . $_POST['rue'] . "'";
else echo '<span class="erreur_mod">- RUE non modifie -</span></br>';
if (isset($_POST['ville']) && $_POST['ville'] != '') $requ .= ", `ville` = '" . $_POST['ville'] . "'";
else echo '<span class="erreur_mod">- VILLE non modifie -</span></br>';
if (isset($_POST['tel']) && $_POST['tel'] != '') $requ .= ", `tel` = '" . $_POST['tel'] . "'";
else echo '<span class="erreur_mod">- NUM. DE TEL. non modifie -</span></br>';
if (isset($_POST['fonction']) && $_POST['fonction'] != '') $requ .= ", `fonction` = '" . $_POST['fonction'] . "'";
else echo '<span class="erreur_mod">- FONCTION non modifie -</span></br>';
if (isset($_POST['droit']) && $_POST['droit'] != '') $requ .= ", `droit` = '" . $_POST['droit'] . "'";
if (isset($_POST['suspendu']) && $_POST['suspendu'] != '') $requ .= ", `suspendu` = '" . $_POST['suspendu'] . "'";
if (isset($_POST['mdp']) && $_POST['mdp'] != '') $requ .= ", `mdp1` = '" . md5($_POST['mdp']) . "'";
$requ .= " WHERE `id_compte` =" . $_GET['id'] . ";";
echo '<div style="text-align:center">';
if ($connexion->query($requ)) {
echo 'Les modifications pour l\'utilisateur ' . $_POST['pseudo'] . ' ont ete prises en compte!';
} else {
echo 'Une erreur est survenue.. (Modifications non effectuees)';
}
echo '<br/><sub><a href="?action=retour">Retour</a></sub></div>';
} else {
if ($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='" . $_GET['id'] . "'")) {
if ($utilisateur = $result->fetch()) {
echo '<h1>Modification d\'utilisateur</h1>';
echo '<form method="post">';
echo '<table width="800" border="0" cellspacing="3" cellpadding="0" align="center">';
echo '<tr> <td class="tab_ajout">Pseudo:</td> <td><input type="text" readonly="true" name="pseudo" id="pseudo" value="'.$utilisateur['pseudo'].'"> (non-modifiable)</td> </tr>';
echo '<tr> <td class="tab_ajout">Nom:</td> <td><input type="text" name="nom" id="nom" value="'.$utilisateur['nom'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Prenom:</td> <td><input type="text" name="prenom" id="prenom" value="'.$utilisateur['prenom'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Adresse:</td> <td><input name="num_rue" type="text" id="num_rue" size="10" maxlength="6" value="'.$utilisateur['num_rue'].'">
<input name="rue" type="text" id="rue" size="45" value="'.$utilisateur['rue'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Ville:</td> <td><input name="ville" type="text" id="ville" size="45" value="'.$utilisateur['ville'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Tel.:</td> <td><input type="text" name="tel" id="tel" value="'.$utilisateur['tel'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Fonction:</td> <td><input type="text" name="fonction" id="fonction" value="'.$utilisateur['fonction'].'"></td> </tr>';
echo '<tr> <td class="tab_ajout">Pseudo:</td> <td><input type="text" readonly="true" name="pseudo" id="pseudo" value="' . $utilisateur['pseudo'] . '"> (non-modifiable)</td> </tr>';
echo '<tr> <td class="tab_ajout">Nom:</td> <td><input type="text" name="nom" id="nom" value="' . $utilisateur['nom'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Prenom:</td> <td><input type="text" name="prenom" id="prenom" value="' . $utilisateur['prenom'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Adresse:</td> <td><input name="num_rue" type="text" id="num_rue" size="10" maxlength="6" value="' . $utilisateur['num_rue'] . '">
<input name="rue" type="text" id="rue" size="45" value="' . $utilisateur['rue'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Ville:</td> <td><input name="ville" type="text" id="ville" size="45" value="' . $utilisateur['ville'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Tel.:</td> <td><input type="text" name="tel" id="tel" value="' . $utilisateur['tel'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Fonction:</td> <td><input type="text" name="fonction" id="fonction" value="' . $utilisateur['fonction'] . '"></td> </tr>';
echo '<tr> <td class="tab_ajout">Droits*:</td> <td><select name="droit" id="droit">
<option value="1" '; if($utilisateur['droit'] == "1") echo 'selected="selected"'; echo '>1</option>
<option value="2" '; if($utilisateur['droit'] == "2") echo 'selected="selected"'; echo '>2</option>
<option value="3" '; if($utilisateur['droit'] == "3") echo 'selected="selected"'; echo '>3</option>
<option value="4" '; if($utilisateur['droit'] == "4") echo 'selected="selected"'; echo '>4</option>
<option value="1" ';
if ($utilisateur['droit'] == "1") echo 'selected="selected"';
echo '>1</option>
<option value="2" ';
if ($utilisateur['droit'] == "2") echo 'selected="selected"';
echo '>2</option>
<option value="3" ';
if ($utilisateur['droit'] == "3") echo 'selected="selected"';
echo '>3</option>
<option value="4" ';
if ($utilisateur['droit'] == "4") echo 'selected="selected"';
echo '>4</option>
</select></td> </tr>';
echo '<tr> <td class="tab_ajout">Suspendu:</td> <td><select name="suspendu" id="suspendu">
<option value="0">Non</option>
<option value="1" '; if($utilisateur['suspendu'] == "1") echo 'selected="selected"'; echo '>Oui</option>
<option value="1" ';
if ($utilisateur['suspendu'] == "1") echo 'selected="selected"';
echo '>Oui</option>
</select></td> </tr>';
echo '<tr> <td class="tab_ajout">Nouveau mot de passe:</td> <td><input type="text" name="mdp" id="mdp"> (non-obligatoire)</td> </tr>';
echo '</table><div style="text-align:center"><br/><input type="submit" value="Enregistrer les modifications"></form>';
echo '<br/><br/><sub>'.$s_droits.'</sub></div>';
}
else
{
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: '.$_GET['id'].')';
echo '<br/><br/><sub>' . $s_droits . '</sub></div>';
} else {
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: ' . $_GET['id'] . ')';
echo '<hr width="800px"><sub><a href="?action=retour">Retour</a></sub>';
}
}
else
{
} else {
echo 'Une erreur est survenue.. (La requete n\'a pas aboutie)';
echo '<hr width="800px"><sub><a href="?action=retour">Retour</a></sub>';
}
}
}
elseif(isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "supprimer")
{
echo '<h1>Suppression d\'utilisateur</h1><div style="text-align:center">';
if(isset($_GET['token']))
{
if($connexion->query("DELETE FROM comptes WHERE id_compte='".$_GET['id']."'"))
echo 'Utilisateur supprime!';
else
echo 'Erreur lors de la suppression..';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
}
else
{
if($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='".$_GET['id']."'"))
{
if($utilisateur = $result->fetch())
{
echo 'Voulez-vous supprimer l\'utilisateur ('.$utilisateur['pseudo'].') '.$utilisateur['nom'].' '.$utilisateur['prenom'].'?</br>';
echo '<a href="?id='.$_GET['id'].'&action=supprimer&token='.$utilisateur['token'].'">Oui</a> - <a href="?id='.$_GET['id'].'">Non</a>';
echo '<br/><sub>L\'action de supprimer un utilisateur est irreversible..</sub>';
}
}
} elseif (isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "supprimer") {
echo '<h1>Suppression d\'utilisateur</h1><div style="text-align:center">';
if (isset($_GET['token'])) {
if ($connexion->query("DELETE FROM comptes WHERE id_compte='" . $_GET['id'] . "'"))
echo 'Utilisateur supprime!';
else
{
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: '.$_GET['id'].')';
echo 'Erreur lors de la suppression..';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
} else {
if ($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='" . $_GET['id'] . "'")) {
if ($utilisateur = $result->fetch()) {
echo 'Voulez-vous supprimer l\'utilisateur (' . $utilisateur['pseudo'] . ') ' . $utilisateur['nom'] . ' ' . $utilisateur['prenom'] . '?</br>';
echo '<a href="?id=' . $_GET['id'] . '&action=supprimer&token=' . $utilisateur['token'] . '">Oui</a> - <a href="?id=' . $_GET['id'] . '">Non</a>';
echo '<br/><sub>L\'action de supprimer un utilisateur est irreversible..</sub>';
} else {
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: ' . $_GET['id'] . ')';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
}
} else {
echo 'Une erreur est survenue.. (La requete n\'a pas aboutie)';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
}
}
else
{
echo 'Une erreur est survenue.. (La requete n\'a pas aboutie)';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
}
}
echo '</div>';
}
else
{
echo '<h1>Gestion des utilisateurs</h1>';
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>';
echo '<td>Pseudo</td>';
echo '<td>NOM Prenom</td>';
echo '<td>Fonction</td>';
echo '<td>Adresse</td>';
echo '<td>Tel.</td>';
echo '<td>Droits</td>';
echo '<td>Suspension</td>';
echo '<td>Actions</td>';
echo '</tr>';
$result = $connexion->query("SELECT * FROM comptes");
while($compte = $result->fetch())
{
$color = !$color;
if($color) $couleur = "#9CF"; else $couleur = "#9CC";
echo '<tr style="background-color:'.$couleur.';">';
echo '<td class="ligne">'.$compte['pseudo'].'</td>';
echo '<td class="ligne">'.$compte['nom'].' '.$compte['prenom'].'</td>';
echo '<td class="ligne">'.$compte['fonction'].'</td>';
echo '<td class="ligne">'.$compte['num_rue'].', '.$compte['rue'].'</br>'.$compte['ville'].'</td>';
echo '<td class="ligne">'.$compte['tel'].'</td>';
echo '<td class="ligne">'.$compte['droit'].'<sup>*</sup></td>';
echo '<td class="ligne">'; if($compte['suspendu']) echo 'Oui'; else echo 'Non'; echo '</td>';
echo '<td class="ligne"><a href="?id='.$compte['id_compte'].'&action=modifier">Modifier</a></br><a href="?id='.$compte['id_compte'].'&action=supprimer">Supprimer</a></td>';
echo '</div>';
} else {
echo '<h1>Gestion des utilisateurs</h1>';
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>';
echo '<td>Pseudo</td>';
echo '<td>NOM Prenom</td>';
echo '<td>Fonction</td>';
echo '<td>Adresse</td>';
echo '<td>Tel.</td>';
echo '<td>Droits</td>';
echo '<td>Suspension</td>';
echo '<td>Actions</td>';
echo '</tr>';
}
echo '</table></br>';
echo '&rarr; <a href="?action=ajouter">Ajouter un utilisateur</a>';
$result = $connexion->query("SELECT * FROM comptes");
while ($compte = $result->fetch()) {
$color = !$color;
if ($color) $couleur = "#9CF";
else $couleur = "#9CC";
echo '<br/><br/><sub>'.$s_droits.'</sub>';
}
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>
echo '<tr style="background-color:' . $couleur . ';">';
echo '<td class="ligne">' . $compte['pseudo'] . '</td>';
echo '<td class="ligne">' . $compte['nom'] . ' ' . $compte['prenom'] . '</td>';
echo '<td class="ligne">' . $compte['fonction'] . '</td>';
echo '<td class="ligne">' . $compte['num_rue'] . ', ' . $compte['rue'] . '</br>' . $compte['ville'] . '</td>';
echo '<td class="ligne">' . $compte['tel'] . '</td>';
echo '<td class="ligne">' . $compte['droit'] . '<sup>*</sup></td>';
echo '<td class="ligne">';
if ($compte['suspendu']) echo 'Oui';
else echo 'Non';
echo '</td>';
echo '<td class="ligne"><a href="?id=' . $compte['id_compte'] . '&action=modifier">Modifier</a></br><a href="?id=' . $compte['id_compte'] . '&action=supprimer">Supprimer</a></td>';
echo '</tr>';
}
echo '</table></br>';
echo '&rarr; <a href="?action=ajouter">Ajouter un utilisateur</a>';
echo '<br/><br/><sub>' . $s_droits . '</sub>';
}
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php');

View File

@ -1 +1,8 @@
<div id='tameteo' style='font-family:Arial;text-align:center;border:solid 1px #000000; background:#DCEDE0; width:145px; padding:4px'><a href='http://www.ta-meteo.fr/rosieres-en-haye' target='_blank' title='M<>t<EFBFBD>o Rosieres en haye' style='font-weight: bold;font-size:14px;text-decoration:none;color:#000000;line-height:12px;'>Rosieres en haye</a><br/><a href='http://www.ta-meteo.fr' target='_blank' title='ta-meteo'><img src='http://www.ta-meteo.fr/widget4/efb900373acd41209aa1c2458ac13c1a.png' border='0'></a><br/><a href='http://www.meteonet.org' style='font-size:10px;text-decoration:none;color:#000000;line-height:10px;' target='_blank' >&copy; Donn&eacute;es meteonet</a></div>
<div id='tameteo'
style='font-family:Arial;text-align:center;border:solid 1px #000000; background:#DCEDE0; width:145px; padding:4px'>
<a href='http://www.ta-meteo.fr/rosieres-en-haye' target='_blank' title='M<>t<EFBFBD>o Rosieres en haye'
style='font-weight: bold;font-size:14px;text-decoration:none;color:#000000;line-height:12px;'>Rosieres en
haye</a><br /><a href='http://www.ta-meteo.fr' target='_blank' title='ta-meteo'><img
src='http://www.ta-meteo.fr/widget4/efb900373acd41209aa1c2458ac13c1a.png' border='0'></a><br /><a
href='http://www.meteonet.org' style='font-size:10px;text-decoration:none;color:#000000;line-height:10px;'
target='_blank'>&copy; Donn&eacute;es meteonet</a></div>

View File

@ -5,13 +5,11 @@ $pass_bdd = 'Mot2Passe!';
$base_bdd = 'chateau2';
session_start();
$connexion = new PDO('mysql:host='.$host_bdd.';dbname='.$base_bdd, $user_bdd, $pass_bdd);
if(@$_SESSION['user'])
{
$result_infos_user = $connexion->query("SELECT * FROM comptes WHERE pseudo='".$_SESSION['user']."'");
$connexion = new PDO('mysql:host=' . $host_bdd . ';dbname=' . $base_bdd, $user_bdd, $pass_bdd);
if (@$_SESSION['user']) {
$result_infos_user = $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_SESSION['user'] . "'");
$infos_user = $result_infos_user->fetch();
if($_SESSION['token'] != $infos_user['token'])
{
if ($_SESSION['token'] != $infos_user['token']) {
$_SESSION['user'] = '';
$_SESSION['token'] = '';
$infos_user = 0;
@ -19,4 +17,3 @@ if(@$_SESSION['user'])
}
$result_nb_alertes = $connexion->query("SELECT count(*) FROM alertes WHERE acquitte='0'")->fetchColumn();
?>

View File

@ -1,117 +1,109 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au']))
{
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else {
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_temp = $connexion->query("SELECT * FROM relevage WHERE heure='23:30:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_temp = $connexion->query("SELECT * FROM relevage WHERE heure='23:30:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$while_date = $date1;
$while_date = $date1;
$s_date = '';
$s_date = '';
while(strtotime($while_date) <= strtotime($date2))
{
$tab_pp1[$while_date] = 'null';
$tab_pp2[$while_date] = 'null';
while (strtotime($while_date) <= strtotime($date2)) {
$tab_pp1[$while_date] = 'null';
$tab_pp2[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_date)).'",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_date)) . '",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
while($fetch = $result_temp->fetch())
{
$tab_pp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pp2[$fetch['date']] = $fetch['temp_marche_pp2'];
}
while ($fetch = $result_temp->fetch()) {
$tab_pp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pp2[$fetch['date']] = $fetch['temp_marche_pp2'];
}
$s_temp_pp1 = '';
$s_temp_pp2= '';
$s_temp_pp1 = '';
$s_temp_pp2 = '';
$while_date = $date1;
$while_date = $date1;
for($i = 0; $i < count($tab_pp1); $i++)
{
$s_temp_pp1 = $s_temp_pp1.$tab_pp1[$while_date].',';
$s_temp_pp2 = $s_temp_pp2.$tab_pp2[$while_date].',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
?>
for ($i = 0; $i < count($tab_pp1); $i++) {
$s_temp_pp1 = $s_temp_pp1 . $tab_pp1[$while_date] . ',';
$s_temp_pp2 = $s_temp_pp2 . $tab_pp2[$while_date] . ',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement cumulé des pompes de la station de relevage<br/>du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
/*subtitle: {
text: 'Temps de fonctionnement des pompes',
x: -20
},*/
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Temps (heures)'
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'x'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
title: {
text: 'Temps de fonctionnement cumulé des pompes de la station de relevage<br/>du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
/*subtitle: {
text: 'Temps de fonctionnement des pompes',
x: -20
},*/
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Temps (heures)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'H'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps pompe 1',
data: [<?php echo $s_temp_pp1; ?>]
}, {
name: 'Temps pompe 2',
data: [<?php echo $s_temp_pp2; ?>]
}]
},
tooltip: {
valueSuffix: 'H'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps pompe 1',
data: [<?php echo $s_temp_pp1;?>]
}, {
name: 'Temps pompe 2',
data: [<?php echo $s_temp_pp2;?>]
}]
});
});
});
</script>
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,141 +1,133 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au']))
{
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else {
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_pomp = $connexion->query("SELECT * FROM relevage WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_pomp = $connexion->query("SELECT * FROM relevage WHERE heure='00:15:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$s_date = '';
$i = 0;
$s_date = '';
$i = 0;
while($fetch = $result_pomp->fetch())
{
$s_date = $s_date.'"'.date("d/m/y", strtotime($fetch['date'])).'",';
$tab_pomp1[$i] = $fetch['temp_marche_pp1'];
$tab_pomp2[$i] = $fetch['temp_marche_pp2'];
$i++;
}
while ($fetch = $result_pomp->fetch()) {
$s_date = $s_date . '"' . date("d/m/y", strtotime($fetch['date'])) . '",';
$tab_pomp1[$i] = $fetch['temp_marche_pp1'];
$tab_pomp2[$i] = $fetch['temp_marche_pp2'];
$i++;
}
$s_pomp1 = '';
$s_pomp2= '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$s_pomp1 = '';
$s_pomp2 = '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$while_date = $date1;
for($i = 0; $i < @count($tab_pomp1)-1; $i++)
{
$volume = $tab_pomp1[$i+1] - $tab_pomp1[$i];
if ($volume<$vol_minp1) $vol_minp1 = $volume;
if ($volume>$vol_maxp1) $vol_maxp1 = $volume;
$vol_totp1 = $vol_totp1 + $volume;
$s_pomp1 = $s_pomp1.($volume).',';
}
$while_date = $date1;
for ($i = 0; $i < @count($tab_pomp1) - 1; $i++) {
$volume = $tab_pomp1[$i + 1] - $tab_pomp1[$i];
if ($volume < $vol_minp1) $vol_minp1 = $volume;
if ($volume > $vol_maxp1) $vol_maxp1 = $volume;
$vol_totp1 = $vol_totp1 + $volume;
$s_pomp1 = $s_pomp1 . ($volume) . ',';
}
$while_date = $date1;
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
for($i = 0; $i < @count($tab_pomp2)-1; $i++)
{
$volume = $tab_pomp2[$i+1] - $tab_pomp2[$i];
if ($volume<$vol_minp2) $vol_minp2 = $volume;
if ($volume>$vol_maxp2) $vol_maxp2 = $volume;
$vol_totp2 = $vol_totp2 + $volume;
$s_pomp2 = $s_pomp2.($tab_pomp2[$i+1] - $tab_pomp2[$i]).',';
}
$while_date = $date1;
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
for ($i = 0; $i < @count($tab_pomp2) - 1; $i++) {
$volume = $tab_pomp2[$i + 1] - $tab_pomp2[$i];
if ($volume < $vol_minp2) $vol_minp2 = $volume;
if ($volume > $vol_maxp2) $vol_maxp2 = $volume;
$vol_totp2 = $vol_totp2 + $volume;
$s_pomp2 = $s_pomp2 . ($tab_pomp2[$i + 1] - $tab_pomp2[$i]) . ',';
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours); // moyenne par jour
$vmoyp2=$vol_totp2/($Nbjours); // moyenne par jour
?>
$vmoyp1 = $vol_totp1 / ($Nbjours); // moyenne par jour
$vmoyp2 = $vol_totp2 / ($Nbjours); // moyenne par jour
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement des pompes de la station de relavage<br/>du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>".round($vol_totp1, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp1, 2)."</b> H -- Tmin = <b>".round($vol_minp1, 2)."</b> H -- TMax = <b>".round($vol_maxp1, 2)."</b> H<br/>T.F. pompe2 ";
if($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>".round($vol_totp2, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp2, 2)."</b> H -- Tmin = <b>".round($vol_minp2, 2)."</b> H -- TMax = <b>".round($vol_maxp2, 2)."</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'H'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1;?>]
}, {
name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2;?>]
}]
});
});
</script>
title: {
text: 'Temps de fonctionnement des pompes de la station de relavage<br/>du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if ($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>" . round($vol_totp1, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp1, 2) . "</b> H -- Tmin = <b>" . round($vol_minp1, 2) . "</b> H -- TMax = <b>" . round($vol_maxp1, 2) . "</b> H<br/>T.F. pompe2 ";
if ($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>" . round($vol_totp2, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp2, 2) . "</b> H -- Tmin = <b>" . round($vol_minp2, 2) . "</b> H -- TMax = <b>" . round($vol_maxp2, 2) . "</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'H'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1; ?>]
}, {
name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2; ?>]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,178 +1,162 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues
{
$date1 = date("Y-m-d", strtotime("-1 day", strtotime($_GET['du'])));
$date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else //Sinon on prend les valeurs du dernier mois
{
$date1bis = $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d', strtotime("+1 day", strtotime(date('Y-m-d'))));
}
$result_vol_6 = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_vol_22 = $connexion->query("SELECT * FROM chateau WHERE heure='22:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$while_date = $date1;
$s_date = '';
while(strtotime($while_date) <= strtotime($date2))
{
$tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_datebis = $date1bis;
while(strtotime($while_datebis) <= strtotime($date2))
{
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_datebis)).'",';
$while_datebis = date("Y-m-d", strtotime("+1 day", strtotime($while_datebis)));
}
while($fetch = $result_vol_6->fetch()) //On remplie tab_vol_6 avec les valeurs de la bdd
{
$tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion'];
}
while($fetch = $result_vol_22->fetch()) //On remplie tab_vol_22 avec les valeurs de la bdd
{
$tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion'];
}
$s_vol_6 = '';
$s_vol_22= '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$Nbjours_V1=0;
$while_date = $date1;
for($i = 0; $i < count($tab_vol_6); $i++)//On remplie s_vol_6 des valeurs de la bdd pour highchart
{
if(isset($tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null')
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues
{
$vol = ($tab_vol_6[$while_date]-$tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
$Nbjours_V1++;
$vol = round($vol, 2);
if ($vol<$volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.','; //On ajoute la valeur au tableau
$date1 = date("Y-m-d", strtotime("-1 day", strtotime($_GET['du'])));
$date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else //Sinon on prend les valeurs du dernier mois
{
$date1bis = $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d', strtotime("+1 day", strtotime(date('Y-m-d'))));
}
else if ($i != 0) $s_vol_6 = $s_vol_6.'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$result_vol_6 = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$result_vol_22 = $connexion->query("SELECT * FROM chateau WHERE heure='22:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$while_date = $date1;
$s_date = '';
while (strtotime($while_date) <= strtotime($date2)) {
$tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_datebis = $date1bis;
while (strtotime($while_datebis) <= strtotime($date2)) {
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_datebis)) . '",';
$while_datebis = date("Y-m-d", strtotime("+1 day", strtotime($while_datebis)));
}
while ($fetch = $result_vol_6->fetch()) //On remplie tab_vol_6 avec les valeurs de la bdd
{
$tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion'];
}
while ($fetch = $result_vol_22->fetch()) //On remplie tab_vol_22 avec les valeurs de la bdd
{
$tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion'];
}
$s_vol_6 = '';
$s_vol_22 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$Nbjours_V1 = 0;
$while_date = $date1;
for ($i = 0; $i < count($tab_vol_6); $i++) //On remplie s_vol_6 des valeurs de la bdd pour highchart
{
if (isset($tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null') {
$vol = ($tab_vol_6[$while_date] - $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
$Nbjours_V1++;
$vol = round($vol, 2);
if ($vol < $volmin) $volmin = $vol;
if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_vol_6 = $s_vol_6 . 'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoy=$voltot/($Nbjours); // moyenne par jour
$vmoy = $voltot / ($Nbjours); // moyenne par jour
$result_pomp = $connexion->query("SELECT * FROM relevage WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_pomp = $connexion->query("SELECT * FROM relevage WHERE heure='00:15:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$i = 0;
$i = 0;
while($fetch = $result_pomp->fetch()) //On remplie tab_pomp1 et tab_pomp2 avec les valeurs de la bdd
{
$tab_pomp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['temp_marche_pp2'];
}
$s_pomp1 = '';
$s_pomp2= '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$Nbjours_P1 = 0;
$while_date = $date1;
for($i = 0; $i < $Nbjours+1;$i++)//On remplie s_pomp1 des valeurs de la bdd pour highchart
{
if(isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0)
while ($fetch = $result_pomp->fetch()) //On remplie tab_pomp1 et tab_pomp2 avec les valeurs de la bdd
{
if(!isset($tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if(isset($tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]))
{
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$tab_pomp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['temp_marche_pp2'];
}
$s_pomp1 = '';
$s_pomp2 = '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$Nbjours_P1 = 0;
$while_date = $date1;
for ($i = 0; $i < $Nbjours + 1; $i++) //On remplie s_pomp1 des valeurs de la bdd pour highchart
{
if (isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0) {
if (!isset($tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if (isset($tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) {
$vol = $tab_pomp1[$while_date] - $tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P1++;
} else
$vol = '0';
else {
$vol = $tab_pomp1[$while_date] - $tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P1++;
}
else
$vol ='0';
else
{
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P1++;
}
$vol = round($vol, 2);
if ($vol<$vol_minp1) $vol_minp1 = $vol;
if ($vol>$vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $vol;
$vol = round($vol, 2);
if ($vol < $vol_minp1) $vol_minp1 = $vol;
if ($vol > $vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $vol;
$s_pomp1 = $s_pomp1.$vol.','; //On ajoute la valeur au tableau
$s_pomp1 = $s_pomp1 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_pomp1 = $s_pomp1 . 'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
else if ($i != 0) $s_pomp1 = $s_pomp1.'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
$Nbjours_P2=0;
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
$Nbjours_P2 = 0;
$while_date = $date1;
for($i = 0; $i < $Nbjours+1; $i++)//On remplie s_pomp2 des valeurs de la bdd pour highchart
{
if(isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0)
$while_date = $date1;
for ($i = 0; $i < $Nbjours + 1; $i++) //On remplie s_pomp2 des valeurs de la bdd pour highchart
{
if(!isset($tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if(isset($tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]))
{
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
if (isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0) {
if (!isset($tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if (isset($tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) {
$vol = $tab_pomp2[$while_date] - $tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P2++;
} else
$vol = '0';
else {
$vol = $tab_pomp2[$while_date] - $tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P2++;
}
else
$vol='0';
else
{
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P2++;
}
$vol = round($vol, 2);
if ($vol<$vol_minp2) $vol_minp2 = $vol;
if ($vol>$vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $vol;
$vol = round($vol, 2);
if ($vol < $vol_minp2) $vol_minp2 = $vol;
if ($vol > $vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $vol;
$s_pomp2 = $s_pomp2.$vol.','; //On ajoute la valeur au tableau
$s_pomp2 = $s_pomp2 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_pomp2 = $s_pomp2 . 'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
else if ($i != 0) $s_pomp2 = $s_pomp2.'null,'; //Si aucune valeur on met null dans le tableau
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
@ -180,118 +164,117 @@ for($i = 0; $i < $Nbjours+1; $i++)//On remplie s_pomp2 des valeurs de la bdd pou
//$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours_P1); // moyenne par jour
$vmoyp2=$vol_totp2/($Nbjours_P2); // moyenne par jour
$vmoy=$voltot/($Nbjours_V1); // moyenne par jour
?>
$vmoyp1 = $vol_totp1 / ($Nbjours_P1); // moyenne par jour
$vmoyp2 = $vol_totp2 / ($Nbjours_P2); // moyenne par jour
$vmoy = $voltot / ($Nbjours_V1); // moyenne par jour
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1bis;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1bis; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
alignTicks: false,
type: 'column',
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement des pompes de la station de relavage<br/>du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>".round($vol_totp1, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp1, 2)."</b> H (".$Nbjours_P1."J) -- Tmin = <b>".round($vol_minp1, 2)."</b> H -- TMax = <b>".round($vol_maxp1, 2)."</b> H<br/>T.F. pompe2 ";
if($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>".round($vol_totp2, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp2, 2)."</b> H (".$Nbjours_P2."J) -- Tmin = <b>".round($vol_minp2, 2)."</b> H -- TMax = <b>".round($vol_maxp2, 2)."</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
alignTicks: false,
type: 'column',
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement des pompes de la station de relavage<br/>du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if ($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>" . round($vol_totp1, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp1, 2) . "</b> H (" . $Nbjours_P1 . "J) -- Tmin = <b>" . round($vol_minp1, 2) . "</b> H -- TMax = <b>" . round($vol_maxp1, 2) . "</b> H<br/>T.F. pompe2 ";
if ($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>" . round($vol_totp2, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp2, 2) . "</b> H (" . $Nbjours_P2 . "J) -- Tmin = <b>" . round($vol_minp2, 2) . "</b> H -- TMax = <b>" . round($vol_maxp2, 2) . "</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
yAxis: [{ // Primary yAxis
title: {
text: 'Volume',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
yAxis: [{ // Primary yAxis
title: {
text: 'Volume',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Heure (H)',
style: {
color: Highcharts.getOptions().colors[2]
}
},
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Heure (H)',
style: {
color: Highcharts.getOptions().colors[2]
}
},
}],
}],
tooltip: {
valueSuffix: 'H'
},
plotOptions: {
column: {
stacking: 'normal'
}
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1;?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#32CD32'
}, {
name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2;?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#008000'
}, {
name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6;?>],
stack: 'volume',
yAxis: 0,
color: '#00BFFF',
tooltip: {
valueSuffix: ''
}
valueSuffix: 'H'
},
}]
});
});
</script>
plotOptions: {
column: {
stacking: 'normal'
}
},
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1; ?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#32CD32'
}, {
name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2; ?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#008000'
}, {
name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6; ?>],
stack: 'volume',
yAxis: 0,
color: '#00BFFF',
tooltip: {
valueSuffix: 'm³'
}
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
if($voltot == 0) $volmin = 0;
echo "Volume pompé --- V total = <b>".round($voltot, 2)."</b> m³ -- Tmoy/jour = <b>".round($vmoy, 2)."</b> m³ (".$Nbjours_V1."J) -- Tmin = <b>".round($volmin, 2)."</b> m³ -- TMax = <b>".round($volmax, 2)."</b> m³ --- ";
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
if ($voltot == 0) $volmin = 0;
echo "Volume pompé --- V total = <b>" . round($voltot, 2) . "</b> m³ -- Tmoy/jour = <b>" . round($vmoy, 2) . "</b> m³ (" . $Nbjours_V1 . "J) -- Tmin = <b>" . round($volmin, 2) . "</b> m³ -- TMax = <b>" . round($volmax, 2) . "</b> m³ --- ";
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -2,61 +2,61 @@
/* CSS Document BY BREGAND Alexis */
a:link {
color:#06C;
text-decoration:none;
color: #06C;
text-decoration: none;
}
a:visited {
text-decoration:none;
color:#06C;
text-decoration: none;
color: #06C;
}
a:hover {
text-decoration:none;
color:#09F;
text-decoration: none;
color: #09F;
}
a:active {
text-decoration:none;
color:#09F;
text-decoration: none;
color: #09F;
}
hr {
border:0;
border-top:1px solid #000;
border: 0;
border-top: 1px solid #000;
}
h1 {
text-align:center;
text-align: center;
}
.options {
text-align:center;
padding:5px;
border:1px dashed #000;
text-align: center;
padding: 5px;
border: 1px dashed #000;
}
.tab_ajout {
text-align:right;
width:325px;
text-align: right;
width: 325px;
}
.oubli {
width:800px;
border:1px dashed red;
background-color:#FCC;
margin:auto;
width: 800px;
border: 1px dashed red;
background-color: #FCC;
margin: auto;
}
.erreur_mod {
background-color:#FCC;
padding:3px;
background-color: #FCC;
padding: 3px;
}
.erreur_ajo {
background-color:#FCC;
padding:2px;
margin:2px;
background-color: #FCC;
padding: 2px;
margin: 2px;
}
.ds_box {

View File

@ -1,181 +1,162 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues
{
$date1 = date("Y-m-d", strtotime("-1 day", strtotime($_GET['du']))); // On enlève 1 jour à la date de départ et on converti en date le timestamp
$date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else //Sinon on prend les valeurs du dernier mois
{
$date1bis = $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); // On soustrait 1 mois (pour pouvoir effectuer un calcul plus tard)
$date2 = date('Y-m-d', strtotime("+1 day", strtotime(date('Y-m-d'))));
}
$result_vol_6 = $connexion->query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC"); // On effectue une requête pour récupérer les données
$while_date = $date1;
$s_date = ''; // On initialise
while(strtotime($while_date) <= strtotime($date2))
{
$tab_vol_6[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_datebis = $date1bis;
while(strtotime($while_datebis) <= strtotime($date2))
{
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_datebis)).'",';
$while_datebis = date("Y-m-d", strtotime("+1 day", strtotime($while_datebis)));
}
while($fetch = $result_vol_6->fetch()) //On remplie tab_vol_6 avec les valeurs de la bdd
{
$tab_vol_6[$fetch['date']] = $fetch['volume'];
}
$s_vol_6 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$Nbjours_V1=0;
$while_date = $date1;
for($i = 0; $i < count($tab_vol_6); $i++)//On remplie s_vol_6 des valeurs de la bdd pour highchart
{
if(isset($tab_vol_6[$while_date]) && $tab_vol_6[$while_date] != 'null' and $i != 0)
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues
{
if($tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] == 'null')//On vérifie que la valeur précédente éxiste
if($tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))] != 'null')
{
$vol = $tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_V1++;//Compte le nombre de jours avec valeur
}
else
$vol ='0';
else
{
$vol = $tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_V1++;//Compte le nombre de jours avec valeur
}
$vol = round($vol, 2);
if ($vol<$volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.','; //On ajoute la valeur au tableau
$date1 = date("Y-m-d", strtotime("-1 day", strtotime($_GET['du']))); // On enlève 1 jour à la date de départ et on converti en date le timestamp
$date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else //Sinon on prend les valeurs du dernier mois
{
$date1bis = $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); // On soustrait 1 mois (pour pouvoir effectuer un calcul plus tard)
$date2 = date('Y-m-d', strtotime("+1 day", strtotime(date('Y-m-d'))));
}
else if ($i != 0) $s_vol_6 = $s_vol_6.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$result_vol_6 = $connexion->query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC"); // On effectue une requête pour récupérer les données
$while_date = $date1;
$s_date = ''; // On initialise
while (strtotime($while_date) <= strtotime($date2)) {
$tab_vol_6[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_datebis = $date1bis;
while (strtotime($while_datebis) <= strtotime($date2)) {
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_datebis)) . '",';
$while_datebis = date("Y-m-d", strtotime("+1 day", strtotime($while_datebis)));
}
while ($fetch = $result_vol_6->fetch()) //On remplie tab_vol_6 avec les valeurs de la bdd
{
$tab_vol_6[$fetch['date']] = $fetch['volume'];
}
$s_vol_6 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$Nbjours_V1 = 0;
$while_date = $date1;
for ($i = 0; $i < count($tab_vol_6); $i++) //On remplie s_vol_6 des valeurs de la bdd pour highchart
{
if (isset($tab_vol_6[$while_date]) && $tab_vol_6[$while_date] != 'null' and $i != 0) {
if ($tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] == 'null') //On vérifie que la valeur précédente éxiste
if ($tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))] != 'null') {
$vol = $tab_vol_6[$while_date] - $tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_V1++; //Compte le nombre de jours avec valeur
} else
$vol = '0';
else {
$vol = $tab_vol_6[$while_date] - $tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_V1++; //Compte le nombre de jours avec valeur
}
$vol = round($vol, 2);
if ($vol < $volmin) $volmin = $vol;
if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_vol_6 = $s_vol_6 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoy=$voltot/($Nbjours); // moyenne par jour
$vmoy = $voltot / ($Nbjours); // moyenne par jour
$result_pomp = $connexion->query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_pomp = $connexion->query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$i = 0;
$i = 0;
while($fetch = $result_pomp->fetch()) //On remplie tab_pomp1 et tab_pomp2 avec les valeurs de la bdd
{
$tab_pomp1[$fetch['date']] = $fetch['horaire_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['horaire_pp2'];
}
$s_pomp1 = '';
$s_pomp2= '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$Nbjours_P1=0;
$while_date = $date1;
for($i = 0; $i < $Nbjours+1; $i++)//On remplie $s_pomp1 des valeurs de la bdd pour highchart
{
if(isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0)
while ($fetch = $result_pomp->fetch()) //On remplie tab_pomp1 et tab_pomp2 avec les valeurs de la bdd
{
if(!isset($tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]))//On vérifie que la valeur précédente éxiste
if(isset($tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]))
{
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P1++;//Compte le nombre de jours avec valeur
}
else
$vol ='0';
else
{
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P1++;//Compte le nombre de jours avec valeur
}
$vol = round($vol, 2);
if ($vol<$vol_minp1) $vol_minp1 = $vol;
if ($vol>$vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $vol;
$s_pomp1 = $s_pomp1.$vol.','; //On ajoute la valeur au tableau
$tab_pomp1[$fetch['date']] = $fetch['horaire_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['horaire_pp2'];
}
else if ($i != 0) $s_pomp1 = $s_pomp1.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
$Nbjours_P2=0;
$s_pomp1 = '';
$s_pomp2 = '';
$vol_maxp1 = 0;
$vol_minp1 = 100;
$vol_totp1 = 0;
$Nbjours_P1 = 0;
$while_date = $date1;
for($i = 0; $i < $Nbjours+1; $i++)//On remplie $s_pomp2 des valeurs de la bdd pour highchart
{
if(isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0)
$while_date = $date1;
for ($i = 0; $i < $Nbjours + 1; $i++) //On remplie $s_pomp1 des valeurs de la bdd pour highchart
{
if(!isset($tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]))//On vérifie que la valeur précédente éxiste
if(isset($tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]))
{
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P2++;//Compte le nombre de jours avec valeur
if (isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0) {
if (!isset($tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if (isset($tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) {
$vol = $tab_pomp1[$while_date] - $tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P1++; //Compte le nombre de jours avec valeur
} else
$vol = '0';
else {
$vol = $tab_pomp1[$while_date] - $tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P1++; //Compte le nombre de jours avec valeur
}
else
$vol='0';
else
{
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P2++;//Compte le nombre de jours avec valeur
}
$vol = round($vol, 2);
if ($vol<$vol_minp2) $vol_minp2 = $vol;
if ($vol>$vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $vol;
$vol = round($vol, 2);
if ($vol < $vol_minp1) $vol_minp1 = $vol;
if ($vol > $vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $vol;
$s_pomp2 = $s_pomp2.$vol.','; //On ajoute la valeur au tableau
$s_pomp1 = $s_pomp1 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_pomp1 = $s_pomp1 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$vol_maxp2 = 0;
$vol_minp2 = 100;
$vol_totp2 = 0;
$Nbjours_P2 = 0;
$while_date = $date1;
for ($i = 0; $i < $Nbjours + 1; $i++) //On remplie $s_pomp2 des valeurs de la bdd pour highchart
{
if (isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0) {
if (!isset($tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))])) //On vérifie que la valeur précédente éxiste
if (isset($tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) {
$vol = $tab_pomp2[$while_date] - $tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))];
$Nbjours_P2++; //Compte le nombre de jours avec valeur
} else
$vol = '0';
else {
$vol = $tab_pomp2[$while_date] - $tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))];
$Nbjours_P2++; //Compte le nombre de jours avec valeur
}
$vol = round($vol, 2);
if ($vol < $vol_minp2) $vol_minp2 = $vol;
if ($vol > $vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $vol;
$s_pomp2 = $s_pomp2 . $vol . ','; //On ajoute la valeur au tableau
} else if ($i != 0) $s_pomp2 = $s_pomp2 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
else if ($i != 0) $s_pomp2 = $s_pomp2.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
@ -183,119 +164,117 @@ for($i = 0; $i < $Nbjours+1; $i++)//On remplie $s_pomp2 des valeurs de la bdd p
//$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours_P1); // moyenne par jour
$vmoyp2=$vol_totp2/($Nbjours_P2); // moyenne par jour
$vmoy=$voltot/($Nbjours_V1); // moyenne par jour
?>
$vmoyp1 = $vol_totp1 / ($Nbjours_P1); // moyenne par jour
$vmoyp2 = $vol_totp2 / ($Nbjours_P2); // moyenne par jour
$vmoy = $voltot / ($Nbjours_V1); // moyenne par jour
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1bis;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1bis; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
alignTicks: false,
type: 'column',
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement des pompes du surpresseur<br/>du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>".round($vol_totp1, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp1, 2)."</b> H (".$Nbjours_P1."J) -- Tmin = <b>".round($vol_minp1, 2)."</b> H -- TMax = <b>".round($vol_maxp1, 2)."</b> H<br/>T.F. pompe2 ";
if($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>".round($vol_totp2, 2)."</b> H -- Tmoy/jour = <b>".round($vmoyp2, 2)."</b> H (".$Nbjours_P2."J) -- Tmin = <b>".round($vol_minp2, 2)."</b> H -- TMax = <b>".round($vol_maxp2, 2)."</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
alignTicks: false,
type: 'column',
zoomType: 'x'
},
title: {
text: 'Temps de fonctionnement des pompes du surpresseur<br/>du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'T.F. pompe1 ";
if ($vol_totp1 == 0) $vol_minp1 = 0;
echo " --- T total = <b>" . round($vol_totp1, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp1, 2) . "</b> H (" . $Nbjours_P1 . "J) -- Tmin = <b>" . round($vol_minp1, 2) . "</b> H -- TMax = <b>" . round($vol_maxp1, 2) . "</b> H<br/>T.F. pompe2 ";
if ($vol_totp2 == 0) $vol_minp2 = 0;
echo " --- T total = <b>" . round($vol_totp2, 2) . "</b> H -- Tmoy/jour = <b>" . round($vmoyp2, 2) . "</b> H (" . $Nbjours_P2 . "J) -- Tmin = <b>" . round($vol_minp2, 2) . "</b> H -- TMax = <b>" . round($vol_maxp2, 2) . "</b> H'";
?>
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Heure (H)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
yAxis: [{ // Primary yAxis
title: {
text: 'Volume',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
yAxis: [{ // Primary yAxis
title: {
text: 'Volume',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Heure (H)',
style: {
color: Highcharts.getOptions().colors[2]
}
},
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Heure (H)',
style: {
color: Highcharts.getOptions().colors[2]
}
},
}],
}],
tooltip: {
valueSuffix: 'H'
},
plotOptions: {
column: {
stacking: 'normal'
}
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de compresseur pompe 1',
data: [<?php echo $s_pomp1;?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#32CD32'
}, {
name: 'Temps de compresseurpompe 2',
data: [<?php echo $s_pomp2;?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#008000'
}, {
name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6;?>],
stack: 'volume',
yAxis: 0,
color: '#00BFFF',
tooltip: {
valueSuffix: ''
}
valueSuffix: 'H'
},
}]
});
});
</script>
plotOptions: {
column: {
stacking: 'normal'
}
},
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temps de compresseur pompe 1',
data: [<?php echo $s_pomp1; ?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#32CD32'
}, {
name: 'Temps de compresseurpompe 2',
data: [<?php echo $s_pomp2; ?>],
stack: 'heure_pompe',
yAxis: 1,
color: '#008000'
}, {
name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6; ?>],
stack: 'volume',
yAxis: 0,
color: '#00BFFF',
tooltip: {
valueSuffix: 'm³'
}
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
if($voltot == 0) $volmin = 0;
echo "Volume pompé --- V total = <b>".round($voltot, 2)."</b> m³ -- Tmoy/jour = <b>".round($vmoy, 2)."</b> m³ (".$Nbjours_V1."J) -- Tmin = <b>".round($volmin, 2)."</b> m³ -- TMax = <b>".round($volmax, 2)."</b> m³ --- ";
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
if ($voltot == 0) $volmin = 0;
echo "Volume pompé --- V total = <b>" . round($voltot, 2) . "</b> m³ -- Tmoy/jour = <b>" . round($vmoy, 2) . "</b> m³ (" . $Nbjours_V1 . "J) -- Tmin = <b>" . round($volmin, 2) . "</b> m³ -- TMax = <b>" . round($volmax, 2) . "</b> m³ --- ";
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,147 +1,139 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au']))
{
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else {
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_temp = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_temp = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$while_date = $date1;
$while_date = $date1;
$s_date = '';
$s_date = '';
while(strtotime($while_date) <= strtotime($date2))
{
$tab_amb[$while_date] = 'null';
$tab_col[$while_date] = 'null';
while (strtotime($while_date) <= strtotime($date2)) {
$tab_amb[$while_date] = 'null';
$tab_col[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_date)).'",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_date)) . '",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
while($fetch = $result_temp->fetch())
{
$tab_amb[$fetch['date']] = $fetch['temp_ambiante'];
$tab_col[$fetch['date']] = $fetch['temp_colonne'];
}
while ($fetch = $result_temp->fetch()) {
$tab_amb[$fetch['date']] = $fetch['temp_ambiante'];
$tab_col[$fetch['date']] = $fetch['temp_colonne'];
}
$s_temp_amb = '';
$s_temp_col= '';
$temp_ambmin = 100;
$temp_ambmax = 0;
$temp_ambtot = 0;
$temp_colmin = 100;
$temp_colmax = 0;
$temp_coltot = 0;
$s_temp_amb = '';
$s_temp_col = '';
$temp_ambmin = 100;
$temp_ambmax = 0;
$temp_ambtot = 0;
$temp_colmin = 100;
$temp_colmax = 0;
$temp_coltot = 0;
$while_date = $date1;
$while_date = $date1;
for($i = 0; $i < count($tab_amb); $i++)
{
// recherche mini et Maxi calcul total
$temp_amb = $tab_amb[$while_date];
$temp_col = $tab_col[$while_date];
if ($temp_amb<$temp_ambmin) $temp_ambmin = $temp_amb;
if ($temp_amb>$temp_ambmax) $temp_ambmax = $temp_amb;
if ($temp_col<$temp_colmin) $temp_colmin = $temp_col;
if ($temp_col>$temp_colmax) $temp_colmax = $temp_col;
$temp_ambtot = $temp_ambtot + $temp_amb;
$temp_coltot = $temp_coltot + $temp_col;
for ($i = 0; $i < count($tab_amb); $i++) {
// recherche mini et Maxi calcul total
$temp_amb = $tab_amb[$while_date];
$temp_col = $tab_col[$while_date];
if ($temp_amb < $temp_ambmin) $temp_ambmin = $temp_amb;
if ($temp_amb > $temp_ambmax) $temp_ambmax = $temp_amb;
if ($temp_col < $temp_colmin) $temp_colmin = $temp_col;
if ($temp_col > $temp_colmax) $temp_colmax = $temp_col;
$temp_ambtot = $temp_ambtot + $temp_amb;
$temp_coltot = $temp_coltot + $temp_col;
$s_temp_amb = $s_temp_amb.$temp_amb.',';
$s_temp_col = $s_temp_col.$temp_col.',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$s_temp_amb = $s_temp_amb . $temp_amb . ',';
$s_temp_col = $s_temp_col . $temp_col . ',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoy_amb = $temp_ambtot/($Nbjours); // moyenne par jour
$vmoy_col = $temp_coltot/($Nbjours); // moyenne par jour
?>
$vmoy_amb = $temp_ambtot / ($Nbjours); // moyenne par jour
$vmoy_col = $temp_coltot / ($Nbjours); // moyenne par jour
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'x'
},
title: {
text: 'Températures du château d\'eau du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Température ambiante";
if($temp_ambtot == 0) $temp_ambmin = 0;
echo " --- T total = <b>".$temp_ambtot."</b> m³ -- Tmoy/jour = <b>".round($vmoy_amb, 2)."</b> m³ -- Tmin = <b>".$temp_ambmin."</b> m³ -- TMax = <b>".$temp_ambmax."</b> m³<br/>Température de la colonne";
if($temp_coltot == 0) $temp_colmin = 0;
echo " --- T total = <b>".$temp_coltot."</b> m³ -- Tmoy/jour = <b>".round($vmoy_col, 2)."</b> m³ -- Tmin = <b>".$temp_colmin."</b> m³ -- TMax = <b>".$temp_colmax."</b> m³'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'x'
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temp. ambiante',
data: [<?php echo $s_temp_amb;?>]
}, {
name: 'Temp. de la colonne',
data: [<?php echo $s_temp_col;?>]
}]
});
});
</script>
title: {
text: 'Températures du château d\'eau du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Température ambiante";
if ($temp_ambtot == 0) $temp_ambmin = 0;
echo " --- T total = <b>" . $temp_ambtot . "</b> m³ -- Tmoy/jour = <b>" . round($vmoy_amb, 2) . "</b> m³ -- Tmin = <b>" . $temp_ambmin . "</b> m³ -- TMax = <b>" . $temp_ambmax . "</b> m³<br/>Température de la colonne";
if ($temp_coltot == 0) $temp_colmin = 0;
echo " --- T total = <b>" . $temp_coltot . "</b> m³ -- Tmoy/jour = <b>" . round($vmoy_col, 2) . "</b> m³ -- Tmin = <b>" . $temp_colmin . "</b> m³ -- TMax = <b>" . $temp_colmax . "</b> m³'";
?>
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '°C'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Temp. ambiante',
data: [<?php echo $s_temp_amb; ?>]
}, {
name: 'Temp. de la colonne',
data: [<?php echo $s_temp_col; ?>]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,181 +1,167 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au']))
{
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_vol_6 = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$result_vol_22 = $connexion->query("SELECT * FROM chateau WHERE heure='22:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$while_date = $date1;
$s_date = '';
while(strtotime($while_date) <= strtotime($date2))
{
$tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_date)).'",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
while($fetch = $result_vol_6->fetch())
{
$tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion'];
}
while($fetch = $result_vol_22->fetch())
{
$tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion'];
}
$s_vol_6 = '';
$s_vol_22= '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$while_date = $date1;
for($i = 0; $i < count($tab_vol_6); $i++)
{
if(isset($tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null')
{
$vol = ($tab_vol_6[$while_date]-$tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
// recherche mini et Maxi calcul total
if ($vol<$volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.',';
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else {
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
else $s_vol_6 = $s_vol_6.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_date = $date1;
for($i = 0; $i < count($tab_vol_22); $i++)
{
if($tab_vol_22[$while_date] != 'null' && $tab_vol_6[$while_date] != 'null')
{
$vol = ($tab_vol_22[$while_date]-$tab_vol_6[$while_date]);
// recherche mini et Maxi calcul total
if ($vol<$volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$result_vol_6 = $connexion->query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$result_vol_22 = $connexion->query("SELECT * FROM chateau WHERE heure='22:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$s_vol_22 = $s_vol_22.$vol.',';
$while_date = $date1;
$s_date = '';
while (strtotime($while_date) <= strtotime($date2)) {
$tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null';
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_date)) . '",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
else $s_vol_22 = $s_vol_22.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
while ($fetch = $result_vol_6->fetch()) {
$tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion'];
}
while ($fetch = $result_vol_22->fetch()) {
$tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion'];
}
$s_vol_6 = '';
$s_vol_22 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$while_date = $date1;
for ($i = 0; $i < count($tab_vol_6); $i++) {
if (isset($tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null') {
$vol = ($tab_vol_6[$while_date] - $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
// recherche mini et Maxi calcul total
if ($vol < $volmin) $volmin = $vol;
if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6 . $vol . ',';
} else $s_vol_6 = $s_vol_6 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
$while_date = $date1;
for ($i = 0; $i < count($tab_vol_22); $i++) {
if ($tab_vol_22[$while_date] != 'null' && $tab_vol_6[$while_date] != 'null') {
$vol = ($tab_vol_22[$while_date] - $tab_vol_6[$while_date]);
// recherche mini et Maxi calcul total
if ($vol < $volmin) $volmin = $vol;
if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_22 = $s_vol_22 . $vol . ',';
} else $s_vol_22 = $s_vol_22 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoy=$voltot/($Nbjours); // moyenne par jour
$vmoy = $voltot / ($Nbjours); // moyenne par jour
?>
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
title: {
text: 'Volumes pompés du château d\'eau du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Volume pompé ";
if($voltot == 0) $volmin = 0;
echo " --- V total = <b>".$voltot."</b> m³ -- Vmoy/jour = <b>".round($vmoy, 2)."</b> m³ -- Vmin = <b>".$volmin."</b> m³ -- VMax = <b>".$volmax."</b> m³'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Volume (m3)'
},
plotLines: [{
value: 60,
width: 2,
color: '#F00',
dashStyle: 'longdash'
}]
},
tooltip: {
valueSuffix: 'm3'
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'center',
verticalAlign: 'bottom'
},
title: {
text: 'Volumes pompés du château d\'eau du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Volume pompé ";
if ($voltot == 0) $volmin = 0;
echo " --- V total = <b>" . $voltot . "</b> m³ -- Vmoy/jour = <b>" . round($vmoy, 2) . "</b> m³ -- Vmin = <b>" . $volmin . "</b> m³ -- VMax = <b>" . $volmax . "</b> m³'";
?>
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
},
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y}',
color: 'blue'
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Volume (m3)'
},
plotLines: [{
value: 60,
width: 2,
color: '#F00',
dashStyle: 'longdash'
}]
},
tooltip: {
valueSuffix: 'm3'
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'center',
verticalAlign: 'bottom'
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
},
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y}',
color: 'blue'
}
}
},
}
},
series: [{
name: 'Volume pompé entre 22hoo-06hoo',
data: [<?php echo $s_vol_6;?>]
}, {
name: 'Volume pompé entre 06hoo-22hoo',
data: [<?php echo $s_vol_22;?>]
}]
});
});
</script>
series: [{
name: 'Volume pompé entre 22hoo-06hoo',
data: [<?php echo $s_vol_6; ?>]
}, {
name: 'Volume pompé entre 06hoo-22hoo',
data: [<?php echo $s_vol_22; ?>]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>

View File

@ -1,134 +1,124 @@
<?php require('head.php');
if(@$infos_user['droit'] > 0)
{
if (@$infos_user['droit'] > 0) {
?>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr>
<td id="ds_calclass"></td>
</tr>
</table>
<?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au']))
{
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
}
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_vol_6 = $connexion->query("SELECT * FROM surpresseur WHERE heure='22:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC");
$while_date = $date1;
$s_date = '';
while(strtotime($while_date) <= strtotime($date2))
{
$tab_vol_6[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_date)).'",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
while($fetch = $result_vol_6->fetch())
{
$tab_vol_6[$fetch['date']] = $fetch['volume'];
}
$s_vol_6 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$while_date = $date1;
for($i = 0; $i < count($tab_vol_6); $i++)
{
if(isset($tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null')
{
// recherche mini et Maxi calcul total
$vol = ($tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
if ($vol<$volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.',';
<?php
if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
$date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au']));
} else {
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = date('Y-m-d');
}
$result_vol_6 = $connexion->query("SELECT * FROM surpresseur WHERE heure='22:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC");
$while_date = $date1;
$s_date = '';
while (strtotime($while_date) <= strtotime($date2)) {
$tab_vol_6[$while_date] = 'null';
$s_date = $s_date . '"' . date("d/m/y", strtotime($while_date)) . '",';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
while ($fetch = $result_vol_6->fetch()) {
$tab_vol_6[$fetch['date']] = $fetch['volume'];
}
$s_vol_6 = '';
$volmin = 100;
$volmax = 0;
$voltot = 0;
$while_date = $date1;
for ($i = 0; $i < count($tab_vol_6); $i++) {
if (isset($tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null') {
// recherche mini et Maxi calcul total
$vol = ($tab_vol_6[$while_date] - $tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]);
if ($vol < $volmin) $volmin = $vol;
if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6 . $vol . ',';
} else $s_vol_6 = $s_vol_6 . 'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
else $s_vol_6 = $s_vol_6.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
}
// calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1);
$Nbjours = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
$Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours
//$Nbjours = 31;
// Affichage des données bilan sur la période;
$vmoy=$voltot/($Nbjours); // moyenne par jour
$vmoy = $voltot / ($Nbjours); // moyenne par jour
?>
?>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1;?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2;?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<form method="get">Du <input name="du" type="text" value="<?php echo $date1; ?>" onclick="ds_sh(this);"> au <input name="au" type="text" value="<?php echo $date2; ?>" onclick="ds_sh(this);"><input type="submit" value="Afficher le graphique"><em style="font-size:12px;">(format ex.: 2014-05-27)</em></form>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
title: {
text: 'Volumes pompés du surpresseur du <?php echo "<b>".date("d/m/Y", strtotime($date1))."</b> au <b>".date("d/m/Y", strtotime($date2))."</b>";?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Volume pompé ";
if($voltot == 0) $volmin = 0;
echo " --- V total = <b>".$voltot."</b> m³ -- Vmoy/jour = <b>".round($vmoy, 2)."</b> m³ -- Vmin = <b>".$volmin."</b> m³ -- VMax = <b>".$volmax."</b> m³'";
?>
},
xAxis: {
labels: {
rotation: -60
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
zoomType: 'x'
},
categories: [<?php echo $s_date;?>]
},
yAxis: {
title: {
text: 'Volume (m3)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'm3'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Volume pompé',
data: [<?php echo $s_vol_6;?>]
}]
});
});
</script>
title: {
text: 'Volumes pompés du surpresseur du <?php echo "<b>" . date("d/m/Y", strtotime($date1)) . "</b> au <b>" . date("d/m/Y", strtotime($date2)) . "</b>"; ?>',
x: -20 //center
},
subtitle: {
<?php
echo " text: 'Volume pompé ";
if ($voltot == 0) $volmin = 0;
echo " --- V total = <b>" . $voltot . "</b> m³ -- Vmoy/jour = <b>" . round($vmoy, 2) . "</b> m³ -- Vmin = <b>" . $volmin . "</b> m³ -- VMax = <b>" . $volmax . "</b> m³'";
?>
},
xAxis: {
labels: {
rotation: -60
},
categories: [<?php echo $s_date; ?>]
},
yAxis: {
title: {
text: 'Volume (m3)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: 'm3'
},
legend: {
layout: 'vertical',
align: 'center',
verticalAlign: 'bottom',
borderWidth: 0
},
series: [{
name: 'Volume pompé',
data: [<?php echo $s_vol_6; ?>]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<?php
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
} else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?>