Commit e15ef973 authored by JonathanMM's avatar JonathanMM

Merge branch 'multiTranche' into 'master'

Correction d'un problème avec les communes comportant plusieurs tranches

See merge request !15
parents 91865bcb e2ddf06e
......@@ -32,10 +32,14 @@ $smarty->assign(array(
//On récupère les stations de la tranche
$requete = $pdo->query('SELECT debut, fin FROM tranche WHERE insee = '.$insee.' ORDER BY debut');
$tranches = $requete->fetch();
$tranches = array();
$debutTranche = $tranches['debut'];
$finTranche = $tranches['fin'];
$tranchesData = $requete->fetchAll();
foreach($tranchesData as $tranche)
{
$tranches[] = array('debut' => $tranche['debut'], 'fin' => $tranche['fin']);
}
//Filtre 24 heures
$hier = new DateTime("-1day");
......@@ -58,9 +62,13 @@ $nbEbike = 0;
$nbEdock = 0;
$nbFreeEdock = 0;
if(!is_null($debutTranche) && !is_null($finTranche))
if(count($tranches) > 0)
{
$stations = getStatusByIdConso($idConso, 'stations.code >= '.$debutTranche.' AND stations.code <= '.$finTranche);
function genererFiltreTranches($tranche)
{
return '(stations.code >= '.$tranche['debut'].' AND stations.code <= '.$tranche['fin'].')';
}
$stations = getStatusByIdConso($idConso, implode(' OR ', array_map('genererFiltreTranches', $tranches)));
foreach($stations as $station)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment