network.php 1.67 KB
<?php
require_once("accesBase.php");
$capteurs = getSensors();
$raspberrys = getRaspberrys();
$nombre = count($raspberrys);
?>
<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-project-diagram"></i> Le réseau</h1>
		<img src="img/computer.jpg" alt="Ordinateur" style="width:100%; height:auto;">
		<?php
		$cpt = 0;
		foreach($raspberrys as $raspberry)
		{
			$cpt++;
			$ip = $raspberry['ip'];
			?>
			<table class="table table-striped table-hover table-bordered" style="margin-top:10px;">
				<thead class="thead-dark">
					<th width="15%"><img src="img/pi.png" alt="Raspberry" style="width:auto; height:50px;"></th>
					<th width="85%" colspan="2"><p style="font-size: 14px;"><?php echo $ip;?></p></th>
				</thead>
				<tbody>
					<?php
					foreach($capteurs as $capteur)
					{
						if($capteur['raspberry'] != $ip) { continue; }
						?>
						<tr>
							<?php
							if(strcmp($capteur['type'], "Température") == 0)
							{
								$source = "img/temperature.png";
							}
							else if(strcmp($capteur['type'], "Distance") == 0)
							{
								$source = "img/distance.png";
							}
							?>
							<td><img src="<?php echo $source;?>" alt="Capteur" style="width:auto; height:50px;"></td>
							<td><p class="tdp"><?php echo $capteur['nom'];?></p></td>
							<td><p class="tdp"><?php echo $capteur['unite'];?></p></td>
						</tr>
						<?php
					}
					?>
				</tbody>
			</table>
			<?php
			if($cpt < $nombre)
			{
				?>
				<img src="img/empty.jpg" alt="Ligne" style="width:100%; height:auto;">
			<?php
			}
		}
		?>
	</div>
</div>