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