templates/website/workshop/ateliers.html.twig line 1

Open in your IDE?
  1. {% extends "website/base.html.twig" %}
  2. {% block title %}Ateliers{% endblock %}
  3. {% block body %}
  4. <div class="container workregister">
  5.     <div class="row">
  6.         <div class="col">
  7.             <div class="workregister__inner">
  8.                 <h2>Comment m'inscrire ?</h2>
  9.                 <p>Si vous souhaitez vous inscrire à l’un de nos ateliers, vous pouvez nous contacter par :</p>
  10.                 <ul>
  11.                     <li><img src="website/Assets/dot-li.svg" alt="Point de liste"><a href="{{ path('contact')}}">Via notre formulaire de contact</a></li>
  12.                     <li><img src="website/Assets/dot-li.svg" alt="Point de liste">Mail : contact@lamargueriteasso.fr</li>
  13.                     <li><img src="website/Assets/dot-li.svg" alt="Point de liste">Tel : 05 55 01 35 94</li>
  14.                 </ul>
  15.                 <p>Vous pouvez également <a href="/contact">demander un entretien individuel santé.</a></p>
  16.             </div>
  17.         </div>
  18.     </div>
  19. </div>
  20. <div class="container searchwork">
  21.     <div class="row">
  22.         <div class="col">
  23.             <div class="searchwork__inner">
  24.                 <select name="category" id="searchwork_cat">
  25.                     <option value="" disabled selected hidden>Choisir une catégorie</option>
  26.                     {% for cat in workshopCat %}
  27.                     <option value="{{cat.id}}">{{cat.name}}</option>
  28.                     {% endfor %}
  29.                 </select>
  30.                 <section>
  31.                     <input type="text" id="searchwork_bar" placeholder="Rechercher un atelier">
  32.                     <button><img src="website/Assets/loupe.svg" alt="icone de loupe"></button>
  33.                 </section>
  34.                 <button><a {{latestFilename}}>Télécharger le calendrier</a></button>
  35.                 {# TODO problème, c'est pas bon car l'heure actuelle n'égale pas l'heure du dernier fichier #}
  36.             </div>
  37.         </div>
  38.     </div>
  39. </div>
  40. <div class="container workcontainer">
  41.     <div class="row">
  42.         {% for work in workshop %}
  43.         <div class="col-12 col-lg-12 col-xl-4">
  44.             <div data-w-color="{{work.workshopCategory.color}}" class="workcard">
  45.                 <section class="workcard__header">
  46.                     {# Affichage de l'image de l'atelier s'il y en a une, sinon affichage de la photo de profil du premier animateur #}
  47.                     {% if work.image is not empty %}
  48.                         <img class="BORDER_color_change" src="/assets/images/{{work.image.id}}.{{work.image.extension}}" alt="Photo de profil">
  49.                     {% else %}
  50.                         {% if work.contributors is not empty %}
  51.                             {% set firstContributor = work.contributors|first %}
  52.                             {% if firstContributor.profilePic is null %}
  53.                                 <div class="BG_color_change BORDER_color_change"></div>
  54.                             {% else %}
  55.                                 <img class="BORDER_color_change" src="/assets/images/{{firstContributor.profilePic.id}}.{{firstContributor.profilePic.extension}}" alt="Photo de profil">
  56.                             {% endif %}
  57.                         {% endif %}
  58.                     {% endif %}
  59.                     <ul>
  60.                         <li><h2 class="TEXT_color_change">{{work.name}}</h2></li>
  61.                         {% if work.contributors is not empty %}
  62.                             {# Pour chaque animateur de l'événement : 
  63.                                 - S'il ne possède pas de structure, on affiche son nom
  64.                                 - S'il possède une structure :
  65.                                     - Si l'animateur est en showOrganisation, on affiche la structure
  66.                                     - Sinon, on affiche la structure et le nom de l'animateur
  67.                             #}
  68.                             {% for cont in work.contributors %}
  69.                                 {% if cont.organisation is null %}
  70.                                     <li><h2>{{ cont.firstname }} {{ cont.lastname }}</h2></li>
  71.                                 {% else %}
  72.                                     
  73.                                         {% if cont.showOrganisation == true %}
  74.                                             <li><h2>{{ cont.organisation }}</h2></li>
  75.                                         {% else %}
  76.                                             <li>
  77.                                                 <h2>{{ cont.organisation }}</h2>
  78.                                                 <h3 class="workcard__header__names">{{ cont.firstname }} {{ cont.lastname }}</h3>
  79.                                             </li>
  80.                                         {% endif %}
  81.                                     
  82.                                 {% endif %}
  83.                             {% endfor %}
  84.                         {% endif %}
  85.                     </ul>
  86.                     <h3 class="BG_color_change workcard__header__tag">{{work.workshopCategory.name}}</h3>
  87.                 </section>
  88.         
  89.                 <section class="workcard__activity BORDER_color_change">
  90.                     <h3 class="TEXT_color_change">{{work.name}} ?</h3>
  91.                     <p>{{work.infoWorkshop}}</p>
  92.                 </section>
  93.         
  94.                 <section class="workcard__content">
  95.                     <h3 class="TEXT_color_change">Activités des scéances :</h3>
  96.                     <p>{{work.activityWorkshop}}</p>
  97.                 </section>
  98.         
  99.                 <section class="workcard__info BG_color_change">
  100.                     <h3>Lieux, Jours & Heures</h3>
  101.                     <p>{{work.place}} <br> {{work.day}} <br> {{work.hours}} </p>
  102.                 </section>
  103.             </div>
  104.         </div>
  105.         {% endfor %}
  106.     </div>
  107. </div>
  108. {{ include("website/workshop/workshop_card_template.html.twig") }}
  109. {% endblock %}
  110. {% block javascripts %}
  111. <script>
  112. $(document).ready(function() {
  113.     // Change the color of the workshop card depending on the category
  114.     function colorWorkshopCard() {
  115.         $('.workcard').each(function() {
  116.             // Get the color
  117.             var color = $(this).data('w-color');
  118.             // For each element in the card, change the color
  119.             $(this).find('.BG_color_change').css('background-color', color);
  120.             $(this).find('.TEXT_color_change').css('color', color);
  121.             $(this).find('.BORDER_color_change').css('border-color', color);
  122.         });
  123.     }
  124.     colorWorkshopCard();
  125.     $('#searchwork_cat').change(function() {
  126.         // Get the id of the category
  127.         var category = $(this).val();
  128.         $.ajax({
  129.             url: '/api/search/workshop/category?id=' + category, 
  130.             method: 'GET',
  131.             success: function(data) {
  132.                 // Replace the cards and color them
  133.                 replaceWorkshopCards(data);
  134.                 colorWorkshopCard();
  135.             }
  136.         });
  137.     });
  138.     
  139.     $('#searchwork_bar').next('button').click(function(e) {
  140.         e.preventDefault();
  141.         // Get the value of the searchbar
  142.         var searchTerm = $('#searchwork_bar').val();
  143.         $.ajax({
  144.             url: '/api/search/workshop/content?value=' + searchTerm, 
  145.             method: 'GET',
  146.             success: function(data) {
  147.                 // Replace the cards and color them
  148.                 replaceWorkshopCards(data);
  149.                 colorWorkshopCard();
  150.             }
  151.         });
  152.     });
  153.     $('#searchwork_bar').keypress(function(e) {
  154.         if(e.which == 13) {
  155.             // If enter key is pressed
  156.             e.preventDefault();
  157.             // Get the value of the searchbar
  158.             var searchTerm = $('#searchwork_bar').val();
  159.             $.ajax({
  160.                 url: '/search/workshop/content?value=' + searchTerm, 
  161.                 method: 'GET',
  162.                 success: function(data) {
  163.                     // Replace the cards and color them
  164.                     replaceWorkshopCards(data);
  165.                     colorWorkshopCard();
  166.                 }
  167.             });
  168.         }
  169.     });
  170. });
  171. // Create a list of all the Workshop cards
  172. function replaceWorkshopCards(workshops) {
  173.     
  174.     let listHTML = "";
  175.     // For each table of data, create a card and add it to the list
  176.     workshops.forEach(workshop => {
  177.         listHTML +=createWorkshopCard(workshop);
  178.     });
  179.     // Replace the container content with all the cards created
  180.     $('.workcontainer .row').html(listHTML);
  181. }
  182. // Create a card using the workshop data
  183.     function createWorkshopCard(workshop) {
  184.         // Get the template
  185.         var template_workshop_card = $('#workshop_card_template').html();
  186.         // Get the first contributor's image
  187.         var firstContributorImage = workshop.contributors.length > 0 ? workshop.contributors[0].image : null;
  188.         // Build the list of contributors
  189.         var contributorsList = workshop.contributors.map(contributor => {
  190.             if (contributor.organisation == null) {
  191.                 return `<h2>${contributor.firstname} ${contributor.lastname}</h2>`;
  192.             } else {
  193.                 if (contributor.showOrganisation) {
  194.                     console.log(1);
  195.                     return `<h2>${contributor.organisation}</h2>`;
  196.                 }
  197.                 else {
  198.                     console.log(2);
  199.                     return `<h2>${contributor.organisation}</h2> <h3 class="workcard__header__names">${contributor.firstname} ${contributor.lastname}</h3>`;
  200.                 }
  201.                 
  202.                 return null;
  203.             }
  204.         }).filter(contributor => contributor !== null).join(', ');
  205.         // Replace the placeholders with the data
  206.         var listHTML = template_workshop_card
  207.             .replace(/%name%/g, workshop.name)
  208.             .replace(/%contributors%/g, contributorsList)
  209.             .replace(/%cont_image%/g, firstContributorImage ? `${firstContributorImage}` : 'default-image-path.jpg')
  210.             .replace(/%cat_name%/g, workshop.cat_name)
  211.             .replace(/%cat_color%/g, workshop.cat_color)
  212.             .replace(/%info%/g, workshop.info)
  213.             .replace(/%activity%/g, workshop.activity)
  214.             .replace(/%place%/g, workshop.place)
  215.             .replace(/%day%/g, workshop.day)
  216.             .replace(/%hours%/g, workshop.hours);
  217.         return listHTML;
  218.     }
  219. </script>
  220. {% endblock %}