From f007bac3b9172711dc0fcca1306270ab99dbd8a4 Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 24 Jun 2025 01:04:35 +0200 Subject: =?UTF-8?q?am=C3=A9lioration=20affichage,=20contr=C3=B4le=20des=20?= =?UTF-8?q?entr=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/calendar.css | 24 +++++++- public/index.php | 8 ++- public/js/calendar.js | 21 ++++--- src/controller/calendar.php | 133 ++++++++++++++++++++++++++------------------ 4 files changed, 121 insertions(+), 65 deletions(-) diff --git a/public/css/calendar.css b/public/css/calendar.css index 5dfb343..b24fe5b 100644 --- a/public/css/calendar.css +++ b/public/css/calendar.css @@ -2,13 +2,15 @@ border: 2px double; border-radius: 5px; width: max-content; + padding: 5px; } #calendar_zone{ display: flex; - max-width: 1000px; + max-width: 1170px; + gap: 5px; } #calendar{ - width: -moz-available; + width: 1165px; } .event_title_box{ display: flex; @@ -46,4 +48,20 @@ td .fc-timegrid-axis{ color: white; background-color: #00679e; border-radius: 5px; -} \ No newline at end of file +} + +@media screen and (max-width: 900px){ + #calendar_zone{ + padding: 0; + } + .fc-toolbar-title{ + font-size: large !important; + } +} +@media screen and (max-width: 650px){ + .fc-toolbar-chunk{ + font-size: smaller; + } +} +@media screen and (max-width: 550px){ +} diff --git a/public/index.php b/public/index.php index 99220e8..540e8ab 100644 --- a/public/index.php +++ b/public/index.php @@ -8,6 +8,7 @@ require '../src/controller/calendar.php'; fullcalendar + @@ -17,7 +18,12 @@ require '../src/controller/calendar.php'; ' . "\n" : '' . "\n"; +if($_SESSION['admin'] === true){ + echo '' . "\n"; +} +else{ + echo '' . "\n"; +} ?> diff --git a/public/js/calendar.js b/public/js/calendar.js index 2193272..a092632 100644 --- a/public/js/calendar.js +++ b/public/js/calendar.js @@ -62,19 +62,24 @@ document.addEventListener('DOMContentLoaded', function(){ const start = formatDate(info.event.start); const start_date = start.split('T')[0]; const start_hour = (info.event.allDay ? '' : '
à ' + start.split('T')[1]).replace(":", "h"); - const formated_start = 'le ' + start_date.split('-')[2] + '/' + start_date.split('-')[1] + '/' + start_date.split('-')[0] + start_hour; + const formated_start = start_date.split('-')[2] + '/' + start_date.split('-')[1] + '/' + start_date.split('-')[0] + start_hour; const end = formatDate(info.event.allDay ? minusOneDay(info.event.end) : info.event.end, info.event.allDay); const end_date = end.split('T')[0]; const end_hour = (info.event.allDay ? '' : '
à ' + end.split('T')[1]).replace(":", "h"); - const formated_end = 'le ' + end_date.split('-')[2] + '/' + end_date.split('-')[1] + '/' + end_date.split('-')[0] + end_hour; + const formated_end = end_date.split('-')[2] + '/' + end_date.split('-')[1] + '/' + end_date.split('-')[0] + end_hour; - const aside_content = `
-

` + info.event.title + `

-

` + info.event.extendedProps.description + `

-

Journée entière:
` + (checked ? 'oui' : 'non') + `

-

Début:
` + formated_start + `

-

Fin:
` + formated_end + `

+ let aside_content = `
+

` + info.event.title + `

+

` + info.event.extendedProps.description + `

`; + if(checked && (formated_start === formated_end)){ // affichage simplifié évènement d'un jour + aside_content = aside_content + `

le ` + formated_start + `

`; + } + else{ + aside_content = aside_content + `

du ` + formated_start + `

+

au ` + formated_end + `

+
`; + } aside.innerHTML = aside_content; calendar.updateSize(); diff --git a/src/controller/calendar.php b/src/controller/calendar.php index ab2832e..c15141a 100644 --- a/src/controller/calendar.php +++ b/src/controller/calendar.php @@ -1,12 +1,31 @@ 1, - 'title' => 'Évènement1', - 'start' => '2025-06-03T05:00:00Z', // Z indique que l'heure est en UTC - 'end' => '2025-06-03T09:00:00Z', - 'allDay' => false, - 'color' => '#ffa500', // couleur hexa, éviter les couleurs CSS qui ne fonctionnent pas dans value="" en HTML - //'url' => 'https://dev.nageurs-bigoudens.fr', // comportement: https://fullcalendar.io/docs/eventClick - 'description' => 'blablabla', + 'id' => 1, + 'title' => 'Évènement1', + 'description' => 'blablabla', + 'start' => '2025-06-03T05:00:00Z', // Z indique que l'heure est en UTC + 'end' => '2025-06-03T09:00:00Z', + 'allDay' => false, + 'color' => '#ffa500', // couleur hexa, éviter les couleurs CSS qui ne fonctionnent pas dans value="" en HTML + //'url' => 'https://dev.nageurs-bigoudens.fr', // comportement: https://fullcalendar.io/docs/eventClick ], [ - 'id' => 2, - 'title' => 'Évènement2', - 'start' => '2025-06-06T08:00:00Z', - 'end' => '2025-06-07T08:00:00Z', - 'allDay' => false, - 'color' => '#e01b24', - 'description' => 'truc machin', + 'id' => 2, + 'title' => 'Évènement2', + 'description' => 'truc machin', + 'start' => '2025-06-06T08:00:00Z', + 'end' => '2025-06-07T08:00:00Z', + 'allDay' => false, + 'color' => '#e01b24', ], [ - 'id' => 3, - 'title' => 'Évènement3', - 'start' => '2025-06-08', - 'end' => '2025-06-09', - 'allDay' => true, // pas d'heure - 'color' => '#008000', - 'description' => 'ça va chier', + 'id' => 3, + 'title' => 'Évènement3', + 'description' => 'ça va chier', + 'start' => '2025-06-08', + 'end' => '2025-06-09', + 'allDay' => true, // pas d'heure + 'color' => '#008000', ], - // provoque une erreur, si allDay la fin ne peut être égale au début - /*[ - 'id' => 4, - 'title' => 'Évènement4', - 'start' => '2025-06-09', - 'end' => '2025-06-09', - 'allDay' => true, - 'color' => '#1a5fb4', - ],*/ ]; header('Content-Type: application/json'); @@ -71,29 +81,46 @@ if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['action']) && $_GET['acti // actions sur le calendrier elseif(isset($_SESSION['admin']) && $_SESSION['admin'] === true - && $_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE'] === 'application/json') + && $_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE'] === 'application/json') { - $data = file_get_contents('php://input'); - $json = json_decode($data, true); - - if($_GET['action'] === 'new_event'){ - // BDD - //print_r($json);die; - $id = 7; // généré par la BDD - echo json_encode(['success' => true, 'id' => $id]); + $data = file_get_contents('php://input'); + $json = json_decode($data, true); + + if($_GET['action'] === 'new_event'){ + try{ + $json = cleanInput($json); } - elseif($_GET['action'] === 'update_event'){ - // BDD - //print_r($json);die; - echo json_encode(['success' => true]); + catch(InvalidArgumentException $e){ + echo json_encode(['success' => false, 'error' => $e->getMessage()]); + http_response_code(400); + die; } - elseif($_GET['action'] === 'remove_event'){ - // BDD - //echo $json['id']; die; - echo json_encode(['success' => true]); + //print_r($json);die; + + $id = 7; // généré par la BDD + echo json_encode(['success' => true, 'id' => $id]); + } + elseif($_GET['action'] === 'update_event'){ + try{ + $json = cleanInput($json); } - else{ - echo json_encode(['success' => false]); + catch(InvalidArgumentException $e){ + echo json_encode(['success' => false, 'error' => $e->getMessage()]); + http_response_code(400); + die; } - die; -} \ No newline at end of file + //print_r($json);die; + + echo json_encode(['success' => true]); + } + elseif($_GET['action'] === 'remove_event'){ + $json['id'] = (int)$json['id']; + //echo $json['id']; die; + + echo json_encode(['success' => true]); + } + else{ + echo json_encode(['success' => false]); + } + die; +} -- cgit v1.2.3