Files
Chateau-deau/pompes.php
Le Stagiaire 0cfc5938bd first commit
2024-11-08 15:31:00 +01:00

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