diff options
Diffstat (limited to 'src/controller/ajax_calendar_visitor.php')
| -rw-r--r-- | src/controller/ajax_calendar_visitor.php | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/controller/ajax_calendar_visitor.php b/src/controller/ajax_calendar_visitor.php deleted file mode 100644 index dcdbebd..0000000 --- a/src/controller/ajax_calendar_visitor.php +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/controller/ajax_calendar_visitor.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | use App\Entity\Event; | ||
| 7 | |||
| 8 | // chargement des évènements à la création du calendrier | ||
| 9 | // et au changement de dates affichées (boutons flèches mais pas changement de vue) | ||
| 10 | if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['action']) && $_GET['action'] === 'get_events' | ||
| 11 | && isset($_GET['start']) && isset($_GET['end']) && empty($_POST)) | ||
| 12 | { | ||
| 13 | // bornes début et fin du calendrier affiché à l'heure locale | ||
| 14 | // noter que la vue "planning" est similaire à la vue "semaine" | ||
| 15 | $start = new DateTime($_GET['start']); | ||
| 16 | $end = new DateTime($_GET['end']); | ||
| 17 | $start->setTimezone(new DateTimeZone('UTC')); | ||
| 18 | $end->setTimezone(new DateTimeZone('UTC')); | ||
| 19 | |||
| 20 | // affichage format ISO à l'heure UTC | ||
| 21 | //$date->format('Y-m-d\TH:i:s\Z'); | ||
| 22 | |||
| 23 | // on prend les évènements se finissant après le début ou commençant avant la fin de la fourchette | ||
| 24 | $dql = 'SELECT e FROM App\Entity\Event e WHERE e.end >= :start AND e.start <= :end'; | ||
| 25 | $bulk_data = $entityManager->createQuery($dql) | ||
| 26 | ->setParameter('start', $start) | ||
| 27 | ->setParameter('end', $end) | ||
| 28 | ->getResult(); | ||
| 29 | |||
| 30 | $events = []; | ||
| 31 | foreach($bulk_data as $one_entry){ | ||
| 32 | $event = new EventDTO($one_entry); | ||
| 33 | $events[] = $event->toArray(); | ||
| 34 | } | ||
| 35 | |||
| 36 | header('Content-Type: application/json'); | ||
| 37 | echo json_encode($events); | ||
| 38 | die; | ||
| 39 | } \ No newline at end of file | ||
