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