templates/planning/liste_bo.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Pilotage exploitation BO{% endblock %}
  3. {% block body %}
  4.     {#<div id="calendarMenu" style="padding-top: 20px;display: flex;align-items: center;">#}
  5.     {#<button type="button" class="calendar-btn calendar-move-today"  onclick="calendar.today();setRenderRangeText()">Aujourd'hui</button>#}
  6.     {#<button type="button" class="calendar-btn calendar-move-day" onclick="calendar.prev();setRenderRangeText()">#}
  7.     {#< </button>#}
  8.     {#<button type="button" class="calendar-btn calendar-move-day" onclick="calendar.next();setRenderRangeText()">#}
  9.     {#> </button>#}
  10.     {#<div id="renderRange" style="font-size:18px"></div>#}
  11.     {#</div>#}
  12.     <ol class="breadcrumb">
  13.         <li>
  14.             <i class="clip-grid-6"></i>
  15.             <a href="#">
  16.                 RDV
  17.             </a>
  18.         </li>
  19.         <li class="active">
  20.             Liste
  21.         </li>
  22.     </ol>
  23.     {#<div id="calendar" style="height: 800px;"></div>#}
  24.     <div class="page-header">
  25.         <h1>BO : Liste des dates d'ouvertures des salons</h1>
  26.         <div>
  27.             <form id="filter-form" method="GET">
  28.                 <div class="row">
  29.                     <div class="col-lg-3">
  30.                         <select id="filter-salon" name="salon" style="width:300px;" class="form-control">
  31.                             <option value>Sélectionnez un salon</option>
  32.                             {% for salon in salons %}
  33.                                 <option value="{{ salon.id }}" {% if app.request.get('salon') == salon.id %} selected{% endif %}>{{ salon.name }}</option>
  34.                             {% endfor %}
  35.                         </select>
  36.                     </div>
  37.                     <div class="col-lg-3">
  38.                         <select id="filter-intervenant" name="intervenant" style="width:300px;" class="form-control">
  39.                             <option value>Sélectionnez un intervenant</option>
  40.                             {% for intervenant in intervenants %}
  41.                                 <option value="{{ intervenant.id }}" {% if app.request.get('intervenant') == intervenant.id %} selected{% endif %}>{{ intervenant.firstname }} {{ intervenant.lastname }}</option>
  42.                             {% endfor %}
  43.                         </select>
  44.                     </div>
  45.                     {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
  46.                         <div class="col-lg-3">
  47.                             <input id="date_debut" placeholder="Date de début" type="text" name="date_debut" class="form-control flatpickr-input active" value="{{ dateDebut}}">
  48.                         </div>
  49.                         <div class="col-lg-3">
  50.                             <input id="date_fin" placeholder="Date de fin"  type="text" name="date_fin" class="form-control flatpickr-input active" value="{{ dateFin}}">
  51.                         </div>
  52.                     {% endif %}
  53.                 </div>
  54.                 <div style="margin-top: 20px">
  55.                     <button class="btn btn-success" type="submit">Valider</button>
  56.                 </div>
  57.             </form>
  58.             <div style="margin-top: 20px;display: flex">
  59.                 {#                {% if not is_granted('ROLE_COIFFEUR') or is_granted('ROLE_TELECONSEILER') %}#}
  60.                 {#                <form action="{{ path('app_planning_envoiplanning') }}">#}
  61.                 {#                    <button id="sendPlanning" class="btn btn-success" type="submit">Envoi planning</button>#}
  62.                 {#                </form>#}
  63.                 {#                {% endif %}#}
  64.                 {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
  65.                     <div style="margin-left: 20px">
  66.                         <a href="{{path('app_planning_newjos')}}"  class="btn btn-success">Nouveau</a>
  67.                     </div>
  68.                 {% endif %}
  69.             </div>
  70.         </div>
  71.     </div>
  72.     <div class="row">
  73.         <div class="col-md-12">
  74.             <!-- start: BASIC TABLE PANEL -->
  75.             <div class="panel panel-default">
  76.                 <div class="panel-heading">
  77.                     RDV
  78.                     <div class="panel-tools">
  79.                     </div>
  80.                 </div>
  81.                 <div class="panel-body">
  82.                     <table class="table table-hover" id="table">
  83.                         <thead>
  84.                         <tr>
  85.                             <th><input class="selectAllSession" type="checkbox" /></th>
  86.                             <th>Id</th>
  87.                             <th>Date</th>
  88.                             <th>Heure</th>
  89.                             <th>Salon</th>
  90.                             <th>Action à réaliser</th>
  91.                             <th>Intervenant</th>
  92.                             <th>Statut</th>
  93.                             <th>CA HT</th>
  94.                             <th>Nbre de RDV</th>
  95.                         </tr>
  96.                         </thead>
  97.                         <tbody>
  98.                         {% set dayNames = ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'] %}
  99.                         {% set monthNames = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'] %}
  100.                         {% for session in sessions %}
  101.                             <tr>
  102.                                 <td><input class="sessionCheck" type="checkbox" data-ht="{{ session.rdvCA  }}" data-nbrdv="{{ session.rdvCount }}"/></td>
  103.                                 <td>{{ session.id }}</td>
  104.                                 <td>{{ dayNames[session.start|date('w')] }} {{ session.start|date('j') }} {{ monthNames[session.start|date('n')-1] }} {{ session.start|date('Y') }} </td>
  105.                                 <td>{{ session.startRDV|date('H:i') }} - {{ session.end|date('H:i') }}</td>
  106.                                 <td>{{ session.salon }}</td>
  107.                                 <td>
  108.                                     {% if session.actionArealiser and session.observation %}
  109.                                         🚩❶
  110.                                     {% elseif session.actionArealiser %}
  111.                                         🚩
  112.                                     {% elseif session.observation %}
  113.                                         ❶
  114.                                     {% else %}
  115.                                         ---
  116.                                     {% endif %}
  117.                                 </td>
  118.                                 <td>{{ session.intervenant }}</td>
  119.                                 <td>
  120.                                     {% if session.status == 'plan' %} Salon Ouvert
  121.                                     {% elseif session.status == 'modifier' %} Salon Modifié
  122.                                     {% elseif session.status == 'indisponible' %} Salon Fermé
  123.                                     {% elseif session.status == 'event' %} Intervention évènementiel
  124.                                     {% endif %}
  125.                                 </td>
  126.                                 <td data-sort="{{ session.rdvCA }}" style="text-align: right">
  127.                                     {{ session.rdvCA }} €
  128.                                 </td>
  129.                                 <td data-sort="{{ session.rdvCount }}" style="text-align: right">
  130.                                     {{ session.rdvCount }}
  131.                                 </td>
  132.                                 <td>
  133.                                     {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
  134.                                         <a href="{{ path('app_planning_sessionsalon', {'id': session.id}) }}" target="_blank">Edition</a>
  135.                                     {% endif %}
  136.                                 </td>
  137.                             </tr>
  138.                         {% else %}
  139.                             <tr>
  140.                                 <td colspan="4">Aucun enregistrement trouvé</td>
  141.                             </tr>
  142.                         {% endfor %}
  143.                         </tbody>
  144.                         <tfoot>
  145.                         <tr>
  146.                             <td colspan="8" style="text-align: right;"><strong>Total CA HT:</strong></td>
  147.                             <td id="total-ca-ht" style="text-align: right">0</td>
  148.                             <td id="nbSession" style="text-align: right">0</td>
  149.                             <td colspan="2"></td>
  150.                         </tr>
  151.                         </tfoot>
  152.                     </table>
  153.                 </div>
  154.             </div>
  155.             <!-- end: BASIC TABLE PANEL -->
  156.         </div>
  157.     </div>
  158. {% endblock %}
  159. {% block javascripts %}
  160.     {{ parent() }}
  161.     <script type="text/javascript">
  162.         function calculateTotalCA() {
  163.             let total = 0;
  164.             let totalSession= 0;
  165.             document.querySelectorAll('.sessionCheck:checked').forEach(function(checkbox) {
  166.                 total += parseFloat(checkbox.getAttribute('data-ht')) || 0;
  167.                 totalSession+= parseFloat(checkbox.getAttribute('data-nbrdv')) || 0;
  168.             });
  169.             document.getElementById('total-ca-ht').textContent = total.toFixed(2)  + " €";
  170.             document.getElementById('nbSession').textContent = totalSession;
  171.         }
  172.         document.querySelector('.selectAllSession').addEventListener('change', function() {
  173.             const isChecked = this.checked;
  174.             document.querySelectorAll('.sessionCheck').forEach(function(checkbox) {
  175.                 checkbox.checked = isChecked;
  176.             });
  177.             calculateTotalCA();
  178.         });
  179.         document.addEventListener('DOMContentLoaded', function() {
  180.             // Calculate the total CA HT on page load
  181.             calculateTotalCA();
  182.             // Add event listener to each checkbox
  183.             document.querySelectorAll('.sessionCheck').forEach(function(checkbox) {
  184.                 checkbox.addEventListener('change', function() {
  185.                     calculateTotalCA();
  186.                 });
  187.             });
  188.         });
  189.         $('#filter-salon').on('change', function () {
  190.             $('#filter-form').submit();
  191.         });
  192.         $('#filter-intervenant').on('change', function () {
  193.             $('#filter-form').submit();
  194.         });
  195.     </script>
  196.     <script type="text/javascript">
  197.         {#function setRenderRangeText() {#}
  198.         {#var renderRange = document.getElementById('renderRange');#}
  199.         {#var options = calendar.getOptions();#}
  200.         {#var viewName = calendar.getViewName();#}
  201.         {#var html = [];#}
  202.         {#if (viewName === 'day') {#}
  203.         {#html.push(moment(calendar.getDate().getTime()).format('YYYY.MM.DD'));#}
  204.         {#} else if (viewName === 'month' &&#}
  205.         {#(!options.month.visibleWeeksCount || options.month.visibleWeeksCount > 4)) {#}
  206.         {#html.push(moment(calendar.getDate().getTime()).format('YYYY.MM'));#}
  207.         {#} else {#}
  208.         {#html.push(moment(calendar.getDateRangeStart().getTime()).format('DD/MM/YYYY'));#}
  209.         {#html.push(' ~ ');#}
  210.         {#html.push(moment(calendar.getDateRangeEnd().getTime()).format('DD/MM/YYYY'));#}
  211.         {#}#}
  212.         {#renderRange.innerHTML = html.join('');#}
  213.         {#}#}
  214.         {#var calendar = new Calendar('#calendar', {#}
  215.         {#defaultView: 'week',#}
  216.         {#taskView: ['milestone'],#}
  217.         {#scheduleView: [ 'allday'],#}
  218.         {#lang: "fr",#}
  219.         {#locale:"fr",#}
  220.         {#useCreationPopup: false,#}
  221.         {#useDetailPopup: true,#}
  222.         {#template: {#}
  223.         {#monthGridHeader: function(model) {#}
  224.         {#var date = new Date(model.date);#}
  225.         {#var template = '<span class="tui-full-calendar-weekday-grid-date">' + date.getDate() + '</span>';#}
  226.         {#return template;#}
  227.         {#},#}
  228.         {#alldayTitle: function() {#}
  229.         {#return 'Jour entier';#}
  230.         {#},#}
  231.         {#popupDelete: function() {#}
  232.         {#return 'Suppresion';#}
  233.         {#},#}
  234.         {#popupEdit: function() {#}
  235.         {#return 'Edition';#}
  236.         {#},#}
  237.         {#milestoneTitle: function () {#}
  238.         {#return 'Intervenants';#}
  239.         {#}#}
  240.         {#},#}
  241.         {#week: {#}
  242.         {#daynames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],#}
  243.         {#startDayOfWeek: 1,#}
  244.         {#narrowWeekend: true#}
  245.         {#},#}
  246.         {#});#}
  247.         {#setRenderRangeText();#}
  248.         {#/**#}
  249.         {#*#}
  250.         {#*/#}
  251.         {#calendar.on('beforeCreateSchedule', function(event) {#}
  252.         {#var startTime = event.start;#}
  253.         {#var endTime = event.end;#}
  254.         {#var isAllDay = event.isAllDay;#}
  255.         {#var guide = event.guide;#}
  256.         {#var triggerEventName = event.triggerEventName;#}
  257.         {#var schedule ;#}
  258.         {#//console.log(startTime.toUTCString());#}
  259.         {#$('#rdv_start').val(startTime.toUTCString());#}
  260.         {#$('#rdv_end').val(endTime.toUTCString());#}
  261.         {#$('#rdv').modal({});#}
  262.         {#$('#rdv_client').select2();#}
  263.         {#console.log(triggerEventName);#}
  264.         {#// if (triggerEventName === 'click') {#}
  265.         {#//     // open writing simple schedule popup#}
  266.         {#//     console.log('cliik');#}
  267.         {#//     $('#rdv').modal(options);#}
  268.         {#//#}
  269.         {#// } else if (triggerEventName === 'dblclick') {#}
  270.         {#//     // open writing detail schedule popup#}
  271.         {#//     console.log('dblclick');#}
  272.         {#// }#}
  273.         {#});#}
  274.         {#calendar.on('clickSchedule', function(event) {#}
  275.         {#console.log(event);#}
  276.         {#});#}
  277.         {#calendar.on('beforeUpdateSchedule', function(event) {#}
  278.         {#console.log('in');#}
  279.         {#var schedule = event.schedule;#}
  280.         {#var url = '{{ path("app_planning_edit", {'id': 'schedule_id'}) }}';#}
  281.         {#url = url.replace("schedule_id", event.schedule.id);#}
  282.         {#window.location.href = url;#}
  283.         {#});#}
  284.         {#const rdvs = JSON.parse('{{ sessionsSalons|raw }}');#}
  285.         {#console.log('RDV', rdvs);#}
  286.         {#if(rdvs.length > 0) {#}
  287.         {#for(var i = 0;i < rdvs.length;i++) {#}
  288.         {#//console.log(rdvs[i]);#}
  289.         {#calendar.createSchedules([#}
  290.         {#{#}
  291.         {#id: rdvs[i].id,#}
  292.         {#calendarId: rdvs[i].id,#}
  293.         {#title: rdvs[i].salon ? rdvs[i].salon.name.toUpperCase() : null,#}
  294.         {#category: 'time',#}
  295.         {#dueDateClass: '',#}
  296.         {#start: rdvs[i].start,#}
  297.         {#end: rdvs[i].start,#}
  298.         {#// attendees: [#}
  299.         {#//     // rdvs[i].client ? 'Client: ' +  rdvs[i].client.lastname.toUpperCase() : null,#}
  300.         {#//     rdvs[i].intervenant ? 'Intervenant: ' +  rdvs[i].intervenant.lastname.toUpperCase() : null,#}
  301.         {#// ],#}
  302.         {#isAllDay: true#}
  303.         {#}#}
  304.         {#]);#}
  305.         {#}#}
  306.         {#}#}
  307.         {#$('#form_add_rdv').on('submit', function (e) {#}
  308.         {#e.preventDefault();#}
  309.         {#const path = "{{ path('app_planning_addrdvajax') }}";#}
  310.         {#$.ajax({#}
  311.         {#url: path,#}
  312.         {#data: $(this).serialize(),#}
  313.         {#type: 'post',#}
  314.         {#success: function(data) {#}
  315.         {#console.log(data);#}
  316.         {#console.log(data.start);#}
  317.         {#console.log( new Date( data.start).toISOString());#}
  318.         {#$('#rdv').modal('hide');#}
  319.         {#calendar.createSchedules([{#}
  320.         {#id: data.id,#}
  321.         {#calendarId: data.id,#}
  322.         {#title: data.client ? data.client.lastname.toUpperCase() : null,#}
  323.         {#category: 'time',#}
  324.         {#dueDateClass: '',#}
  325.         {#start: new Date( data.start).toISOString(),#}
  326.         {#end:  new Date( data.end).toISOString()#}
  327.         {#}]);#}
  328.         {#}#}
  329.         {#});#}
  330.         {#});#}
  331.         {#/**#}
  332.         {#* Filter#}
  333.         {#*/#}
  334.         {#$('.filter').on('change', function (e) {#}
  335.         {#e.preventDefault();#}
  336.         {#const type = $(this).data('type');#}
  337.         {#const val = $(this).val();#}
  338.         {#console.log('value selected', val);#}
  339.         {#let path = null;#}
  340.         {#if(type === 'company') {#}
  341.         {#console.log('type',type);#}
  342.         {#$('.select-intervenant').val(null).trigger('change.select2');#}
  343.         {#$('.select-site').val(null).trigger('change.select2');#}
  344.         {#path = "{{ path('app_planning_ajaxfilter', {#}
  345.         {#'company' : 'company_id',#}
  346.         {#}) }}";#}
  347.         {#path = path.replace("company_id", val);#}
  348.         {#}#}
  349.         {#if(type === 'intervenant') {#}
  350.         {#console.log('type',type);#}
  351.         {#$('.select-company').val(null).trigger('change.select2');#}
  352.         {#$('.select-site').val(null).trigger('change.select2');#}
  353.         {#path = "{{ path('app_planning_ajaxfilter', {#}
  354.         {#'intervenant' : 'intervenant_id',#}
  355.         {#}) }}";#}
  356.         {#path = path.replace("intervenant_id", val);#}
  357.         {#}#}
  358.         {#if(type === 'site') {#}
  359.         {#console.log('type',type);#}
  360.         {#$('.select-intervenant').val(null).trigger('change.select2');#}
  361.         {#$('.select-company').val(null).trigger('change.select2');#}
  362.         {#path = "{{ path('app_planning_ajaxfilter', {#}
  363.         {#'site' : 'site_id'#}
  364.         {#}) }}";#}
  365.         {#path = path.replace("site_id", val);#}
  366.         {#}#}
  367.         {#console.log(path);#}
  368.         {#if(path && val) {#}
  369.         {#$.ajax({#}
  370.         {#url: path,#}
  371.         {#type: 'get',#}
  372.         {#success: function(data) {#}
  373.         {#calendar.clear();#}
  374.         {#if(data.length >  0) {#}
  375.         {#for(var i = 0;i < data.length; i++) {#}
  376.         {#calendar.createSchedules([{#}
  377.         {#id: data[i].id,#}
  378.         {#calendarId: data[i].id,#}
  379.         {#title: data[i].client ? data[i].client.lastname.toUpperCase() : null,#}
  380.         {#category: 'time',#}
  381.         {#dueDateClass: '',#}
  382.         {#start: new Date( data[i].start).toISOString(),#}
  383.         {#end:  new Date( data[i].end).toISOString(),#}
  384.         {#isAllDay: true#}
  385.         {#}]);#}
  386.         {#}#}
  387.         {#}#}
  388.         {#}#}
  389.         {#});#}
  390.         {#}#}
  391.         {#else {#}
  392.         {#$.ajax({#}
  393.         {#url: "{{ path('app_planning_ajaxfilter') }}",#}
  394.         {#type: 'get',#}
  395.         {#success: function(data) {#}
  396.         {#calendar.clear();#}
  397.         {#if(data.length >  0) {#}
  398.         {#for(var i = 0;i < data.length; i++) {#}
  399.         {#calendar.createSchedules([{#}
  400.         {#id: data[i].id,#}
  401.         {#calendarId: data[i].id,#}
  402.         {#title: data[i].client ? data[i].client.lastname.toUpperCase() : null,#}
  403.         {#category: 'time',#}
  404.         {#dueDateClass: '',#}
  405.         {#start: new Date( data[i].start).toISOString(),#}
  406.         {#end:  new Date( data[i].end).toISOString(),#}
  407.         {#isAllDay: true#}
  408.         {#}]);#}
  409.         {#}#}
  410.         {#}#}
  411.         {#}#}
  412.         {#});#}
  413.         {#}#}
  414.         {#});#}
  415.         $('#date_debut').flatpickr({
  416.             'dateFormat' : 'Y-m-d',
  417.             "locale": "fr",
  418.         });
  419.         $('#date_fin').flatpickr({
  420.             'dateFormat' : 'Y-m-d',
  421.             "locale": "fr"
  422.         });
  423.         new Tablesort(document.getElementById('table'));
  424.         $('#filter-salon').select2({ width: '100%' });
  425.         $('#filter-intervenant').select2({ width: '100%' });
  426.     </script>
  427. {% endblock %}