Ajout du code couleur pour les goals

This commit is contained in:
2025-03-18 22:20:16 +01:00
parent f0eef99c8f
commit e5099bd241
2 changed files with 67 additions and 3 deletions

View File

@@ -49,9 +49,18 @@ $compte = $base->querySingle("SELECT SUM(nombre) FROM chiffres WHERE date = \"".
<tr><th>Ville</th><th>Nombre de réponses</th><th>Chiffres de 2021</th></tr>
</thead>
<?php
$compte = $base->query("SELECT r1.nom as nom, r1.nombre as nombre, r2.nombre as nombre2021 FROM (SELECT * FROM chiffres c NATURAL JOIN Villes v WHERE c.date = '".$last_check."' ORDER BY c.nombre DESC) r1 LEFT JOIN (SELECT * FROM chiffres_2021) r2 ON r1.code_INSEE = r2.code_INSEE");
$compte = $base->query("SELECT r1.nom as nom, r1.nombre as nombre, r2.nombre as nombre2021, r1.population as population FROM (SELECT * FROM chiffres c NATURAL JOIN Villes v WHERE c.date = '".$last_check."' ORDER BY c.nombre DESC) r1 LEFT JOIN (SELECT * FROM chiffres_2021) r2 ON r1.code_INSEE = r2.code_INSEE ORDER BY nombre desc");
while( $line = $compte->fetchArray()) {
?><tr><td><?=$line['nom']?></td><td style="text-align: right;"><?=$line['nombre']?></td><td style="text-align: right;"><?=$line['nombre2021']?></td></tr>
$plus_que_2021 = $line['nombre'] > $line['nombre2021'];
$presque_plus_que_2021 = $line['nombre'] > 0.8 * $line['nombre2021'];
$seuil = $line['population'] <= 3000 ? 30 : 50 ;
$qualifie = $line['nombre'] >= $seuil;
$presque_qualifie = $line['nombre'] >= 0.8 * $seuil;
?><tr>
<td<?php if ($plus_que_2021): ?> style="background-color:lightgreen;"<?php elseif ($presque_plus_que_2021): ?> style="background-color:lightgoldenrodyellow;"<?php endif; ?>><?=$line['nom']?></td>
<td style="text-align: right;<?php if($qualifie): ?> background-color: lightgreen;<?php elseif($presque_qualifie): ?> background-color: lightgoldenrodyellow;<?php else: ?> background-color: lightsalmon;<?php endif; ?>"><?=$line['nombre']?></td>
<td style="text-align: right;"><?=$line['nombre2021']?></td>
</tr>
<?php
}
?></table>