Skip to content

Commit

Permalink
Merge pull request #33 from wallforfry/master
Browse files Browse the repository at this point in the history
Aurion validé par le smig
  • Loading branch information
kevin-ta authored Jun 21, 2017
2 parents 80fb7c6 + 6769555 commit 8adc7f2
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
Agenda
</a>
</li>
<li {% block liMarks %}{% endblock %}>
<!--<li {% block liMarks %}{% endblock %}>
<a href="{{ path('application_marks_homepage') }}">
<i class="fa fa-eye"></i>
Mes Notes
Expand All @@ -151,7 +151,7 @@
<i class="fa fa-list"></i>
Mes Appréciations
</a>
</li>
</li>-->
</ul>
</li>
<li class="dropdown{% block liServices %}{% endblock %}">
Expand Down
77 changes: 75 additions & 2 deletions src/Application/AurionBundle/Controller/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

}

}
}
2 changes: 1 addition & 1 deletion src/Application/AurionBundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
</div>
<div class="panel-body">

<form id="connexionForm" class="form-horizontal" action="{{ path('application_calendar_groups')}}" method="POST">
<form id="connexionForm" class="form-horizontal" action="{{ path('application_calendar_login')}}" method="POST">
<div class="form-group" id="login">
<label class="col-lg-3 col-sm-3 control-label" for="login">Login ESIEE :</label>
<label class="col-lg-3 col-sm-3 control-label" for="login">Mail ou identifiant ESIEE :</label>
<div class="col-lg-9 col-sm-9">
<input type="text" class="form-control" id="login" name="login" required="required" placeholder="Login ESIEE"/>
<input type="text" class="form-control" id="login" name="mail" required="required" placeholder="Login ESIEE"/>
</div>
</div>
<div class="form-group" id="password" >
Expand Down

0 comments on commit 8adc7f2

Please sign in to comment.