templates/forum/detail.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block stylesheets %}
  3.     <link rel="stylesheet" href="{{ asset('css/detail-forum.css') }}">
  4.      <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"/> 
  5.     {% endblock %}
  6.     {% block body %}
  7.         <div class="section-about" id="section-about">
  8.             {% for message in app.flashes('success') %}
  9.                 <div class="alert alert-success alert-dismissible fade show col-md-6" role="alert">{{ message }}</div>
  10.             {% endfor %}
  11.             <div class="section-gallery">
  12.                 <div class="container">
  13.                     <div class="row  justify-content-center pb-5">
  14.                         <div class="row justify-content-center pb-5 {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  15.                             <h5>{% trans %} forum.details.forum {% endtrans %}</h5>
  16.                             <h2 class="pb-0">Lorem ipsum dolor</h2>
  17.                         </div>
  18.                     </div>
  19.                     <div class="box"></div>
  20.                     <div class="row  justify-content-center pb-5">
  21.                         <div class="row  justify-content-center pb-5">
  22.                             <div class="card-body {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  23.                                 <h6 class="card-title">
  24.                                     <strong>{{ sujetForum.sujet }}
  25.                                     </strong>
  26.                                 </h6>
  27.                                 <hr>
  28.                                     <p class="card-text">{{ sujetForum.description }}</p>
  29.                                     <h6 class="card-title">
  30.                                         <span id="date">
  31.                                    {{ app.request.locale == 'ar_TN' ? sujetForum.getDatePublic | date('Y/m/d') : sujetForum.getDatePublic | date('d/m/Y') }} </p></span>
  32.                                     </h6>
  33.                                 </div>
  34.                             </div>
  35.                         </div>
  36.                         <div class="row  justify-content-center pb-5">
  37.                             <div class="row  justify-content-center pb-5">
  38.                                 <form class="{{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}" method="post" action="{{ path('make_forum_response', { id: sujetForum.id }) }}" id="form-envoyer">
  39.                                     <input type="hidden" name="_token" value="{{ csrf_token('forum') }}">
  40.                                     <div
  41.                                         class="input-group">
  42.                                         <textarea name="message" class="form-control col-md-4" aria-label="With textarea" placeholder="{{ 'Réponse'|trans }}"></textarea>
  43.                                     </div>
  44.                                     <input id="sujetForumId" type="hidden" value="{{ sujetForum.id }}"/>
  45.                                     {% if  app.user != null %}
  46.                                         <button type="submit" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  47.                                     {% endif %}
  48.                                     {% if  app.user == null %}
  49.                                         <a href="/login">
  50.                                             <button type="button" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  51.                                         </a>
  52.                                     {% endif %}
  53.                                 </form>
  54.                             </div>
  55.                         </div>
  56.                         <div class="row justify-content-center pb-5" id="ReponseSujet">
  57.                             <div class="row justify-content-center pb-5" style="">
  58.                                 <div class="accordion-content">
  59.                                     {% for reponse in reponsesForums %}
  60.                                         <div
  61.                                             class="accordion-item" id="accordion-item">
  62.                                             {% if app.user != null and reponse.user.id == app.user.id and reponse.etat == false %}
  63.                                                 <header class="item-header answer">
  64.                                                     <h4 id="item-quest-user" class="item-question answer">{{ reponse.user }}</h4>
  65.                                                     <h4 id="item-quest-date" class="item-question">
  66.                                                        {{ app.request.locale == 'ar_TN' ? reponse.date | date('Y/m/d') : reponse.date | date('d/m/Y') }} </p></span></h4>
  67.                                                     <form class="" method="post" action="{{ path('update_forum_response', { id: reponse.id }) }}" id="form-reponse">
  68.                                                         <input type="hidden" name="_token" value="{{ csrf_token('forum') }}">
  69.                                                         <div class="input-group {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  70.                                                             <textarea name="message" class="form-control form-control-lg " aria-lab-el="With textarea" required>{{ reponse.reponse }}</textarea>
  71.                                                         </div>
  72.                                                         <button type="submit" class="btn-slider-text modif">
  73.                                                             <i id="update-commentaire" class="fa-solid fa-pen-to-square"></i>
  74.                                                         </button>
  75.                                                         <a class="col-md-10" style="margin:10px;">
  76.                                                             <i id="drop-commentaire" onclick="supprimerReponse({{ reponse.id }})" class="fa-sharp fa-solid fa-trash"></i>
  77.                                                         </a>
  78.                                                     </form>
  79.                                                 </header>
  80.                                             {% else %}
  81.                                                 <header class=" item-header container">
  82.                                                     <div class="row {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  83.                                                         <div class="col-md-2">
  84.                                                             <h4 id="item-quest-user" class="item-question">{{ reponse.user }}</h4>
  85.                                                             <div class="col-md-2">
  86.                                                                 <h4 id="item-quest-date" class="item-question">
  87.                                                              {{ app.request.locale == 'ar_TN' ? reponse.date | date('Y/m/d') : reponse.date | date('d/m/Y') }} </p></span></h4></h4>
  88.                                                             </div>
  89.                                                         </div>
  90.                                                         <div class="col-md-12 description">
  91.                                                             {{ reponse.reponse }}
  92.                                                         </div>
  93.                                                     </div>
  94.                                                 </header>
  95.                                             {% endif %}
  96.                                         </div>
  97.                                         <form method="post" action="{{ path('make_forum_comment', { id: sujetForum.id, repid: reponse.id }) }}" id="reponse-form">
  98.                                             <input type="hidden" name="_token" value="{{ csrf_token('forum') }}">
  99.                                             <div class="input-group ">
  100.                                                 <div class="{{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}" style="width:100%">
  101.                                                 <div
  102.                                                     class="input-group">
  103.                                                     <textarea name="message" class="form-control" aria-label="With textarea" placeholder="{{ 'Commenter_la_réponse'|trans }}"></textarea>
  104.                                                 </div>
  105.                                                 <input
  106.                                                 type="hidden" value="{{ sujetForum.id }}"/>
  107.                                                 {% if  app.user != null %}
  108.                                                     <button type="submit" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  109.                                                 {% endif %}
  110.                                                 {% if  app.user == null %}
  111.                                                     <a href="/login">
  112.                                                         <button type="button" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  113.                                                     </a>
  114.                                                 {% endif %}
  115.                                                 </div>
  116.                                         </form>
  117.                                             {% for child in reponse.children %}
  118.                                                 {% if app.user != null and child.user.id == app.user.id and child.etat == false %}
  119.                                                     <div class="accordion-content mx-5">
  120.                                                         <div class="accordion-item">
  121.                                                             <header class="item-header" id="Rps-child">
  122.                                                                 <h4 id="item-quest-user" class="item-question">{{ child.user }}
  123.                                                                 </h4>
  124.                                                                 <h4 id="item-quest-date" class="item-question">
  125.                                                                    {{ app.request.locale == 'ar_TN' ? child.date | date('Y/m/d') : child.date | date('d/m/Y') }} </p></span></h4>
  126. </h4>
  127.                                                                 <form method="post" action="{{ path('update_forum_response', { id: child.id }) }}" style="margin-right: 30px">
  128.                                                                     <input type="hidden" name="_token" value="{{ csrf_token('forum') }}">
  129.                                                                     <div class="input-group {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  130.                                                                         <textarea name="message" class="form-control col-md-4" aria-label="With textarea" required>{{ child.reponse }}</textarea>
  131.                                                                     </div>
  132.                                                                     <button type="submit" class="btn-slider-text modif">
  133.                                                                         <i id="update-commentaire" class="fa-solid fa-pen-to-square"></i>
  134.                                                                     </button>
  135.                                                                     <i id="drop-commentaire" onclick="supprimerReponse({{ child.id }})" class="fa-sharp fa-solid fa-trash"></i>
  136.                                                                 </form>
  137.                                                             </header>
  138.                                                         </div>
  139.                                                     </div>
  140.                                                 {% elseif child.etat != false %}
  141.                                                     <div class="accordion-content mx-5" id="Rps-child">
  142.                                                         <div class="accordion-item">
  143.                                                             <header class=" item-header container">
  144.                                                                 <div class="row {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  145.                                                                     <div class="col-md-2">
  146.                                                                         <h4 id="item-quest-user" class="item-question">{{ child.user }}</h4>
  147.                                                                         <div class="col-md-2">
  148.                                                                             <h4 id="item-quest-date" class="item-question">
  149.                                                                                {{ app.request.locale == 'ar_TN' ? child.date | date('Y/m/d') : child.date | date('d/m/Y') }} </p></span></h4></h4>
  150.                                                                         </div>
  151.                                                                     </div>
  152.                                                                     <div class="col-md-12 description">
  153.                                                                         {{ child.reponse }}
  154.                                                                     </div>
  155.                                                                 </div>
  156.                                                             </header>
  157.                                                         </div>
  158.                                                     </div>
  159.                                                 {% endif %}
  160.                                             {% endfor %}
  161.                                         {% endfor %}
  162.                                     </div>
  163.                                 </div>
  164.                             </div>
  165.                             <div class="container showMore">
  166.                                 <div class="row justify-content-center">
  167.                                     <div class="col-md-12">
  168.                                         <div class="row justify-content-center pb-5">
  169.                                             <a>
  170.                                                 <input type="hidden" value="{{ sujetForum.id }}" id="idSujetForum">
  171.                                                     <button class="btn-slider-text mt-5" id="addMore">
  172.                                                         {% trans %} forum.details.show {% endtrans %}</button>
  173.                                                 </a>
  174.                                             </div>
  175.                                         </div>
  176.                                     </div>
  177.                                 </div>
  178.                             </div>
  179.                         </div>
  180.                     </div>
  181.                     <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  182.                     <script>
  183.                        var csrfForumToken = '{{ csrf_token('forum') }}';
  184.                        function supprimerReponse(a) {
  185.                         console.log('supprimer')
  186.                             event.preventDefault();
  187.                             Swal.fire({
  188.                                 title: 'Êtes-vous sûr?',
  189.                                 text: 'Vous ne pourrez pas revenir en arrière !',
  190.                                 icon: 'warning',
  191.                                 showCancelButton: true,
  192.                                 confirmButtonColor: '#3085d6',
  193.                                 cancelButtonColor: '#d33',
  194.                                 confirmButtonText: 'Oui, supprimez-le!'
  195.                             }).then((result) => {
  196.                                 if (result.isConfirmed) {
  197.                                     $.ajax({
  198.                                         type: 'POST',
  199.                                         url: '/delete/forum/reponse/' + a,
  200.                                         data: { _token: csrfForumToken },
  201.                                         // data: JSON.stringify(item),
  202.                                         dataType: 'json',
  203.                                         success: function (response) {
  204.                                             console.log(response)
  205.                                             location.reload()
  206.                                         }
  207.                                     })
  208.                                     // window.location.href = "/make/command/delete/"+a;
  209.                                 }
  210.                             })
  211.                         }
  212.                         // Get the modal
  213.                         var modal = document.getElementById('myModal')
  214.                         // Get the image and insert it inside the modal - use its "alt" text as a caption
  215.                         var img = document.getElementById('dream-img')
  216.                         {# var modalImg = document.getElementById('img01') {
  217.                             
  218.                             var pathImg = document.getElementById('path-img').value
  219.                             function showImg(img) {
  220.                                 var img = pathImg + img
  221.                                 modalImg.style.backgroundImage = 'url(' + img + ')'
  222.                                 modal.style.display = 'block'
  223.                             }
  224.                             
  225.                         } #}
  226.                         // Get the <span> element that closes the modal
  227.                         var span = document.getElementsByClassName('close')[0]
  228.                         // When the user clicks on <span> (x), close the modal
  229.                         $(document).ready(function () {});
  230.                         let offset = 1;
  231.                         $('#addMore').on('click', function () {
  232.                             console.log(offset)
  233.                             sujetForumId = $('#idSujetForum').val()
  234.                             var url = '/ajax/get/ReponseForum/' + sujetForumId;
  235.                             console.log('/ajax/get/ReponseForum/' + sujetForumId)
  236.                             console.log("offset " + offset)
  237.                             div = ` test one div`
  238.                             $(div).insertBefore(".showMore");
  239.                             $.ajax({
  240.                                 type: "GET",
  241.                                 url: url,
  242.                                 data: {
  243.                                     'offset': offset
  244.                                 },
  245.                                 success: function (response) {
  246.                                     console.log(JSON.stringify(response))
  247.                                     div = ``
  248.                                     $(div).insertBefore(".showMore");
  249.                                     response.result.map((value, index) => {
  250.                                         forumDate = value.date
  251.                                         console.log(forumDate)
  252.                                         console.log(typeof(forumDate))
  253.                                         div = `<div class="accordion-item" id="accordion-item">`
  254.                                         $(div).insertBefore(".showMore")
  255.                                         appUser = "{{ app.user }}"
  256.                                         if (appUser != null && value.etat === false) {
  257.                                             div = `
  258.               <div class="row justify-content-center pb-5" id="ReponseSujet">
  259.                 <div class="row justify-content-center pb-5" style="">
  260.                 <div class="accordion-content">
  261.       
  262.                  <div class="accordion-item" id="accordion-item">
  263.                  <header class="item-header answer">
  264.                     <h4 id="item-quest-user" class="item-question answer">${escapeHtml(value.userName)}</h4>
  265.                     <h4 id="item-quest-date" class="item-question"> 
  266.                     {% if  app.request.locale == 'ar_TN' %}
  267.                     ${forumDate.split('/').reverse().join('/')} 
  268.                     {% else %} 
  269.                     ${forumDate} 
  270.                     {% endif %}
  271.                     </h4>
  272.                     <form method="post" action="/update/forum/response/${
  273.                                                 value.id
  274.                                             }" id="form-reponse">
  275.                       <input type="hidden" name="_token" value="${csrfForumToken}">
  276.                       <div class="input-group {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  277.                         <textarea name="message" class="form-control form-control-lg " aria-label="With textarea" required>${escapeHtml(value.reponse)}</textarea>
  278.                       </div>
  279.                       <button type="submit" class="btn-slider-text modif"> <i id="update-commentaire" class="fa-solid fa-pen-to-square"></i> 
  280.                       </button>
  281.                       <a class="col-md-10" style="0:10px;">
  282.                       <i id="drop-commentaire"   onclick="supprimerReponse(${value.id})" class="fa-sharp fa-solid fa-trash"></i>
  283.                       </a>
  284.                     </form>
  285.                     </header>
  286.                     </div>
  287.                     </div>
  288.              
  289.                     `;
  290.                                             $(div).insertBefore(".showMore");
  291.                                         } else {
  292.                                             div = `
  293.               
  294.                 <div class="row justify-content-center pb-5" id="ReponseSujet">
  295.       <div class="row justify-content-center pb-5" style="">
  296.         <div class="accordion-content">
  297.       
  298.             <div class="accordion-item" id="accordion-item">
  299.             
  300.         
  301.                 <header class="item-header {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  302.                   <h4 id="item-quest-user" class="item-question">${escapeHtml(value.userName)}</h4>
  303.                   <h4 id="item-quest-date" class="item-question"> 
  304.                   {% if  app.request.locale == 'ar_TN' %}
  305.                     ${forumDate.split('/').reverse().join('/')} 
  306.                     {% else %} 
  307.                     ${forumDate} 
  308.                     {% endif %}
  309.                   </h4>
  310.                  ${escapeHtml(value.reponse)}  
  311.                 </header>
  312.             
  313.             </div>
  314.                    
  315.             <form method="post" action="/make/forum/comment/${sujetForumId}/${
  316.                                                 value.id
  317.                                             }"  id="reponse-form">
  318.               <input type="hidden" name="_token" value="${csrfForumToken}">
  319.               <div class="input-group">
  320.                 <div class="input-group {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}" >
  321.                   <textarea name="message" class="form-control" aria-label="With textarea" placeholder="{{ 'Commenter_la_réponse'|trans }}"></textarea>
  322.                 </div>
  323.                 <input type="hidden" value="${sujetForumId}" />
  324.                      <div class="{{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}" style="width:100%;">     {% if  app.user != null %}
  325.           <button type="submit" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  326.         {% endif %}
  327.           {% if  app.user == null %}
  328.           <a href="/login"><button type="button" class="btn-slider-text-forum-dtls">{% trans %} forum.details.send {% endtrans %}</button>
  329.        </a>
  330.        </div>
  331.         {% endif %}
  332.                 </div>
  333.               </form>
  334.             </div>
  335.             </div>
  336.             </div>
  337.                     `;
  338.                                             $(div).insertBefore(".showMore");
  339.                                         }
  340.                                         value.childs.forEach(child => {
  341.                                             console.log("childs " + child)
  342.                                             var forumDate = child.date // Assurez-vous de remplacer cela par la valeur réelle en JavaScript
  343.                                             var date = new Date(forumDate);
  344.                                             var formattedDate = (date.getDate() < 10 ? '0' : '') + date.getDate() + '/' + (
  345.                                             (date.getMonth() + 1) < 10 ? '0' : ''
  346.                                         ) + (date.getMonth() + 1) + '/' + date.getFullYear();
  347.                                             if (appUser && child.userName == appUser && child.etat == false) {
  348.                                                 div = `       
  349.                   <div class="row justify-content-center pb-5" id="ReponseSujet">
  350.       <div class="row justify-content-center pb-5" style="">
  351.         <div class="accordion-content">
  352.                 <div class="accordion-content mx-5">
  353.                   <div class="accordion-item">
  354.                     <header class="item-header" id="Rps-child">
  355.                      <h4 id="item-quest-user" class="item-question">${escapeHtml(child.userName)} </h4>
  356.                      <h4  id="item-quest-date" class="item-question"> 
  357.                       {% if  app.request.locale == 'ar_TN' %}
  358.                     ${child.date.split('/').reverse().join('/')} 
  359.                     {% else %} 
  360.                     ${child.date} 
  361.                     {% endif %}
  362.                     </h4> 
  363.                       <form method="post" action="/update/forum/response/${
  364.                                                     child.id
  365.                                                 }" style="margin-right: 30px">
  366.                         <input type="hidden" name="_token" value="${csrfForumToken}">
  367.                         <div class="input-group {{ app.request.locale == 'ar_TN' ? 'form_direction_rtl' : 'form_direction_ltr' }}">
  368.                           <textarea name="message" class="form-control col-md-4" aria-label="With textarea" required> ${escapeHtml(child.reponse)}</textarea>
  369.                         </div>
  370.                          <button type="submit" class="btn-slider-text modif"> <i id="update-commentaire" class="fa-solid fa-pen-to-square"></i>  </button>
  371.                          <i id="drop-commentaire"   onclick="supprimerReponse(${
  372.                                                     child.id
  373.                                                 })" class="fa-sharp fa-solid fa-trash"></i>
  374.                       </form>
  375.                     </header>
  376.                   </div>
  377.                 </div>
  378.                 </div>
  379.                 </div>
  380.                 `
  381.                                                 $(div).insertBefore(".showMore");
  382.                                             }
  383.                                         });
  384.                                         offset = offset + 1;
  385.                                     });
  386.                                 }
  387.                             });
  388.                         });
  389.                     </script>
  390.                 {% endblock %}