recherche.php 3.01 KB
<?php
session_start();
?>
<!DOCTYPE html>

<html>
        <head>
                <?php include("head.php"); ?>
        </head>

        <!-- Contenu du site -->
        <body>
                <?php 
                include("header.php");
                if(isset($_SESSION['Login'], $_SESSION['Password']))
                {
                        ?>
			<div class="row">
			        <div class="col-6 col-md-6 offset-md-3 offset-3">
                			<br/>
                			<h1 style="margin-bottom:20px; margin-top:60px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fas fa-history"></i> Historique</h1>
                			<table class="table table-striped table-bordered">
                        			<tbody>
                                			<th class="thead-dark">
                                		        	<td>Nom</td>
                                        			<td>Raspberry</td>
                                        			<td>Type</td>
                                        			<td>Valeur</td>
                                        			<td>Unité</td>
                                        			<td>Date</td>
                                			</th>

                                			<div id="sensors">
                                        			<?php
								$name = $_POST['nom'];
								$type = $_POST['type'];
								$raspberry = $_POST['raspberry'];
								$start = $_POST['start-date'];
								$end = $_POST['end-date'];
								if(($end == NULL) || ($end < $start)) {$e = date_max(); $end = $e['max'];}
								else $end = $end." 23:59:59";
								if($start == NULL) {$s = date_min(); $start = $s['min'];}
								else $start = $start."  00:00:00";

								$history = getHistory($name, $type, $raspberry, $start, $end, $_POST['nombre']);
                                        			foreach($history as $sensor){
                                                			?>
                                                			<tr>
                                                        			<td><?php echo $sensor['name'];?></td>
                                                        			<td><?php echo $sensor['raspberry'];?></td>
                                                        			<td><?php echo $sensor['type'];?></td>
                                                        			<td><?php echo $sensor['value'];?></td>
                                                        			<td><?php echo $sensor['unite'];?></td>
                                                        			<td><?php echo $sensor['date'];?></td>
                                                			</tr>
                                                			<?php
                                        			}
                                        			?>
                                			</div>
                        			</tbody>
                			</table>
        			</div>
			</div>
			<?php
                }
                else
                {
                        include("formConnexion.php");
                }
                ?>
        </body>
</html>