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'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
$color = true; $color = true;
$num_page = 1; // Initialisation du numéro de la page $num_page = 1; // Initialisation du numéro de la page
$nb_per_page = 10; // Initialisation du nombre d'entréé par page $nb_per_page = 10; // Initialisation du nombre d'entréé par page
$index = 0; // Initialisation de l'index pour la selection dans la BDD $index = 0; // Initialisation de l'index pour la selection dans la BDD
// Si l'utilisateur change le nombre d'alertes par page // Si l'utilisateur change le nombre d'alertes par page
if(isset($_GET['npp']) && $_GET['npp'] > 0) if (isset($_GET['npp']) && $_GET['npp'] > 0)
$nb_per_page = $_GET['npp']; // On modifie l'attribut $nb_per_page = $_GET['npp']; // On modifie l'attribut
// Si le numéro de la page est supérieur à 0 // Si le numéro de la page est supérieur à 0
if(isset($_GET['page']) && $_GET['page'] > 0) if (isset($_GET['page']) && $_GET['page'] > 0) {
{
$num_page = $_GET['page']; // On modifie l'attribut $num_page = $_GET['page']; // On modifie l'attribut
$index = $nb_per_page * ($num_page - 1); // Ainsi que l'attribut ci $index = $nb_per_page * ($num_page - 1); // Ainsi que l'attribut ci
} }
// Sélection de l'affichage // Sélection de l'affichage
$getaff = ""; $getaff = "";
if(isset($_POST['chateau']) or isset($_POST['relevage']) or isset($_POST['surpresseur'])) if (isset($_POST['chateau']) or isset($_POST['relevage']) or isset($_POST['surpresseur'])) {
{ if (@$_POST['chateau']) $_SESSION['alerte_chateau'] = 1;
if(@$_POST['chateau']) $_SESSION['alerte_chateau'] = 1; else $_SESSION['alerte_chateau'] = 0; else $_SESSION['alerte_chateau'] = 0;
if(@$_POST['relevage']) $_SESSION['alerte_relevage'] = 1; else $_SESSION['alerte_relevage'] = 0; if (@$_POST['relevage']) $_SESSION['alerte_relevage'] = 1;
if(@$_POST['surpresseur']) $_SESSION['alerte_surpresseur'] = 1; else $_SESSION['alerte_surpresseur'] = 0; else $_SESSION['alerte_relevage'] = 0;
} if (@$_POST['surpresseur']) $_SESSION['alerte_surpresseur'] = 1;
if(!@$_SESSION['alerte_chateau'] && !@$_SESSION['alerte_relevage'] && !@$_SESSION['alerte_surpresseur']) else $_SESSION['alerte_surpresseur'] = 0;
{ }
if (!@$_SESSION['alerte_chateau'] && !@$_SESSION['alerte_relevage'] && !@$_SESSION['alerte_surpresseur']) {
$_SESSION['alerte_chateau'] = 1; $_SESSION['alerte_chateau'] = 1;
$_SESSION['alerte_relevage'] = 1; $_SESSION['alerte_relevage'] = 1;
$_SESSION['alerte_surpresseur'] = 1; $_SESSION['alerte_surpresseur'] = 1;
} }
$where = "WHERE "; $where = "WHERE ";
if($_SESSION['alerte_chateau']) if ($_SESSION['alerte_chateau']) {
{ $where .= "equipement='Chateau'"; } $where .= "equipement='Chateau'";
if($_SESSION['alerte_relevage']) }
{ if ($_SESSION['alerte_relevage']) {
if($_SESSION['alerte_chateau']) $where .= " or "; if ($_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Station de Relevage'"; $where .= "equipement='Station de Relevage'";
} }
if($_SESSION['alerte_surpresseur']) if ($_SESSION['alerte_surpresseur']) {
{ if ($_SESSION['alerte_relevage'] or $_SESSION['alerte_chateau']) $where .= " or ";
if($_SESSION['alerte_relevage'] or $_SESSION['alerte_chateau']) $where .= " or ";
$where .= "equipement='Surpresseur'"; $where .= "equipement='Surpresseur'";
} }
if(isset($_GET['acquitte_id']) && $_GET['acquitte_id'] >= 0) if (isset($_GET['acquitte_id']) && $_GET['acquitte_id'] >= 0) {
{ if ($connexion->query("UPDATE alertes SET acquitte='1' WHERE id_releve=" . $_GET['acquitte_id']))
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
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 echo 'Erreur..'; // sur la page précédente donc la page d'affichage des alertes
} } else {
else
{
// Requête qui récupère les informations de la base de données // 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"); $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>'; echo '<h1>Gestion des alertes</h1>';
// Déclaration des titres du tableau // Déclaration des titres du tableau
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">'; echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>'; echo '<tr>';
echo '<td>Equipement</td>'; echo '<td>Equipement</td>';
echo '<td>Type</td>'; echo '<td>Type</td>';
echo '<td>Date / Heure</td>'; echo '<td>Date / Heure</td>';
echo '<td>Acquitte?</td>'; echo '<td>Acquitte?</td>';
echo '</tr>'; echo '</tr>';
while($alertes = $result_alertes->fetch()) // fetch() récupère un à un les alertes 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 $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 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 '<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">' . $alertes['equipement'] . '</td>'; // Equipement
echo '<td class="ligne">'.utf8_encode(strtolower(str_replace('?', 'e', str_replace('_', ' ', $alertes['type'])))).'</td>'; echo '<td class="ligne">' . utf8_encode(strtolower(str_replace('?', 'e', str_replace('_', ' ', $alertes['type'])))) . '</td>';
// Type d'alerte en minuscule avec strtolower() // Type d'alerte en minuscule avec strtolower()
echo '<td class="ligne">'.$alertes['date'].' / '.$alertes['heure'].'</td>'; // Date et Heure echo '<td class="ligne">' . $alertes['date'] . ' / ' . $alertes['heure'] . '</td>'; // Date et Heure
echo '<td class="ligne">'; echo '<td class="ligne">';
// Si "acquitte" est a 1 on affiche "Oui" sinon on afficher un lien pour l'acquitter "Non-> Acquitter" // Si "acquitte" est a 1 on affiche "Oui" sinon on afficher un lien pour l'acquitter "Non-> Acquitter"
if($alertes['acquitte']) echo 'Oui'; 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>'; 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 '</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; // Fermeture du tableau echo '</table>'; // Fermeture du tableau
// Nb pages // Nb pages
$nb_alertes = $connexion->query("SELECT count(*) FROM alertes ".$where."")->fetchColumn(); $nb_alertes = $connexion->query("SELECT count(*) FROM alertes " . $where . "")->fetchColumn();
if($nb_alertes == 0) echo '<h1>Aucunes alertes</h1>'; if ($nb_alertes == 0) echo '<h1>Aucunes alertes</h1>';
else else {
{ if (isset($_GET['page']))
if(isset($_GET['page']))
$pageActuelle = $_GET['page']; $pageActuelle = $_GET['page'];
else else
$pageActuelle = '1'; $pageActuelle = '1';
function get_list_page($page, $nb_page, $link, $nb = 3){ function get_list_page($page, $nb_page, $link, $nb = 3)
{
$list_page = array(); $list_page = array();
for ($i=1; $i <= $nb_page; $i++) for ($i = 1; $i <= $nb_page; $i++) {
{ if (($i < $nb) or ($i > $nb_page - $nb) or (($i < $page + $nb) and ($i > $page - $nb)))
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>';
$list_page[] = ($i==$page)?'<a class="pagenumeroactuel">[ '.$i.' ]</a>':'<a class="pagenumero" href="'.$link.'page='.$i.'">'.$i.'</a>'; else {
else if ($i >= $nb and $i <= $page - $nb)
{
if ($i >= $nb AND $i <= $page - $nb)
$i = $page - $nb; $i = $page - $nb;
elseif ($i >= $page + $nb AND $i <= $nb_page - $nb) elseif ($i >= $page + $nb and $i <= $nb_page - $nb)
$i = $nb_page - $nb; $i = $nb_page - $nb;
$list_page[] = '...'; $list_page[] = '...';
} }
} }
$print= implode(' ', $list_page); $print = implode(' ', $list_page);
return $print; return $print;
} }
echo '<br>Pages: '; echo '<br>Pages: ';
echo get_list_page($pageActuelle, (($nb_alertes -1 ) / $nb_per_page)+1, '?'); 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 '<form method="GET"><input type="text" name="page" value="' . $pageActuelle . '" style="width:30px;"><input type="submit" value="Rechercher"></form>';
echo '<br>'; echo '<br>';
} }
// Options d'affichage // 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" '; 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'; if ($_SESSION['alerte_chateau']) echo 'checked';
echo '>Ch&acirc;teau</label> <label><input type="checkbox" name="relevage" value="1" '; echo '>Ch&acirc;teau</label> <label><input type="checkbox" name="relevage" value="1" ';
if($_SESSION['alerte_relevage']) echo 'checked'; if ($_SESSION['alerte_relevage']) echo 'checked';
echo '>Station de Relevage</label> <label><input type="checkbox" name="surpresseur" value="1" '; echo '>Station de Relevage</label> <label><input type="checkbox" name="surpresseur" value="1" ';
if($_SESSION['alerte_surpresseur']) echo 'checked'; if ($_SESSION['alerte_surpresseur']) echo 'checked';
echo '>Surpresseur</label><br/><input type="submit" value="Flitrer les r&eacute;sultats"></form></div>'; 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');
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) { function ds_getleft(el) {
var tmp = el.offsetLeft; var tmp = el.offsetLeft;
el = el.offsetParent el = el.offsetParent
while(el) { while (el) {
tmp += el.offsetLeft; tmp += el.offsetLeft;
el = el.offsetParent; el = el.offsetParent;
} }
@ -23,7 +23,7 @@ function ds_getleft(el) {
function ds_gettop(el) { function ds_gettop(el) {
var tmp = el.offsetTop; var tmp = el.offsetTop;
el = el.offsetParent el = el.offsetParent
while(el) { while (el) {
tmp += el.offsetTop; tmp += el.offsetTop;
el = el.offsetParent; el = el.offsetParent;
} }
@ -31,7 +31,7 @@ function ds_gettop(el) {
} }
setTimeout( setTimeout(
function(){ function () {
// Output Element // Output Element
ds_oe = ds_getel('ds_calclass'); ds_oe = ds_getel('ds_calclass');
// Container // Container
@ -55,12 +55,12 @@ function ds_echo(t) {
var ds_element; // Text Element... var ds_element; // Text Element...
var ds_monthnames = [ var ds_monthnames = [
'Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin',
'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre' 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre'
]; // You can translate it for your language. ]; // You can translate it for your language.
var ds_daynames = [ var ds_daynames = [
'Dim', 'Lun', 'Mar', 'Me', 'Jeu', 'Ven', 'Sam' 'Dim', 'Lun', 'Mar', 'Me', 'Jeu', 'Ven', 'Sam'
]; // You can translate it for your language. ]; // You can translate it for your language.
// Calendar template // Calendar template
@ -106,9 +106,9 @@ function ds_draw_calendar(m, y) {
// First clean the output buffer. // First clean the output buffer.
ds_ob_clean(); ds_ob_clean();
// Here we go, do the header // Here we go, do the header
ds_echo (ds_template_main_above(ds_monthnames[m - 1] + ' ' + y)); ds_echo(ds_template_main_above(ds_monthnames[m - 1] + ' ' + y));
for (i = 0; i < 7; i ++) { for (i = 0; i < 7; i++) {
ds_echo (ds_template_day_row(ds_daynames[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) { 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 { else {
days = (y % 4 == 0) ? 29 : 28; 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; var first_loop = 1;
// Start the first week // 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 sunday is not the first day of the month, make a blank cell...
if (first_day != 0) { if (first_day != 0) {
ds_echo (ds_template_blank_cell(first_day)); ds_echo(ds_template_blank_cell(first_day));
} }
var j = 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. // Today is sunday, make a new week.
// If this sunday is the first day of the month, // If this sunday is the first day of the month,
// we've made a new row for you already. // we've made a new row for you already.
if (j == 0 && !first_loop) { if (j == 0 && !first_loop) {
// New week!! // 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... first_loop = 0; // This is not first loop anymore...
// What is the next day? // What is the next day?
j ++; j++;
j %= 7; 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_ob_flush(); // And let's display..
ds_ce.scrollIntoView(); // Scroll it into view. ds_ce.scrollIntoView(); // Scroll it into view.
} }
@ -158,13 +158,11 @@ function ds_sh(t) {
ds_element = t; ds_element = t;
var date = t.value.split("-"); var date = t.value.split("-");
// Make a new date, and set the current month and year. // Make a new date, and set the current month and year.
if(t != "") if (t != "") {
{
ds_c_month = date[1]; ds_c_month = date[1];
ds_c_year = date[0]; ds_c_year = date[0];
} }
else else {
{
var ds_sh_date = new Date(); var ds_sh_date = new Date();
ds_c_month = ds_sh_date.getMonth() + 1; ds_c_month = ds_sh_date.getMonth() + 1;
ds_c_year = ds_sh_date.getFullYear(); ds_c_year = ds_sh_date.getFullYear();
@ -183,12 +181,12 @@ function ds_sh(t) {
} }
// Hide the calendar. // Hide the calendar.
function ds_hi() {ds_ce.style.display = 'none';} function ds_hi() { ds_ce.style.display = 'none'; }
// Moves to the next month... // Moves to the next month...
function ds_nm() { function ds_nm() {
// Increase the current month. // Increase the current month.
ds_c_month ++; ds_c_month++;
// We have passed December, let's go to the next year. // We have passed December, let's go to the next year.
// Increase the current year, and set the current month to January. // Increase the current year, and set the current month to January.
if (ds_c_month > 12) { if (ds_c_month > 12) {
@ -238,17 +236,17 @@ function ds_format_date(d, m, y) {
function ds_onclick(d, m, y) { function ds_onclick(d, m, y) {
ds_hi(); // Hide the calendar. 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. // Set the value of it, if we can.
ds_element.value = ds_format_date(d, m, y); 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. // Maybe we want to set the HTML in it.
ds_element.innerHTML = ds_format_date(d, m, y); ds_element.innerHTML = ds_format_date(d, m, y);
} }
else { else {
// I don't know how should we display it, just alert it to user. // 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'); <?php require('head.php');
if(@$infos_user['token'] == @$_SESSION['token'] && @$_SESSION['token'] != '') if (@$infos_user['token'] == @$_SESSION['token'] && @$_SESSION['token'] != '') {
{ if (@$_GET['action'] == 'logout') {
if(@$_GET['action'] == 'logout')
{
$_SESSION['user'] = ''; $_SESSION['user'] = '';
$_SESSION['token'] = ''; $_SESSION['token'] = '';
header('Refresh:1; url=connexion.php'); header('Refresh:1; url=connexion.php');
echo 'Vous êtes déconnecté!'; echo 'Vous êtes déconnecté!';
} } else {
else
{
header('Refresh:1; url=index.php'); 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']) {
elseif(@$_POST['user'] && @$_POST['pass']) if ($result_infos_userCO = $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_POST['user'] . "'")) {
{
if($result_infos_userCO = $connexion->query("SELECT * FROM comptes WHERE pseudo='".$_POST['user']."'"))
{
$infos_userCO = $result_infos_userCO->fetch(); $infos_userCO = $result_infos_userCO->fetch();
//if($infos_userCO['mdp1'] == md5($_POST['pass'])) //if($infos_userCO['mdp1'] == md5($_POST['pass']))
if($infos_userCO['mdp1'] == $_POST['pass']) if ($infos_userCO['mdp1'] == $_POST['pass']) {
{
$tokenCO = rand(100000, 999999); $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['user'] = $_POST['user'];
$_SESSION['token'] = $tokenCO; $_SESSION['token'] = $tokenCO;
header('Refresh:1; url=index.php'); 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>';
} } else echo 'Erreur avec la BDD! 0x02';
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 'L\'utilisateur ou mot de passe incorrect!<br/><br/>-> <a href="connexion.php">On réésaye?</a>'; } else {
}
else echo 'Erreur avec la BDD! 0x01';
}
else
{
?> ?>
<h2>Connexion</h2> <h2>Connexion</h2>
<form method="post"> <form method="post">
Utilisateur :<br/> Utilisateur :<br />
<input type="text" name="user"><br/><br/> <input type="text" name="user"><br /><br />
Mot de passe :<br/> Mot de passe :<br />
<input type="password" name="pass"> <input type="password" name="pass">
<input type="submit" value="Se connecter"> <input type="submit" value="Se connecter">
</form> </form>
<?php <?php
} }
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,6 +1,4 @@
<?php <?php
// message d'erreur lors d'un pb de connexion // 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!'; echo 'Vous n\'etes pas autorise!';
?>

View File

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

View File

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

View File

@ -5,37 +5,39 @@ $debut_ex = (float)$usec + (float)$sec;
<!doctype html> <!doctype html>
<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 <head>
require('mysql.php'); <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> </head>
<body> <body>
<div style="width:800px; margin-left:auto; margin-right:auto;"> <div style="width:800px; margin-left:auto; margin-right:auto;">
<!-- LOGO --> <!-- LOGO -->
<div style="float:left"><img src="banniere_reh.png" width="600" height="200" alt=""/></div> <div style="float:left"><img src="banniere_reh.png" width="600" height="200" alt="" /></div>
<!-- FIN LOGO --> <!-- FIN LOGO -->
<!-- MENU --> <!-- MENU -->
<div style="height:200px; text-align:right;"> <div style="height:200px; text-align:right;">
<?php if(@$infos_user){ echo strtoupper($infos_user['prenom'].' '.$infos_user['nom']); ?><br/> <?php if (@$infos_user) {
(<?php echo strtolower($infos_user['pseudo']); ?>)<br/> echo strtoupper($infos_user['prenom'] . ' ' . $infos_user['nom']); ?><br />
<a href="connexion.php?action=logout">Se déconnecter</a><br/><br/> (<?php echo strtolower($infos_user['pseudo']); ?>)<br />
<a href="index.php">Menu</a><br/> <a href="connexion.php?action=logout">Se déconnecter</a><br /><br />
<a href="alertes.php"><?php echo $result_nb_alertes; ?> Alertes</a><br/> <a href="index.php">Menu</a><br />
<a href="membres.php">Membres</a> <a href="alertes.php"><?php echo $result_nb_alertes; ?> Alertes</a><br />
<?php <a href="membres.php">Membres</a>
} <?php
else echo 'Bonjour à vous!<br/><br/><a href="connexion.php">Se connecter</a>'; ?> } else echo 'Bonjour à vous!<br/><br/><a href="connexion.php">Se connecter</a>'; ?>
</div> </div>
<!-- FIN MENU --> <!-- FIN MENU -->
<!-- CORPS --> <!-- CORPS -->
<div><hr style="width:800px;"> <div>
<hr style="width:800px;">

View File

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

View File

@ -1,198 +1,188 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 3) if (@$infos_user['droit'] > 3) {
{
function mdp_gen($taille) function mdp_gen($taille)
{ {
$car = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*-$'; $car = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*-$';
$mdp = NULL; $mdp = NULL;
for($i=0;$i<$taille;$i++) for ($i = 0; $i < $taille; $i++) {
{ $mdp .= $car[rand(0, strlen($car) - 1)];
$mdp .= $car[rand(0, strlen($car) -1)];
} }
return $mdp; 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>';
} }
else
{ $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 'Une erreur est survenue.. (Aucun utilisateur n\'a ete ajoute)';
} }
echo '<br/><br/><sub><a href="?action=retour">Retour</a></sub></div>'; echo '<br/><br/><sub><a href="?action=retour">Retour</a></sub></div>';
} } else {
else
{
echo '<h1>Ajout d\'utilisateur</h1>'; echo '<h1>Ajout d\'utilisateur</h1>';
echo '<form method="post">'; echo '<form method="post">';
echo '<table width="800" border="0" cellspacing="3" cellpadding="0" align="center">'; 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'].'">'; 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()) if (isset($_POST['pseudo']) && $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_POST['pseudo'] . "'")->fetch())
echo '<span class="erreur_ajo">Pseudo deja utilise</span>'; echo '<span class="erreur_ajo">Pseudo deja utilise</span>';
elseif(isset($_POST['pseudo']) && $_POST['pseudo'] == '') echo '<span class="erreur_ajo">Pseudo manquant</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 '</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"> 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="1" ';
<option value="2" '; if(@$_POST['droit'] == "2") echo 'selected="selected"'; echo '>2</option> if (@$_POST['droit'] == "1") echo 'selected="selected"';
<option value="3" '; if(@$_POST['droit'] == "3") echo 'selected="selected"'; echo '>3</option> echo '>1</option>
<option value="4" '; if(@$_POST['droit'] == "4") echo 'selected="selected"'; echo '>4</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>'; </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="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>'; </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>'; 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'] == '') if (isset($_POST['mdp']) && $_POST['mdp'] == '')
echo '</br><span class="erreur_ajo">Mot de passe manquant</span>'; echo '</td> </tr>'; 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 '</table><div style="text-align:center"><br/><input type="submit" value="Ajouter l\'utilisateur"></form>';
echo '<br/><br/><sub>'.$s_droits.'</sub></div>'; echo '<br/><br/><sub>' . $s_droits . '</sub></div>';
} }
} } elseif (isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "modifier") {
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'])) {
{
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'"; $requ = "UPDATE `comptes` SET `token` ='0123'";
if(isset($_POST['nom']) && $_POST['nom'] != '') $requ .= ", `nom` = '".$_POST['nom']."'"; if (isset($_POST['nom']) && $_POST['nom'] != '') $requ .= ", `nom` = '" . $_POST['nom'] . "'";
else echo '<span class="erreur_mod">- NOM non modifie -</span></br>'; else echo '<span class="erreur_mod">- NOM non modifie -</span></br>';
if(isset($_POST['prenom']) && $_POST['prenom'] != '') $requ .= ", `prenom` = '".$_POST['prenom']."'"; if (isset($_POST['prenom']) && $_POST['prenom'] != '') $requ .= ", `prenom` = '" . $_POST['prenom'] . "'";
else echo '<span class="erreur_mod">- PRENOM non modifie -</span></br>'; 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']."'"; 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>'; else echo '<span class="erreur_mod">- NUM. DE RUE non modifie -</span></br>';
if(isset($_POST['rue']) && $_POST['rue'] != '') $requ .= ", `rue` = '".$_POST['rue']."'"; if (isset($_POST['rue']) && $_POST['rue'] != '') $requ .= ", `rue` = '" . $_POST['rue'] . "'";
else echo '<span class="erreur_mod">- RUE non modifie -</span></br>'; else echo '<span class="erreur_mod">- RUE non modifie -</span></br>';
if(isset($_POST['ville']) && $_POST['ville'] != '') $requ .= ", `ville` = '".$_POST['ville']."'"; if (isset($_POST['ville']) && $_POST['ville'] != '') $requ .= ", `ville` = '" . $_POST['ville'] . "'";
else echo '<span class="erreur_mod">- VILLE non modifie -</span></br>'; else echo '<span class="erreur_mod">- VILLE non modifie -</span></br>';
if(isset($_POST['tel']) && $_POST['tel'] != '') $requ .= ", `tel` = '".$_POST['tel']."'"; if (isset($_POST['tel']) && $_POST['tel'] != '') $requ .= ", `tel` = '" . $_POST['tel'] . "'";
else echo '<span class="erreur_mod">- NUM. DE TEL. non modifie -</span></br>'; else echo '<span class="erreur_mod">- NUM. DE TEL. non modifie -</span></br>';
if(isset($_POST['fonction']) && $_POST['fonction'] != '') $requ .= ", `fonction` = '".$_POST['fonction']."'"; if (isset($_POST['fonction']) && $_POST['fonction'] != '') $requ .= ", `fonction` = '" . $_POST['fonction'] . "'";
else echo '<span class="erreur_mod">- FONCTION non modifie -</span></br>'; else echo '<span class="erreur_mod">- FONCTION non modifie -</span></br>';
if(isset($_POST['droit']) && $_POST['droit'] != '') $requ .= ", `droit` = '".$_POST['droit']."'"; if (isset($_POST['droit']) && $_POST['droit'] != '') $requ .= ", `droit` = '" . $_POST['droit'] . "'";
if(isset($_POST['suspendu']) && $_POST['suspendu'] != '') $requ .= ", `suspendu` = '".$_POST['suspendu']."'"; if (isset($_POST['suspendu']) && $_POST['suspendu'] != '') $requ .= ", `suspendu` = '" . $_POST['suspendu'] . "'";
if(isset($_POST['mdp']) && $_POST['mdp'] != '') $requ .= ", `mdp1` = '".md5($_POST['mdp'])."'"; if (isset($_POST['mdp']) && $_POST['mdp'] != '') $requ .= ", `mdp1` = '" . md5($_POST['mdp']) . "'";
$requ .= " WHERE `id_compte` =".$_GET['id'].";"; $requ .= " WHERE `id_compte` =" . $_GET['id'] . ";";
echo '<div style="text-align:center">'; echo '<div style="text-align:center">';
if($connexion->query($requ)) if ($connexion->query($requ)) {
{ echo 'Les modifications pour l\'utilisateur ' . $_POST['pseudo'] . ' ont ete prises en compte!';
echo 'Les modifications pour l\'utilisateur '.$_POST['pseudo'].' ont ete prises en compte!'; } else {
}
else
{
echo 'Une erreur est survenue.. (Modifications non effectuees)'; echo 'Une erreur est survenue.. (Modifications non effectuees)';
} }
echo '<br/><sub><a href="?action=retour">Retour</a></sub></div>'; echo '<br/><sub><a href="?action=retour">Retour</a></sub></div>';
} } else {
else if ($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='" . $_GET['id'] . "'")) {
{ if ($utilisateur = $result->fetch()) {
if($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='".$_GET['id']."'"))
{
if($utilisateur = $result->fetch())
{
echo '<h1>Modification d\'utilisateur</h1>'; echo '<h1>Modification d\'utilisateur</h1>';
echo '<form method="post">'; echo '<form method="post">';
echo '<table width="800" border="0" cellspacing="3" cellpadding="0" align="center">'; 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">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">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">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'].'"> 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>'; <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">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">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">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"> 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="1" ';
<option value="2" '; if($utilisateur['droit'] == "2") echo 'selected="selected"'; echo '>2</option> if ($utilisateur['droit'] == "1") echo 'selected="selected"';
<option value="3" '; if($utilisateur['droit'] == "3") echo 'selected="selected"'; echo '>3</option> echo '>1</option>
<option value="4" '; if($utilisateur['droit'] == "4") echo 'selected="selected"'; echo '>4</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>'; </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="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>'; </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 '<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 '</table><div style="text-align:center"><br/><input type="submit" value="Enregistrer les modifications"></form>';
echo '<br/><br/><sub>'.$s_droits.'</sub></div>'; echo '<br/><br/><sub>' . $s_droits . '</sub></div>';
} } else {
else echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: ' . $_GET['id'] . ')';
{
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: '.$_GET['id'].')';
echo '<hr width="800px"><sub><a href="?action=retour">Retour</a></sub>'; 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 'Une erreur est survenue.. (La requete n\'a pas aboutie)';
echo '<hr width="800px"><sub><a href="?action=retour">Retour</a></sub>'; echo '<hr width="800px"><sub><a href="?action=retour">Retour</a></sub>';
} }
} }
} } elseif (isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "supprimer") {
elseif(isset($_GET['action']) && isset($_GET['id']) && $_GET['action'] == "supprimer")
{
echo '<h1>Suppression d\'utilisateur</h1><div style="text-align:center">'; echo '<h1>Suppression d\'utilisateur</h1><div style="text-align:center">';
if(isset($_GET['token'])) if (isset($_GET['token'])) {
{ if ($connexion->query("DELETE FROM comptes WHERE id_compte='" . $_GET['id'] . "'"))
if($connexion->query("DELETE FROM comptes WHERE id_compte='".$_GET['id']."'"))
echo 'Utilisateur supprime!'; echo 'Utilisateur supprime!';
else else
echo 'Erreur lors de la suppression..'; echo 'Erreur lors de la suppression..';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>'; echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
} } else {
else if ($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='" . $_GET['id'] . "'")) {
{ if ($utilisateur = $result->fetch()) {
if($result = $connexion->query("SELECT * FROM comptes WHERE id_compte='".$_GET['id']."'")) 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>';
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>'; echo '<br/><sub>L\'action de supprimer un utilisateur est irreversible..</sub>';
} } else {
else echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: ' . $_GET['id'] . ')';
{
echo 'Une erreur est survenue.. (Aucun utilisateur avec l\'id: '.$_GET['id'].')';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>'; echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
} }
} } else {
else
{
echo 'Une erreur est survenue.. (La requete n\'a pas aboutie)'; echo 'Une erreur est survenue.. (La requete n\'a pas aboutie)';
echo '<br/><sub><a href="?action=retour">Retour</a></sub>'; echo '<br/><sub><a href="?action=retour">Retour</a></sub>';
} }
} }
echo '</div>'; echo '</div>';
} } else {
else
{
echo '<h1>Gestion des utilisateurs</h1>'; echo '<h1>Gestion des utilisateurs</h1>';
echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">'; echo '<table width="800px" border="0" cellspacing="0" cellpadding="0" align="center" style="text-align: center;">';
echo '<tr>'; echo '<tr>';
@ -206,27 +196,29 @@ else
echo '<td>Actions</td>'; echo '<td>Actions</td>';
echo '</tr>'; echo '</tr>';
$result = $connexion->query("SELECT * FROM comptes"); $result = $connexion->query("SELECT * FROM comptes");
while($compte = $result->fetch()) while ($compte = $result->fetch()) {
{
$color = !$color; $color = !$color;
if($color) $couleur = "#9CF"; else $couleur = "#9CC"; if ($color) $couleur = "#9CF";
else $couleur = "#9CC";
echo '<tr style="background-color:'.$couleur.';">'; echo '<tr style="background-color:' . $couleur . ';">';
echo '<td class="ligne">'.$compte['pseudo'].'</td>'; echo '<td class="ligne">' . $compte['pseudo'] . '</td>';
echo '<td class="ligne">'.$compte['nom'].' '.$compte['prenom'].'</td>'; echo '<td class="ligne">' . $compte['nom'] . ' ' . $compte['prenom'] . '</td>';
echo '<td class="ligne">'.$compte['fonction'].'</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['num_rue'] . ', ' . $compte['rue'] . '</br>' . $compte['ville'] . '</td>';
echo '<td class="ligne">'.$compte['tel'].'</td>'; echo '<td class="ligne">' . $compte['tel'] . '</td>';
echo '<td class="ligne">'.$compte['droit'].'<sup>*</sup></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">';
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>'; 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 '</tr>';
} }
echo '</table></br>'; echo '</table></br>';
echo '&rarr; <a href="?action=ajouter">Ajouter un utilisateur</a>'; echo '&rarr; <a href="?action=ajouter">Ajouter un utilisateur</a>';
echo '<br/><br/><sub>'.$s_droits.'</sub>'; echo '<br/><br/><sub>' . $s_droits . '</sub>';
} }
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!'; include('foot.php');
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'; $base_bdd = 'chateau2';
session_start(); session_start();
$connexion = new PDO('mysql:host='.$host_bdd.';dbname='.$base_bdd, $user_bdd, $pass_bdd); $connexion = new PDO('mysql:host=' . $host_bdd . ';dbname=' . $base_bdd, $user_bdd, $pass_bdd);
if(@$_SESSION['user']) if (@$_SESSION['user']) {
{ $result_infos_user = $connexion->query("SELECT * FROM comptes WHERE pseudo='" . $_SESSION['user'] . "'");
$result_infos_user = $connexion->query("SELECT * FROM comptes WHERE pseudo='".$_SESSION['user']."'");
$infos_user = $result_infos_user->fetch(); $infos_user = $result_infos_user->fetch();
if($_SESSION['token'] != $infos_user['token']) if ($_SESSION['token'] != $infos_user['token']) {
{
$_SESSION['user'] = ''; $_SESSION['user'] = '';
$_SESSION['token'] = ''; $_SESSION['token'] = '';
$infos_user = 0; $infos_user = 0;
@ -19,4 +17,3 @@ if(@$_SESSION['user'])
} }
$result_nb_alertes = $connexion->query("SELECT count(*) FROM alertes WHERE acquitte='0'")->fetchColumn(); $result_nb_alertes = $connexion->query("SELECT count(*) FROM alertes WHERE acquitte='0'")->fetchColumn();
?>

View File

@ -1,73 +1,66 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
{
$date1 = date('Y-m-d', strtotime($_GET['du'])); $date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else {
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = 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)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_pp1[$while_date] = 'null'; $tab_pp1[$while_date] = 'null';
$tab_pp2[$while_date] = 'null'; $tab_pp2[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", 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_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
while($fetch = $result_temp->fetch()) while ($fetch = $result_temp->fetch()) {
{
$tab_pp1[$fetch['date']] = $fetch['temp_marche_pp1']; $tab_pp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pp2[$fetch['date']] = $fetch['temp_marche_pp2']; $tab_pp2[$fetch['date']] = $fetch['temp_marche_pp2'];
} }
$s_temp_pp1 = ''; $s_temp_pp1 = '';
$s_temp_pp2= ''; $s_temp_pp2 = '';
$while_date = $date1; $while_date = $date1;
for($i = 0; $i < count($tab_pp1); $i++) for ($i = 0; $i < count($tab_pp1); $i++) {
{ $s_temp_pp1 = $s_temp_pp1 . $tab_pp1[$while_date] . ',';
$s_temp_pp1 = $s_temp_pp1.$tab_pp1[$while_date].','; $s_temp_pp2 = $s_temp_pp2 . $tab_pp2[$while_date] . ',';
$s_temp_pp2 = $s_temp_pp2.$tab_pp2[$while_date].',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
/*subtitle: { /*subtitle: {
@ -78,7 +71,7 @@ $(function () {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -101,17 +94,16 @@ $(function () {
}, },
series: [{ series: [{
name: 'Temps pompe 1', name: 'Temps pompe 1',
data: [<?php echo $s_temp_pp1;?>] data: [<?php echo $s_temp_pp1; ?>]
}, { }, {
name: 'Temps pompe 2', name: 'Temps pompe 2',
data: [<?php echo $s_temp_pp2;?>] 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 <?php
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,108 +1,101 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
{
$date1 = date('Y-m-d', strtotime($_GET['du'])); $date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else {
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = 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 = ''; $s_date = '';
$i = 0; $i = 0;
while($fetch = $result_pomp->fetch()) while ($fetch = $result_pomp->fetch()) {
{ $s_date = $s_date . '"' . date("d/m/y", strtotime($fetch['date'])) . '",';
$s_date = $s_date.'"'.date("d/m/y", strtotime($fetch['date'])).'",';
$tab_pomp1[$i] = $fetch['temp_marche_pp1']; $tab_pomp1[$i] = $fetch['temp_marche_pp1'];
$tab_pomp2[$i] = $fetch['temp_marche_pp2']; $tab_pomp2[$i] = $fetch['temp_marche_pp2'];
$i++; $i++;
} }
$s_pomp1 = ''; $s_pomp1 = '';
$s_pomp2= ''; $s_pomp2 = '';
$vol_maxp1 = 0; $vol_maxp1 = 0;
$vol_minp1 = 100; $vol_minp1 = 100;
$vol_totp1 = 0; $vol_totp1 = 0;
$while_date = $date1; $while_date = $date1;
for($i = 0; $i < @count($tab_pomp1)-1; $i++) for ($i = 0; $i < @count($tab_pomp1) - 1; $i++) {
{ $volume = $tab_pomp1[$i + 1] - $tab_pomp1[$i];
$volume = $tab_pomp1[$i+1] - $tab_pomp1[$i]; if ($volume < $vol_minp1) $vol_minp1 = $volume;
if ($volume<$vol_minp1) $vol_minp1 = $volume; if ($volume > $vol_maxp1) $vol_maxp1 = $volume;
if ($volume>$vol_maxp1) $vol_maxp1 = $volume;
$vol_totp1 = $vol_totp1 + $volume; $vol_totp1 = $vol_totp1 + $volume;
$s_pomp1 = $s_pomp1.($volume).','; $s_pomp1 = $s_pomp1 . ($volume) . ',';
} }
$while_date = $date1; $while_date = $date1;
$vol_maxp2 = 0; $vol_maxp2 = 0;
$vol_minp2 = 100; $vol_minp2 = 100;
$vol_totp2 = 0; $vol_totp2 = 0;
for($i = 0; $i < @count($tab_pomp2)-1; $i++) for ($i = 0; $i < @count($tab_pomp2) - 1; $i++) {
{ $volume = $tab_pomp2[$i + 1] - $tab_pomp2[$i];
$volume = $tab_pomp2[$i+1] - $tab_pomp2[$i]; if ($volume < $vol_minp2) $vol_minp2 = $volume;
if ($volume<$vol_minp2) $vol_minp2 = $volume; if ($volume > $vol_maxp2) $vol_maxp2 = $volume;
if ($volume>$vol_maxp2) $vol_maxp2 = $volume;
$vol_totp2 = $vol_totp2 + $volume; $vol_totp2 = $vol_totp2 + $volume;
$s_pomp2 = $s_pomp2.($tab_pomp2[$i+1] - $tab_pomp2[$i]).','; $s_pomp2 = $s_pomp2 . ($tab_pomp2[$i + 1] - $tab_pomp2[$i]) . ',';
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours); // moyenne par jour $vmoyp1 = $vol_totp1 / ($Nbjours); // moyenne par jour
$vmoyp2=$vol_totp2/($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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
type: 'column', type: 'column',
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'T.F. pompe1 "; echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0; 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 "; 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; 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'"; 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: { xAxis: {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -125,17 +118,16 @@ $(function () {
}, },
series: [{ series: [{
name: 'Temps de fonctionnement pompe 1', name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1;?>] data: [<?php echo $s_pomp1; ?>]
}, { }, {
name: 'Temps de fonctionnement pompe 2', name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2;?>] data: [<?php echo $s_pomp2; ?>]
}] }]
}); });
}); });
</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 <?php
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,178 +1,162 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues 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']))); $date1 = date("Y-m-d", strtotime("-1 day", strtotime($_GET['du'])));
$date1bis = date('Y-m-d', strtotime($_GET['du'])); $date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else //Sinon on prend les valeurs du dernier mois
else //Sinon on prend les valeurs du dernier mois {
{
$date1bis = $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $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')))); $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_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"); $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; $while_date = $date1;
$s_date = ''; $s_date = '';
while(strtotime($while_date) <= strtotime($date2)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_vol_6[$while_date] = 'null'; $tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null'; $tab_vol_22[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
$while_datebis = $date1bis; $while_datebis = $date1bis;
while(strtotime($while_datebis) <= strtotime($date2)) while (strtotime($while_datebis) <= strtotime($date2)) {
{ $s_date = $s_date . '"' . date("d/m/y", strtotime($while_datebis)) . '",';
$s_date = $s_date.'"'.date("d/m/y", strtotime($while_datebis)).'",';
$while_datebis = date("Y-m-d", strtotime("+1 day", 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 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)))]); $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++; $Nbjours_V1++;
$vol = round($vol, 2); $vol = round($vol, 2);
if ($vol<$volmin) $volmin = $vol; if ($vol < $volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol; if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol; $voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.','; //On ajoute la valeur au tableau $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
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))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // 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 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_pomp1[$fetch['date']] = $fetch['temp_marche_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['temp_marche_pp2']; $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'; $s_pomp1 = '';
else $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
{ {
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; 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++; $Nbjours_P1++;
} }
$vol = round($vol, 2); $vol = round($vol, 2);
if ($vol<$vol_minp1) $vol_minp1 = $vol; if ($vol < $vol_minp1) $vol_minp1 = $vol;
if ($vol>$vol_maxp1) $vol_maxp1 = $vol; if ($vol > $vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $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
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))); $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++;
} }
else
$vol='0';
else $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
{ {
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-1 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++; $Nbjours_P2++;
} }
$vol = round($vol, 2); $vol = round($vol, 2);
if ($vol<$vol_minp2) $vol_minp2 = $vol; if ($vol < $vol_minp2) $vol_minp2 = $vol;
if ($vol>$vol_maxp2) $vol_maxp2 = $vol; if ($vol > $vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $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
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))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
@ -180,15 +164,15 @@ 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 = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
//$Nbjours = 31; //$Nbjours = 31;
// Affichage des données bilan sur la période; // Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours_P1); // moyenne par jour $vmoyp1 = $vol_totp1 / ($Nbjours_P1); // moyenne par jour
$vmoyp2=$vol_totp2/($Nbjours_P2); // moyenne par jour $vmoyp2 = $vol_totp2 / ($Nbjours_P2); // moyenne par jour
$vmoy=$voltot/($Nbjours_V1); // 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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
alignTicks: false, alignTicks: false,
@ -196,23 +180,23 @@ $(function () {
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'T.F. pompe1 "; echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0; 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 "; 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; 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'"; 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: { xAxis: {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -263,19 +247,19 @@ $(function () {
}, },
series: [{ series: [{
name: 'Temps de fonctionnement pompe 1', name: 'Temps de fonctionnement pompe 1',
data: [<?php echo $s_pomp1;?>], data: [<?php echo $s_pomp1; ?>],
stack: 'heure_pompe', stack: 'heure_pompe',
yAxis: 1, yAxis: 1,
color: '#32CD32' color: '#32CD32'
}, { }, {
name: 'Temps de fonctionnement pompe 2', name: 'Temps de fonctionnement pompe 2',
data: [<?php echo $s_pomp2;?>], data: [<?php echo $s_pomp2; ?>],
stack: 'heure_pompe', stack: 'heure_pompe',
yAxis: 1, yAxis: 1,
color: '#008000' color: '#008000'
}, { }, {
name: 'Volume pompé Chateau d\'eau', name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6;?>], data: [<?php echo $s_vol_6; ?>],
stack: 'volume', stack: 'volume',
yAxis: 0, yAxis: 0,
color: '#00BFFF', color: '#00BFFF',
@ -286,12 +270,11 @@ $(function () {
}] }]
}); });
}); });
</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 <?php
if($voltot == 0) $volmin = 0; 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³ --- "; 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é!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

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

View File

@ -1,181 +1,162 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) //On vérifie les dates reçues 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 $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'])); $date1bis = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else //Sinon on prend les valeurs du dernier mois
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) $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')))); $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 $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; $while_date = $date1;
$s_date = ''; // On initialise $s_date = ''; // On initialise
while(strtotime($while_date) <= strtotime($date2)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_vol_6[$while_date] = 'null'; $tab_vol_6[$while_date] = 'null';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $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'; $while_datebis = $date1bis;
else 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
{ {
$vol = $tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; $tab_vol_6[$fetch['date']] = $fetch['volume'];
$Nbjours_V1++;//Compte le nombre de jours avec valeur }
$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); $vol = round($vol, 2);
if ($vol<$volmin) $volmin = $vol; if ($vol < $volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol; if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol; $voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.','; //On ajoute la valeur au tableau $s_vol_6 = $s_vol_6 . $vol . ','; //On ajoute la valeur au tableau
} } else if ($i != 0) $s_vol_6 = $s_vol_6 . 'null,';
else if ($i != 0) $s_vol_6 = $s_vol_6.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // 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 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_pomp1[$fetch['date']] = $fetch['horaire_pp1'];
$tab_pomp2[$fetch['date']] = $fetch['horaire_pp2']; $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)
{
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'; $s_pomp1 = '';
else $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
{ {
$vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; if (isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0) {
$Nbjours_P1++;//Compte le nombre de jours avec valeur 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); $vol = round($vol, 2);
if ($vol<$vol_minp1) $vol_minp1 = $vol; if ($vol < $vol_minp1) $vol_minp1 = $vol;
if ($vol>$vol_maxp1) $vol_maxp1 = $vol; if ($vol > $vol_maxp1) $vol_maxp1 = $vol;
$vol_totp1 = $vol_totp1 + $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,';
else if ($i != 0) $s_pomp1 = $s_pomp1.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $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'; $vol_maxp2 = 0;
else $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
{ {
$vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; if (isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0) {
$Nbjours_P2++;//Compte le nombre de jours avec valeur 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); $vol = round($vol, 2);
if ($vol<$vol_minp2) $vol_minp2 = $vol; if ($vol < $vol_minp2) $vol_minp2 = $vol;
if ($vol>$vol_maxp2) $vol_maxp2 = $vol; if ($vol > $vol_maxp2) $vol_maxp2 = $vol;
$vol_totp2 = $vol_totp2 + $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,';
else if ($i != 0) $s_pomp2 = $s_pomp2.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
@ -183,15 +164,15 @@ 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 = round(($TDfin-$TDDeb)/(60*60*24)); //division des secondes pour avoir les jours
//$Nbjours = 31; //$Nbjours = 31;
// Affichage des données bilan sur la période; // Affichage des données bilan sur la période;
$vmoyp1=$vol_totp1/($Nbjours_P1); // moyenne par jour $vmoyp1 = $vol_totp1 / ($Nbjours_P1); // moyenne par jour
$vmoyp2=$vol_totp2/($Nbjours_P2); // moyenne par jour $vmoyp2 = $vol_totp2 / ($Nbjours_P2); // moyenne par jour
$vmoy=$voltot/($Nbjours_V1); // 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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
alignTicks: false, alignTicks: false,
@ -199,23 +180,23 @@ $(function () {
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'T.F. pompe1 "; echo " text: 'T.F. pompe1 ";
if($vol_totp1 == 0) $vol_minp1 = 0; 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 "; 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; 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'"; 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: { xAxis: {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -266,19 +247,19 @@ $(function () {
}, },
series: [{ series: [{
name: 'Temps de compresseur pompe 1', name: 'Temps de compresseur pompe 1',
data: [<?php echo $s_pomp1;?>], data: [<?php echo $s_pomp1; ?>],
stack: 'heure_pompe', stack: 'heure_pompe',
yAxis: 1, yAxis: 1,
color: '#32CD32' color: '#32CD32'
}, { }, {
name: 'Temps de compresseurpompe 2', name: 'Temps de compresseurpompe 2',
data: [<?php echo $s_pomp2;?>], data: [<?php echo $s_pomp2; ?>],
stack: 'heure_pompe', stack: 'heure_pompe',
yAxis: 1, yAxis: 1,
color: '#008000' color: '#008000'
}, { }, {
name: 'Volume pompé Chateau d\'eau', name: 'Volume pompé Chateau d\'eau',
data: [<?php echo $s_vol_6;?>], data: [<?php echo $s_vol_6; ?>],
stack: 'volume', stack: 'volume',
yAxis: 0, yAxis: 0,
color: '#00BFFF', color: '#00BFFF',
@ -289,13 +270,11 @@ $(function () {
}] }]
}); });
}); });
</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 <?php
if($voltot == 0) $volmin = 0; 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³ --- "; 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é!';
}
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,114 +1,107 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
{
$date1 = date('Y-m-d', strtotime($_GET['du'])); $date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else {
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = 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)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_amb[$while_date] = 'null'; $tab_amb[$while_date] = 'null';
$tab_col[$while_date] = 'null'; $tab_col[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", 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_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
while($fetch = $result_temp->fetch()) while ($fetch = $result_temp->fetch()) {
{
$tab_amb[$fetch['date']] = $fetch['temp_ambiante']; $tab_amb[$fetch['date']] = $fetch['temp_ambiante'];
$tab_col[$fetch['date']] = $fetch['temp_colonne']; $tab_col[$fetch['date']] = $fetch['temp_colonne'];
} }
$s_temp_amb = ''; $s_temp_amb = '';
$s_temp_col= ''; $s_temp_col = '';
$temp_ambmin = 100; $temp_ambmin = 100;
$temp_ambmax = 0; $temp_ambmax = 0;
$temp_ambtot = 0; $temp_ambtot = 0;
$temp_colmin = 100; $temp_colmin = 100;
$temp_colmax = 0; $temp_colmax = 0;
$temp_coltot = 0; $temp_coltot = 0;
$while_date = $date1; $while_date = $date1;
for($i = 0; $i < count($tab_amb); $i++) for ($i = 0; $i < count($tab_amb); $i++) {
{
// recherche mini et Maxi calcul total // recherche mini et Maxi calcul total
$temp_amb = $tab_amb[$while_date]; $temp_amb = $tab_amb[$while_date];
$temp_col = $tab_col[$while_date]; $temp_col = $tab_col[$while_date];
if ($temp_amb<$temp_ambmin) $temp_ambmin = $temp_amb; if ($temp_amb < $temp_ambmin) $temp_ambmin = $temp_amb;
if ($temp_amb>$temp_ambmax) $temp_ambmax = $temp_amb; if ($temp_amb > $temp_ambmax) $temp_ambmax = $temp_amb;
if ($temp_col<$temp_colmin) $temp_colmin = $temp_col; if ($temp_col < $temp_colmin) $temp_colmin = $temp_col;
if ($temp_col>$temp_colmax) $temp_colmax = $temp_col; if ($temp_col > $temp_colmax) $temp_colmax = $temp_col;
$temp_ambtot = $temp_ambtot + $temp_amb; $temp_ambtot = $temp_ambtot + $temp_amb;
$temp_coltot = $temp_coltot + $temp_col; $temp_coltot = $temp_coltot + $temp_col;
$s_temp_amb = $s_temp_amb.$temp_amb.','; $s_temp_amb = $s_temp_amb . $temp_amb . ',';
$s_temp_col = $s_temp_col.$temp_col.','; $s_temp_col = $s_temp_col . $temp_col . ',';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // Affichage des données bilan sur la période;
$vmoy_amb = $temp_ambtot/($Nbjours); // moyenne par jour $vmoy_amb = $temp_ambtot / ($Nbjours); // moyenne par jour
$vmoy_col = $temp_coltot/($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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'Température ambiante"; echo " text: 'Température ambiante";
if($temp_ambtot == 0) $temp_ambmin = 0; 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"; 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; 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³'"; 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: { xAxis: {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -131,17 +124,16 @@ $(function () {
}, },
series: [{ series: [{
name: 'Temp. ambiante', name: 'Temp. ambiante',
data: [<?php echo $s_temp_amb;?>] data: [<?php echo $s_temp_amb; ?>]
}, { }, {
name: 'Temp. de la colonne', name: 'Temp. de la colonne',
data: [<?php echo $s_temp_col;?>] data: [<?php echo $s_temp_col; ?>]
}] }]
}); });
}); });
</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 <?php
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,122 +1,109 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
{
$date1 = date('Y-m-d', strtotime($_GET['du'])); $date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else {
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = 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_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"); $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; $while_date = $date1;
$s_date = ''; $s_date = '';
while(strtotime($while_date) <= strtotime($date2)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_vol_6[$while_date] = 'null'; $tab_vol_6[$while_date] = 'null';
$tab_vol_22[$while_date] = 'null'; $tab_vol_22[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", 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_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
while($fetch = $result_vol_6->fetch()) while ($fetch = $result_vol_6->fetch()) {
{
$tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion']; $tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion'];
} }
while($fetch = $result_vol_22->fetch()) while ($fetch = $result_vol_22->fetch()) {
{
$tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion']; $tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion'];
} }
$s_vol_6 = ''; $s_vol_6 = '';
$s_vol_22= ''; $s_vol_22 = '';
$volmin = 100; $volmin = 100;
$volmax = 0; $volmax = 0;
$voltot = 0; $voltot = 0;
$while_date = $date1; $while_date = $date1;
for($i = 0; $i < count($tab_vol_6); $i++) 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') {
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)))]);
{
$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 // recherche mini et Maxi calcul total
if ($vol<$volmin) $volmin = $vol; if ($vol < $volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol; if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol; $voltot = $voltot + $vol;
$s_vol_6 = $s_vol_6.$vol.','; $s_vol_6 = $s_vol_6 . $vol . ',';
} } else $s_vol_6 = $s_vol_6 . 'null,';
else $s_vol_6 = $s_vol_6.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
$while_date = $date1; $while_date = $date1;
for($i = 0; $i < count($tab_vol_22); $i++) for ($i = 0; $i < count($tab_vol_22); $i++) {
{ if ($tab_vol_22[$while_date] != 'null' && $tab_vol_6[$while_date] != 'null') {
if($tab_vol_22[$while_date] != 'null' && $tab_vol_6[$while_date] != 'null') $vol = ($tab_vol_22[$while_date] - $tab_vol_6[$while_date]);
{
$vol = ($tab_vol_22[$while_date]-$tab_vol_6[$while_date]);
// recherche mini et Maxi calcul total // recherche mini et Maxi calcul total
if ($vol<$volmin) $volmin = $vol; if ($vol < $volmin) $volmin = $vol;
if ($vol>$volmax) $volmax = $vol; if ($vol > $volmax) $volmax = $vol;
$voltot = $voltot + $vol; $voltot = $voltot + $vol;
$s_vol_22 = $s_vol_22.$vol.','; $s_vol_22 = $s_vol_22 . $vol . ',';
} } else $s_vol_22 = $s_vol_22 . 'null,';
else $s_vol_22 = $s_vol_22.'null,';
$while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // 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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
type: 'column', type: 'column',
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'Volume pompé "; echo " text: 'Volume pompé ";
if($voltot == 0) $volmin = 0; 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³'"; 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³'";
?> ?>
@ -125,7 +112,7 @@ $(function () {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -165,17 +152,16 @@ $(function () {
series: [{ series: [{
name: 'Volume pompé entre 22hoo-06hoo', name: 'Volume pompé entre 22hoo-06hoo',
data: [<?php echo $s_vol_6;?>] data: [<?php echo $s_vol_6; ?>]
}, { }, {
name: 'Volume pompé entre 06hoo-22hoo', name: 'Volume pompé entre 06hoo-22hoo',
data: [<?php echo $s_vol_22;?>] data: [<?php echo $s_vol_22; ?>]
}] }]
}); });
}); });
</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 <?php
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>

View File

@ -1,104 +1,95 @@
<?php require('head.php'); <?php require('head.php');
if(@$infos_user['droit'] > 0) if (@$infos_user['droit'] > 0) {
{
?> ?>
<script src="js/highcharts.js"></script> <script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script> <script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="calendrier.js"></script> <script type="text/javascript" src="calendrier.js"></script>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
<tr> <tr>
<td id="ds_calclass"></td> <td id="ds_calclass"></td>
</tr> </tr>
</table> </table>
<?php <?php
if(isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) if (isset($_GET['du'], $_GET['au']) && strtotime($_GET['du']) && strtotime($_GET['au'])) {
{
$date1 = date('Y-m-d', strtotime($_GET['du'])); $date1 = date('Y-m-d', strtotime($_GET['du']));
$date2 = date('Y-m-d', strtotime($_GET['au'])); $date2 = date('Y-m-d', strtotime($_GET['au']));
} } else {
else
{
$date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d')))); $date1 = date('Y-m-d', strtotime("-1 month", strtotime(date('Y-m-d'))));
$date2 = 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"); $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; $while_date = $date1;
$s_date = ''; $s_date = '';
while(strtotime($while_date) <= strtotime($date2)) while (strtotime($while_date) <= strtotime($date2)) {
{
$tab_vol_6[$while_date] = 'null'; $tab_vol_6[$while_date] = 'null';
$s_date = $s_date.'"'.date("d/m/y", 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_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 ($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))); $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date)));
} }
// calcul du nombre de jours sur l'intervalle // calcul du nombre de jours sur l'intervalle
$TDfin = strtotime($date2); // conversion timestamp $TDfin = strtotime($date2); // conversion timestamp
$TDDeb = strtotime($date1); $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; //$Nbjours = 31;
// Affichage des données bilan sur la période; // 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"> <script type="text/javascript">
$(function () { $(function() {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
type: 'column', type: 'column',
zoomType: 'x' zoomType: 'x'
}, },
title: { 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>";?>', 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 x: -20 //center
}, },
subtitle: { subtitle: {
<?php <?php
echo " text: 'Volume pompé "; echo " text: 'Volume pompé ";
if($voltot == 0) $volmin = 0; 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³'"; 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: { xAxis: {
labels: { labels: {
rotation: -60 rotation: -60
}, },
categories: [<?php echo $s_date;?>] categories: [<?php echo $s_date; ?>]
}, },
yAxis: { yAxis: {
title: { title: {
@ -121,14 +112,13 @@ $(function () {
}, },
series: [{ series: [{
name: 'Volume pompé', name: 'Volume pompé',
data: [<?php echo $s_vol_6;?>] data: [<?php echo $s_vol_6; ?>]
}] }]
}); });
}); });
</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 <?php
} } else echo 'Vous n\'êtes pas autorisé/connecté!';
else echo 'Vous n\'êtes pas autorisé/connecté!';
include('foot.php'); ?> include('foot.php'); ?>