From 9fb8327c240d80c15e7cd8c34f959960c07e5476 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 16 Sep 2017 12:19:05 +0200 Subject: [PATCH] Fixed location update page --- build/router/controller/ics.php | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/build/router/controller/ics.php b/build/router/controller/ics.php index f4535e5..6ed9d09 100644 --- a/build/router/controller/ics.php +++ b/build/router/controller/ics.php @@ -107,25 +107,17 @@ $location = []; /* (1) Get the list of available locations*/ - $sqlr = DatabaseDriver::getPDO()->prepare("SELECT l.id_location as idl, l.name as name, l.basename as basename, e.name as ename, e.color as color FROM location as l, event as e WHERE l.id_event = e.id_event AND e.id_diplome = :idd GROUP BY idl, name, basename, ename, color"); + $sqlr = DatabaseDriver::getPDO()->prepare("SELECT GROUP_CONCAT(DISTINCT l.id_location SEPARATOR ',') as idl, l.name as lname, l.basename as lbasename, e.name as ename, e.color as color FROM location as l, event as e WHERE l.id_event = e.id_event AND e.id_diplome = :idd GROUP BY lname, lbasename, ename, color ORDER BY ename ASC, lbasename ASC"); $sqlr->execute([ ':idd' => $this->diplome_id ]); $fetched = $sqlr->fetchAll(); - if( !$fetched ){ + if( !$fetched ) $fetched[] = []; - $locdata[] = []; - } - foreach($fetched as $raw){ - if( !isset($location[$raw['ename']]) ) - $location[$raw['ename']] = []; + // foreach($fetched as $raw) + // $location[$raw['ename']] = [ $raw['ename'], $raw['idl'], $raw['lname'], $raw['lbasename'], $raw['color'] ]; - $location[$raw['ename']][] = intval( $raw['idl'] ); - - $locdata[$raw['ename']] = [ $raw['name'], $raw['basename'], $raw['color'] ]; - - } // } @@ -133,12 +125,13 @@ echo "
"; echo ""; - foreach($location as $ename=>$ids){ + foreach($fetched as $raw){ - $color = $locdata[$ename][2]; - $id = implode(",", $ids); - $name = $locdata[$ename][0]; - $basename = $locdata[$ename][1]; + $color = $raw['color']; + $id = $raw['idl']; + $name = $raw['lname']; + $basename = $raw['lbasename']; + $ename = $raw['ename']; echo ""; }
LessonRead nameCorrection
$ename$basename