diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig
index c0ad769..a27038b 100755
--- a/app/Resources/views/base.html.twig
+++ b/app/Resources/views/base.html.twig
@@ -134,7 +134,7 @@
Agenda
-
+
diff --git a/src/Application/AurionBundle/Controller/CalendarController.php b/src/Application/AurionBundle/Controller/CalendarController.php
index a5189da..a6126f8 100644
--- a/src/Application/AurionBundle/Controller/CalendarController.php
+++ b/src/Application/AurionBundle/Controller/CalendarController.php
@@ -159,8 +159,8 @@ public function getAgendaAction($groups){
$event_id = $event_id + 1;
}
- $ics_file = $this->decode($event_json);
- file_put_contents("agenda/ics/".$_POST["login"].".ics", $ics_file, LOCK_EX);
+ #$ics_file = $this->decode($event_json);
+ #file_put_contents("agenda/ics/".$_POST["login"].".ics", $ics_file, LOCK_EX);
return $event_json;
}
@@ -237,4 +237,77 @@ public function getDataAction(){
return $response;
}
}
+
+ public function getAgendaFromCSVAction(){
+
+ $url = "http://localhost:5000/api/ade-esiee/agenda";
+
+ $data = array("mail" => $_POST['mail']);
+
+ $ch = curl_init($url);
+
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $response = curl_exec($ch);
+ curl_close($ch);
+
+
+ $event_list = json_decode($response, true);
+ $event_json = array();
+
+ if(!empty($event_list[0]["error"])){
+ $response = new Response(json_encode("1"));
+ $response->headers->set('Content-Type', 'application/json');
+ return $response;
+ }
+ else {
+
+ $event_id = 0;
+
+ foreach ($event_list as $event) {
+ if (preg_match("/TD/", $event["name"])) {
+ $color = "#f39c12";
+ }
+ elseif (preg_match("/CTRL/", $event["name"])){
+ $color = "#e74c3c";
+ }
+ elseif (preg_match("/PERS/", $event["name"])){
+ $color = "#95a5a6";
+ }
+ elseif (preg_match("/TP/", $event["name"])){
+ $color = "#27ae60";
+ }
+ else {
+ $color = "#35a9fb";
+ }
+
+ $event_json[] = array(
+ 'id' => $event_id,
+ 'title' => $event["name"]."\n".$event["unite"]."\n".$event["rooms"]."\n".$event["prof"],
+ 'name' => $event["name"],
+ 'start' => date("Y-m-d H:i:s", strtotime($event["start"])),
+ 'end' => date("Y-m-d H:i:s", strtotime($event["end"])),
+ 'allDay' => false,
+ 'color' => $color,//$event->getCategory()->getBackgroundColor(),
+ 'textColor' => "white",//$event->getCategory()->getTextColor(),
+ 'place' => $event["rooms"],
+ 'prof' => $event["prof"],
+ 'club_id' => null,
+ 'news_ids' => 0,
+ );
+ $event_id = $event_id + 1;
+ }
+
+ $ics_file = $this->decode($event_json);
+ file_put_contents("agenda/ics/".$_POST["mail"].".ics", $ics_file, LOCK_EX);
+
+ $response = new Response(json_encode($event_json));
+ $response->headers->set('Content-Type', 'application/json');
+ return $response;
+
+ }
+
+ }
}
diff --git a/src/Application/AurionBundle/Resources/config/routing.yml b/src/Application/AurionBundle/Resources/config/routing.yml
index fec3277..ed76184 100644
--- a/src/Application/AurionBundle/Resources/config/routing.yml
+++ b/src/Application/AurionBundle/Resources/config/routing.yml
@@ -4,7 +4,7 @@ application_calendar_homepage:
application_calendar_login:
path: /aurion/agenda/login
- defaults: { _controller: ApplicationAurionBundle:Calendar:getData}
+ defaults: { _controller: ApplicationAurionBundle:Calendar:getAgendaFromCSV}
application_calendar_groups:
path: /aurion/agenda/groups
diff --git a/src/Application/AurionBundle/Resources/views/Aurion/agenda.html.twig b/src/Application/AurionBundle/Resources/views/Aurion/agenda.html.twig
index bd805cf..a1eb47a 100644
--- a/src/Application/AurionBundle/Resources/views/Aurion/agenda.html.twig
+++ b/src/Application/AurionBundle/Resources/views/Aurion/agenda.html.twig
@@ -38,11 +38,11 @@