- Code: Tout sélectionner
<?php
include("./pages/conf_zibase.php");
include("zibase.php");
$zibase = new ZiBase($ipzibase);
if(isset($_POST['VALIDER'])) {
$cal = new ZbCalendar();
for ($j = 0; $j < 24; $j++) {
if($_POST[$j] == 'on'){
$val = 1;
} else {
$val = 0;
}
$cal->hour[$j] = $val;
//echo $j;
//echo '=';
//echo $cal->hour[$j];
}
if($_POST['lundi'] == 'on'){
$lundi = 1;
} else {
$lundi = 0;
}
if($_POST['mardi'] == 'on'){
$mardi = 1;
} else {
$mardi = 0;
}
if($_POST['mercredi'] == 'on'){
$mercredi = 1;
} else {
$mercredi = 0;
}
if($_POST['jeudi'] == 'on'){
$jeudi = 1;
} else {
$jeudi = 0;
}
if($_POST['vendredi'] == 'on'){
$vendredi = 1;
} else {
$vendredi = 0;
}
if($_POST['samedi'] == 'on'){
$samedi = 1;
} else {
$samedi = 0;
}
if($_POST['dimanche'] == 'on'){
$dimanche = 1;
} else {
$dimanche = 0;
}
$cal->day['lundi'] = $lundi;
$cal->day['mardi'] = $mardi;
$cal->day['mercredi'] = $mercredi;
$cal->day['jeudi'] = $jeudi;
$cal->day['vendredi'] = $vendredi;
$cal->day['samedi'] = $samedi;
$cal->day['dimanche'] = $dimanche;
$zibase->setCalendar($_POST['id'],$cal);
}
if(isset($_POST['Modifier_vcj'])) {
$zibase->setVariable($_POST['id'],$_POST['temperature']*10);
}
if(isset($_POST['Modifier_vcn'])) {
$zibase->setVariable($_POST['id'],$_POST['temperature']*10);
}
if(isset($_POST['Modifier_mode'])) {
$zibase->setVariable($_POST['id'],$_POST['mode']);
}
$thermostat=$zibase->getThermostat($idzibase,$tokenzibase);
$thermostatnb = count($thermostat);
$i = 1;
while($i <= $thermostatnb) {
echo "<p align=center>".$thermostat[$i]['0']."</p>";
echo "<p align=center>Temperature d'entree : ".(($zibase->getVariable($thermostat[$i]['3']))/10)."°</p>";
?> <FORM method="post" action=""> <?php
echo "<p align=center>Consigne de jour : ".(($zibase->getVariable($thermostat[$i]['4']))/10)."° ";
?>
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $thermostat[$i]['4']; ?>">
<INPUT TYPE="text" size="3" NAME="temperature" VALUE="<?php echo (($zibase->getVariable($thermostat[$i]['4']))/10); ?>">
<INPUT TYPE="SUBMIT" NAME="Modifier_vcj" VALUE="Modifier">
</p></FORM>
<FORM method="post" action="">
<?php
echo "<p align=center>Consigne de nuit : ".(($zibase->getVariable($thermostat[$i]['6']))/10)."° ";
?>
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $thermostat[$i]['6']; ?>php">
<INPUT TYPE="text" size="3" NAME="temperature" VALUE="<?php echo (($zibase->getVariable($thermostat[$i]['6']))/10); ?>">
<INPUT TYPE="SUBMIT" NAME="Modifier_vcn" VALUE="Modifier">
</p></FORM>
<?php
echo "<p align=center>Hysteresis : ".$thermostat[$i]['8']."</p>";
echo "<p align=center>Actif : ".(($zibase->getVariable($thermostat[$i]['10']))/10)."</p>";
echo "<center><p align=center>Mode : <br>";
?>
<FORM method="post" action="./index.php?page=thermostat">
<input type="radio" name="mode" value="0"<?php if($zibase->getVariable($thermostat[$i]['5']) == "0") { echo " checked"; } ?>>Auto |
<input type="radio" name="mode" value="16"<?php if($zibase->getVariable($thermostat[$i]['5']) == "16") { echo " checked"; } ?>>Jour |
<input type="radio" name="mode" value="32"<?php if($zibase->getVariable($thermostat[$i]['5']) == "32") { echo " checked"; } ?>>Jour temporaire |
<input type="radio" name="mode" value="6"<?php if($zibase->getVariable($thermostat[$i]['5']) == "6") { echo " checked"; } ?>>Hor gel |
<input type="radio" name="mode" value="48"<?php if($zibase->getVariable($thermostat[$i]['5']) == "48") { echo " checked"; } ?>>Nuit |
<input type="radio" name="mode" value="64"<?php if($zibase->getVariable($thermostat[$i]['5']) == "64") { echo " checked"; } ?>>Nuit temporaire |
<input type="radio" name="mode" value="5"<?php if($zibase->getVariable($thermostat[$i]['5']) == "5") { echo " checked"; } ?>>Stop
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $thermostat[$i]['5']; ?>">
<INPUT TYPE="SUBMIT" NAME="Modifier_mode" VALUE="Modifier">
</FORM></p></center>
<?php
for ($k = 0; $k < 3; $k++) {
$calendrier=$zibase->getCalendar($thermostat[$i]['7']+$k);
echo "<center>Calendrier Numero ".($thermostat[$i]['7']+$k)."</center>";
?>
<center><p align="center"><form method="post" action="">
<?php
for ($j = 0; $j < 24; $j++) {
if($j > 0 && $j <> 13) { echo " | "; }
if($j == 13) { echo "<br>"; }
?>
<?php echo $j; ?>h <input type="checkbox" name="<?php echo $j;?>"<?php if($calendrier->hour[$j] == "1") {echo "checked";} ?>>
<?php } ?>
<BR>
Lundi <input type="checkbox" name="lundi"<?php if($calendrier->day['lundi'] == "1") { echo "checked"; } ?>>
| Mardi <input type="checkbox" name="mardi"<?php if($calendrier->day['mardi'] == "1") { echo "checked"; } ?>>
| Mercredi <input type="checkbox" name="mercredi"<?php if($calendrier->day['mercredi'] == "1") {echo "checked";} ?>>
| Jeudi <input type="checkbox" name="jeudi"<?php if($calendrier->day['jeudi'] == "1") {echo "checked";} ?>>
| Vendredi <input type="checkbox" name="vendredi"<?php if($calendrier->day['vendredi'] == "1") {echo "checked";} ?>>
| Samedi <input type="checkbox" name="samedi"<?php if($calendrier->day['samedi'] == "1") {echo "checked";} ?>>
| Dimanche <input type="checkbox" name="dimanche"<?php if($calendrier->day['dimanche'] == "1") {echo "checked";} ?>>
<INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $thermostat[$i]['7']+$k; ?>">
<br>
<INPUT TYPE="SUBMIT" NAME="VALIDER" VALUE="VALIDER">
</form></p></center>
<?php
}
$i++;
}
?>
Et pour eviter les erreurs de "Undefined offset:" qui vont s'afficher sur la page lors de la validation d'un post , il faut modifier le fichier php.ini et remplacer cette ligne : error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
par error_reporting = E_ALL & ~E_NOTICE.