templates/default/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Calendrier{% endblock %}
  3. {% block body %}
  4.     <div id="form_event" class="parent" style="display: none;">
  5.         <div id="container_close"><i id="close" class="fa fa-2x fa-times"></i></div>
  6.         <div id="form_event_detail"></div>
  7.     </div>
  8.     <div id="calendrier"></div>
  9. {% endblock %}
  10. {% block javascripts %}
  11.     <script>
  12.         var calendar;
  13.         var calendarElt;
  14.         {% if app.user %} 
  15.         function addEvent(e) {
  16.             self.location.href = '/admin/calendrier/newcalendrier/';
  17.         }
  18.         function showEvent(e) {
  19.             self.location.href = '/admin/calendrier/edit/' + e.id;
  20.         }
  21.         {% else %}
  22.             function showEvent(e) {
  23.                 if (e.id == -1) {
  24.                     return;
  25.                 }
  26.                 let url = '/api/' + e.id + '/getevent';
  27.                 let xhr = new XMLHttpRequest;
  28.                 xhr.responseType = 'json';
  29.                 xhr.open("GET", url, true);
  30.                 xhr.onload = (e) => {
  31.                     if (xhr.readyState === 4) {
  32.                         if (xhr.status === 200) {
  33.                             let e = xhr.response;
  34.                             let ds = new Date(e.start);
  35.                             var html = '<div class="event-title text-center"><h2>' + e.title + '</h2></div>';
  36.                             html += '<div class="event-title">Début : ' + ds.toLocaleString("fr") + '</div>';
  37.                             if (e.end !== null) {
  38.                                 let de = new Date(e.end);
  39.                                 html += '<div class="event-title">Fin : ' + de.toLocaleString("fr") + '</div>';
  40.                             }
  41.                             html += '<div class="event-title">Description : ' + e.description + '</div>';
  42.                             html += '<div class="event-title">Lieu : ' + e.lieu + '</div>';
  43.                             document.querySelector("#form_event_detail").style.padding = "6px";
  44.                             document.querySelector("#form_event_detail").style.backgroundColor = e.backgroundColor;
  45.                             document.querySelector("#form_event_detail").style.color = e.textColor;
  46.                             document.querySelector("#form_event_detail").style.border = "solid " + e.borderColor;
  47.                             document.querySelector("#form_event_detail").innerHTML = html;
  48.                             document.querySelector("#form_event").style.display = 'block';
  49.                         } else {
  50.                             console.error(xhr.statusText);
  51.                         }
  52.                     }
  53.                 };
  54.                 xhr.send(null);
  55.             }
  56.         {% endif %}
  57.             function initializeCalendrier() {
  58.                 calendar = new FullCalendar.Calendar(calendarElt, {
  59.                     initialView: 'dayGridMonth',
  60.                     locale: 'fr',
  61.                     timeZone: 'Europe/Paris',
  62.                     handleWindowResize: true,
  63.                     height: 800,
  64.                     allDayText: 'Journée',
  65.                     firstDay: 1,
  66.                     weekNumbers: true,
  67.                     weekText: "S",
  68.                     buttonText: {
  69.                         today: 'Aujourd\'hui',
  70.                         month: 'Mois',
  71.                         week: 'Semaine',
  72.                         day: 'Journée'
  73.                     },
  74.                     buttonIcons: {
  75.                         'loggedButton': 'fa-logged',
  76.         {% if app.user %}
  77.                         'loginButton': 'fa-sign-logout',
  78.         {% else %}
  79.                         'loginButton': 'fa-sign-login'
  80.         {% endif %}
  81.                     },
  82.                     headerToolbar: {
  83.                         start: '{{ app.user ? 'loggedButton backendButton '}}loginButton prevYear,nextYear prev,next today',
  84.                         center: 'title',
  85.                         end: 'dayGridMonth timeGridWeek timeGridDay'
  86.                     },
  87.                     footerToolbar: {
  88.                         center: 'showCarteButton'
  89.                     },
  90.                     customButtons: {
  91.         {% if app.user %}
  92.                         backendButton: {
  93.                             text: 'Espace admin',
  94.                             click: function (e) {
  95.                                 e.stopPropagation();
  96.                                 self.location.href = '{{asset(path('admin'))}}';
  97.                             }
  98.                         },
  99.         {% endif %}
  100.                         showCarteButton: {
  101.                             text: 'Voir sur la carte',
  102.                             click: function (e) {
  103.                                 self.location.href = '{{asset(path('carte'))}}';
  104.                             }
  105.                         },
  106.                         loggedButton: {
  107.                             text: '{{ app.user ? 'Vous êtes identifié-e comme ' ~ app.user.username}}'
  108.                         },
  109.                         loginButton: {
  110.                             text: '{{ app.user ? 'Déconnection' : 'Identifiez-vous' }}',
  111.                             click: function (e) {
  112.         {% if app.user %}
  113.                                 self.location.href = '{{asset(path('app_logout'))}}';
  114.         {% else %}
  115.                                 self.location.href = '{{asset(path('app_login'))}}';
  116.         {% endif %}
  117.                             }
  118.                         }
  119.                     },
  120.                     eventSources: ['api/getallevents'],
  121.                     editable:{{app.user ? 'true' : 'false'}} ,
  122.                     eventResizableFromStart: true
  123.                 });
  124.                 calendar.on('eventClick', (e) => {
  125.                     showEvent(e.event);
  126.                 });
  127.         {% if app.user %}
  128.                 calendar.on('dateClick', (e) => {
  129.                     addEvent(e);
  130.                 });
  131.                 calendar.on('eventChange', (e) => {
  132.                     let donnees = {
  133.                         "id": e.event.id,
  134.                         "title": e.event.title,
  135.                         "description": e.event.extendedProps.description,
  136.                         "start": e.event.start,
  137.                         "end": e.event.end,
  138.                         "backgroundColor": e.event.backgroundColor,
  139.                         "borderColor": e.event.borderColor,
  140.                         "textColor": e.event.textColor,
  141.                         "allDay": e.event.allDay,
  142.                         "lieu": e.event.lieu,
  143.                         "latitude": e.event.latitude,
  144.                         "longitude": e.event.longitude
  145.                     };
  146.                     setEvent(donnees);
  147.                 });
  148.         {% endif %}
  149.                 calendar.render();
  150.             }
  151.             function setEvent(donnees) {
  152.                 let url = '/api/' + donnees.id + '/edit';
  153.                 let xhr = new XMLHttpRequest;
  154.                 xhr.open("PUT", url);
  155.                 xhr.send(JSON.stringify(donnees));
  156.                 xhr.onload = (e) => {
  157.                     if (xhr.readyState === 4) {
  158.                         if (xhr.status === 200) {
  159.                             document.querySelector("#form_event").style.display = 'none';
  160.                             calendar.refetchEvents();
  161.                         }
  162.                     }
  163.                 };
  164.             }
  165.             window.onload = () => {
  166.                 calendarElt = document.querySelector("#calendrier");
  167.                 let closeBtn = document.querySelector("#close");
  168.                 closeBtn.addEventListener('click', function () {
  169.                     document.querySelector("#form_event").style.display = 'none';
  170.                 });
  171.                 calendarElt.addEventListener('click', function () {
  172.                     document.querySelector("#form_event").style.display = 'none';
  173.                 });
  174.                 initializeCalendrier();
  175.             };
  176.     </script>
  177.     <script src="{{ asset('js/tarteaucitron/tarteaucitron.js')}}"></script>
  178.     <script>
  179.         {#
  180.             tarteaucitron.init({
  181.                 "privacyUrl": "", /* Privacy policy url */
  182.                 "bodyPosition": "top", /* or top to bring it as first element for accessibility */
  183.                 "hashtag": "#tarteaucitron", /* Open the panel with this hashtag */
  184.                 "cookieName": "tarteaucitron", /* Cookie name */
  185.                 "orientation": "middle", /* Banner position (top - bottom - middle - popup) */
  186.                 "groupServices": false, /* Group services by category */
  187.                 "serviceDefaultState": "wait", /* Default state (true - wait - false) */
  188.                 "showAlertSmall": false, /* Show the small banner on bottom right */
  189.                 "cookieslist": false, /* Show the cookie list */
  190.                 "showIcon": true, /* Show cookie icon to manage cookies */
  191. // "iconSrc": "", /* Optionnal: URL or base64 encoded image */
  192.                 "iconPosition": "BottomRight", /* Position of the icon between BottomRight, BottomLeft, TopRight and TopLeft */
  193.                 "adblocker": false, /* Show a Warning if an adblocker is detected */
  194.                 "DenyAllCta": true, /* Show the deny all button */
  195.                 "AcceptAllCta": true, /* Show the accept all button when highPrivacy on */
  196.                 "highPrivacy": true, /* HIGHLY RECOMMANDED Disable auto consent */
  197.                 "handleBrowserDNTRequest": false, /* If Do Not Track == 1, disallow all */
  198.                 "removeCredit": true, /* Remove credit link */
  199.                 "moreInfoLink": true, /* Show more info link */
  200.                 "useExternalCss": false, /* If false, the tarteaucitron.css file will be loaded */
  201.                 "useExternalJs": false, /* If false, the tarteaucitron.services.js file will be loaded */
  202. //"cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for subdomain website */
  203.                 "readmoreLink": "", /* Change the default readmore link pointing to tarteaucitron.io */
  204.                 "mandatory": true, /* Show a message about mandatory cookies */
  205.                 "mandatoryCta": true /* Show the disabled accept button when mandatory on */
  206.             });
  207. #}
  208.     </script>
  209.     <script src="{{ asset('fullcalendar_5_11_3/lib/main.min.js') }}"></script>
  210. {% endblock %}