{% extends 'base.html.twig' %}
{% block title %}Pilotage exploitation BO{% endblock %}
{% block body %}
{#<div id="calendarMenu" style="padding-top: 20px;display: flex;align-items: center;">#}
{#<button type="button" class="calendar-btn calendar-move-today" onclick="calendar.today();setRenderRangeText()">Aujourd'hui</button>#}
{#<button type="button" class="calendar-btn calendar-move-day" onclick="calendar.prev();setRenderRangeText()">#}
{#< </button>#}
{#<button type="button" class="calendar-btn calendar-move-day" onclick="calendar.next();setRenderRangeText()">#}
{#> </button>#}
{#<div id="renderRange" style="font-size:18px"></div>#}
{#</div>#}
<ol class="breadcrumb">
<li>
<i class="clip-grid-6"></i>
<a href="#">
RDV
</a>
</li>
<li class="active">
Liste
</li>
</ol>
{#<div id="calendar" style="height: 800px;"></div>#}
<div class="page-header">
<h1>BO : Liste des dates d'ouvertures des salons</h1>
<div>
<form id="filter-form" method="GET">
<div class="row">
<div class="col-lg-3">
<select id="filter-salon" name="salon" style="width:300px;" class="form-control">
<option value>Sélectionnez un salon</option>
{% for salon in salons %}
<option value="{{ salon.id }}" {% if app.request.get('salon') == salon.id %} selected{% endif %}>{{ salon.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-lg-3">
<select id="filter-intervenant" name="intervenant" style="width:300px;" class="form-control">
<option value>Sélectionnez un intervenant</option>
{% for intervenant in intervenants %}
<option value="{{ intervenant.id }}" {% if app.request.get('intervenant') == intervenant.id %} selected{% endif %}>{{ intervenant.firstname }} {{ intervenant.lastname }}</option>
{% endfor %}
</select>
</div>
{% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
<div class="col-lg-3">
<input id="date_debut" placeholder="Date de début" type="text" name="date_debut" class="form-control flatpickr-input active" value="{{ dateDebut}}">
</div>
<div class="col-lg-3">
<input id="date_fin" placeholder="Date de fin" type="text" name="date_fin" class="form-control flatpickr-input active" value="{{ dateFin}}">
</div>
{% endif %}
</div>
<div style="margin-top: 20px">
<button class="btn btn-success" type="submit">Valider</button>
</div>
</form>
<div style="margin-top: 20px;display: flex">
{# {% if not is_granted('ROLE_COIFFEUR') or is_granted('ROLE_TELECONSEILER') %}#}
{# <form action="{{ path('app_planning_envoiplanning') }}">#}
{# <button id="sendPlanning" class="btn btn-success" type="submit">Envoi planning</button>#}
{# </form>#}
{# {% endif %}#}
{% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
<div style="margin-left: 20px">
<a href="{{path('app_planning_newjos')}}" class="btn btn-success">Nouveau</a>
</div>
{% endif %}
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<!-- start: BASIC TABLE PANEL -->
<div class="panel panel-default">
<div class="panel-heading">
RDV
<div class="panel-tools">
</div>
</div>
<div class="panel-body">
<table class="table table-hover" id="table">
<thead>
<tr>
<th><input class="selectAllSession" type="checkbox" /></th>
<th>Id</th>
<th>Date</th>
<th>Heure</th>
<th>Salon</th>
<th>Action à réaliser</th>
<th>Intervenant</th>
<th>Statut</th>
<th>CA HT</th>
<th>Nbre de RDV</th>
</tr>
</thead>
<tbody>
{% set dayNames = ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'] %}
{% set monthNames = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'] %}
{% for session in sessions %}
<tr>
<td><input class="sessionCheck" type="checkbox" data-ht="{{ session.rdvCA }}" data-nbrdv="{{ session.rdvCount }}"/></td>
<td>{{ session.id }}</td>
<td>{{ dayNames[session.start|date('w')] }} {{ session.start|date('j') }} {{ monthNames[session.start|date('n')-1] }} {{ session.start|date('Y') }} </td>
<td>{{ session.startRDV|date('H:i') }} - {{ session.end|date('H:i') }}</td>
<td>{{ session.salon }}</td>
<td>
{% if session.actionArealiser and session.observation %}
🚩❶
{% elseif session.actionArealiser %}
🚩
{% elseif session.observation %}
❶
{% else %}
---
{% endif %}
</td>
<td>{{ session.intervenant }}</td>
<td>
{% if session.status == 'plan' %} Salon Ouvert
{% elseif session.status == 'modifier' %} Salon Modifié
{% elseif session.status == 'indisponible' %} Salon Fermé
{% elseif session.status == 'event' %} Intervention évènementiel
{% endif %}
</td>
<td data-sort="{{ session.rdvCA }}" style="text-align: right">
{{ session.rdvCA }} €
</td>
<td data-sort="{{ session.rdvCount }}" style="text-align: right">
{{ session.rdvCount }}
</td>
<td>
{% if is_granted('ROLE_ADMIN') or is_granted('ROLE_BO') or is_granted('ROLE_ADMINISTRATIVE') %}
<a href="{{ path('app_planning_sessionsalon', {'id': session.id}) }}" target="_blank">Edition</a>
{% endif %}
</td>
</tr>
{% else %}
<tr>
<td colspan="4">Aucun enregistrement trouvé</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="8" style="text-align: right;"><strong>Total CA HT:</strong></td>
<td id="total-ca-ht" style="text-align: right">0</td>
<td id="nbSession" style="text-align: right">0</td>
<td colspan="2"></td>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- end: BASIC TABLE PANEL -->
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
function calculateTotalCA() {
let total = 0;
let totalSession= 0;
document.querySelectorAll('.sessionCheck:checked').forEach(function(checkbox) {
total += parseFloat(checkbox.getAttribute('data-ht')) || 0;
totalSession+= parseFloat(checkbox.getAttribute('data-nbrdv')) || 0;
});
document.getElementById('total-ca-ht').textContent = total.toFixed(2) + " €";
document.getElementById('nbSession').textContent = totalSession;
}
document.querySelector('.selectAllSession').addEventListener('change', function() {
const isChecked = this.checked;
document.querySelectorAll('.sessionCheck').forEach(function(checkbox) {
checkbox.checked = isChecked;
});
calculateTotalCA();
});
document.addEventListener('DOMContentLoaded', function() {
// Calculate the total CA HT on page load
calculateTotalCA();
// Add event listener to each checkbox
document.querySelectorAll('.sessionCheck').forEach(function(checkbox) {
checkbox.addEventListener('change', function() {
calculateTotalCA();
});
});
});
$('#filter-salon').on('change', function () {
$('#filter-form').submit();
});
$('#filter-intervenant').on('change', function () {
$('#filter-form').submit();
});
</script>
<script type="text/javascript">
{#function setRenderRangeText() {#}
{#var renderRange = document.getElementById('renderRange');#}
{#var options = calendar.getOptions();#}
{#var viewName = calendar.getViewName();#}
{#var html = [];#}
{#if (viewName === 'day') {#}
{#html.push(moment(calendar.getDate().getTime()).format('YYYY.MM.DD'));#}
{#} else if (viewName === 'month' &&#}
{#(!options.month.visibleWeeksCount || options.month.visibleWeeksCount > 4)) {#}
{#html.push(moment(calendar.getDate().getTime()).format('YYYY.MM'));#}
{#} else {#}
{#html.push(moment(calendar.getDateRangeStart().getTime()).format('DD/MM/YYYY'));#}
{#html.push(' ~ ');#}
{#html.push(moment(calendar.getDateRangeEnd().getTime()).format('DD/MM/YYYY'));#}
{#}#}
{#renderRange.innerHTML = html.join('');#}
{#}#}
{#var calendar = new Calendar('#calendar', {#}
{#defaultView: 'week',#}
{#taskView: ['milestone'],#}
{#scheduleView: [ 'allday'],#}
{#lang: "fr",#}
{#locale:"fr",#}
{#useCreationPopup: false,#}
{#useDetailPopup: true,#}
{#template: {#}
{#monthGridHeader: function(model) {#}
{#var date = new Date(model.date);#}
{#var template = '<span class="tui-full-calendar-weekday-grid-date">' + date.getDate() + '</span>';#}
{#return template;#}
{#},#}
{#alldayTitle: function() {#}
{#return 'Jour entier';#}
{#},#}
{#popupDelete: function() {#}
{#return 'Suppresion';#}
{#},#}
{#popupEdit: function() {#}
{#return 'Edition';#}
{#},#}
{#milestoneTitle: function () {#}
{#return 'Intervenants';#}
{#}#}
{#},#}
{#week: {#}
{#daynames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],#}
{#startDayOfWeek: 1,#}
{#narrowWeekend: true#}
{#},#}
{#});#}
{#setRenderRangeText();#}
{#/**#}
{#*#}
{#*/#}
{#calendar.on('beforeCreateSchedule', function(event) {#}
{#var startTime = event.start;#}
{#var endTime = event.end;#}
{#var isAllDay = event.isAllDay;#}
{#var guide = event.guide;#}
{#var triggerEventName = event.triggerEventName;#}
{#var schedule ;#}
{#//console.log(startTime.toUTCString());#}
{#$('#rdv_start').val(startTime.toUTCString());#}
{#$('#rdv_end').val(endTime.toUTCString());#}
{#$('#rdv').modal({});#}
{#$('#rdv_client').select2();#}
{#console.log(triggerEventName);#}
{#// if (triggerEventName === 'click') {#}
{#// // open writing simple schedule popup#}
{#// console.log('cliik');#}
{#// $('#rdv').modal(options);#}
{#//#}
{#// } else if (triggerEventName === 'dblclick') {#}
{#// // open writing detail schedule popup#}
{#// console.log('dblclick');#}
{#// }#}
{#});#}
{#calendar.on('clickSchedule', function(event) {#}
{#console.log(event);#}
{#});#}
{#calendar.on('beforeUpdateSchedule', function(event) {#}
{#console.log('in');#}
{#var schedule = event.schedule;#}
{#var url = '{{ path("app_planning_edit", {'id': 'schedule_id'}) }}';#}
{#url = url.replace("schedule_id", event.schedule.id);#}
{#window.location.href = url;#}
{#});#}
{#const rdvs = JSON.parse('{{ sessionsSalons|raw }}');#}
{#console.log('RDV', rdvs);#}
{#if(rdvs.length > 0) {#}
{#for(var i = 0;i < rdvs.length;i++) {#}
{#//console.log(rdvs[i]);#}
{#calendar.createSchedules([#}
{#{#}
{#id: rdvs[i].id,#}
{#calendarId: rdvs[i].id,#}
{#title: rdvs[i].salon ? rdvs[i].salon.name.toUpperCase() : null,#}
{#category: 'time',#}
{#dueDateClass: '',#}
{#start: rdvs[i].start,#}
{#end: rdvs[i].start,#}
{#// attendees: [#}
{#// // rdvs[i].client ? 'Client: ' + rdvs[i].client.lastname.toUpperCase() : null,#}
{#// rdvs[i].intervenant ? 'Intervenant: ' + rdvs[i].intervenant.lastname.toUpperCase() : null,#}
{#// ],#}
{#isAllDay: true#}
{#}#}
{#]);#}
{#}#}
{#}#}
{#$('#form_add_rdv').on('submit', function (e) {#}
{#e.preventDefault();#}
{#const path = "{{ path('app_planning_addrdvajax') }}";#}
{#$.ajax({#}
{#url: path,#}
{#data: $(this).serialize(),#}
{#type: 'post',#}
{#success: function(data) {#}
{#console.log(data);#}
{#console.log(data.start);#}
{#console.log( new Date( data.start).toISOString());#}
{#$('#rdv').modal('hide');#}
{#calendar.createSchedules([{#}
{#id: data.id,#}
{#calendarId: data.id,#}
{#title: data.client ? data.client.lastname.toUpperCase() : null,#}
{#category: 'time',#}
{#dueDateClass: '',#}
{#start: new Date( data.start).toISOString(),#}
{#end: new Date( data.end).toISOString()#}
{#}]);#}
{#}#}
{#});#}
{#});#}
{#/**#}
{#* Filter#}
{#*/#}
{#$('.filter').on('change', function (e) {#}
{#e.preventDefault();#}
{#const type = $(this).data('type');#}
{#const val = $(this).val();#}
{#console.log('value selected', val);#}
{#let path = null;#}
{#if(type === 'company') {#}
{#console.log('type',type);#}
{#$('.select-intervenant').val(null).trigger('change.select2');#}
{#$('.select-site').val(null).trigger('change.select2');#}
{#path = "{{ path('app_planning_ajaxfilter', {#}
{#'company' : 'company_id',#}
{#}) }}";#}
{#path = path.replace("company_id", val);#}
{#}#}
{#if(type === 'intervenant') {#}
{#console.log('type',type);#}
{#$('.select-company').val(null).trigger('change.select2');#}
{#$('.select-site').val(null).trigger('change.select2');#}
{#path = "{{ path('app_planning_ajaxfilter', {#}
{#'intervenant' : 'intervenant_id',#}
{#}) }}";#}
{#path = path.replace("intervenant_id", val);#}
{#}#}
{#if(type === 'site') {#}
{#console.log('type',type);#}
{#$('.select-intervenant').val(null).trigger('change.select2');#}
{#$('.select-company').val(null).trigger('change.select2');#}
{#path = "{{ path('app_planning_ajaxfilter', {#}
{#'site' : 'site_id'#}
{#}) }}";#}
{#path = path.replace("site_id", val);#}
{#}#}
{#console.log(path);#}
{#if(path && val) {#}
{#$.ajax({#}
{#url: path,#}
{#type: 'get',#}
{#success: function(data) {#}
{#calendar.clear();#}
{#if(data.length > 0) {#}
{#for(var i = 0;i < data.length; i++) {#}
{#calendar.createSchedules([{#}
{#id: data[i].id,#}
{#calendarId: data[i].id,#}
{#title: data[i].client ? data[i].client.lastname.toUpperCase() : null,#}
{#category: 'time',#}
{#dueDateClass: '',#}
{#start: new Date( data[i].start).toISOString(),#}
{#end: new Date( data[i].end).toISOString(),#}
{#isAllDay: true#}
{#}]);#}
{#}#}
{#}#}
{#}#}
{#});#}
{#}#}
{#else {#}
{#$.ajax({#}
{#url: "{{ path('app_planning_ajaxfilter') }}",#}
{#type: 'get',#}
{#success: function(data) {#}
{#calendar.clear();#}
{#if(data.length > 0) {#}
{#for(var i = 0;i < data.length; i++) {#}
{#calendar.createSchedules([{#}
{#id: data[i].id,#}
{#calendarId: data[i].id,#}
{#title: data[i].client ? data[i].client.lastname.toUpperCase() : null,#}
{#category: 'time',#}
{#dueDateClass: '',#}
{#start: new Date( data[i].start).toISOString(),#}
{#end: new Date( data[i].end).toISOString(),#}
{#isAllDay: true#}
{#}]);#}
{#}#}
{#}#}
{#}#}
{#});#}
{#}#}
{#});#}
$('#date_debut').flatpickr({
'dateFormat' : 'Y-m-d',
"locale": "fr",
});
$('#date_fin').flatpickr({
'dateFormat' : 'Y-m-d',
"locale": "fr"
});
new Tablesort(document.getElementById('table'));
$('#filter-salon').select2({ width: '100%' });
$('#filter-intervenant').select2({ width: '100%' });
</script>
{% endblock %}