2023-04-17 15:44:55 +02:00
|
|
|
<div class="assiduite-bubble">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2023-05-30 10:17:49 +02:00
|
|
|
|
|
|
|
const mt_start = {{ t_start }};
|
|
|
|
const mt_end = {{ t_end }};
|
|
|
|
/**
|
|
|
|
* Création de la minitiline d'un étudiant
|
|
|
|
* @param {Array[Assiduité]} assiduitesArray
|
|
|
|
* @returns {HTMLElement} l'élément correspondant à la mini timeline
|
|
|
|
*/
|
2023-06-22 16:25:13 +02:00
|
|
|
function createMiniTimeline(assiduitesArray, day = null) {
|
2023-05-30 10:17:49 +02:00
|
|
|
const array = [...assiduitesArray];
|
2023-11-20 16:55:26 +01:00
|
|
|
const date = day == null ? getDate() : new Date(day);
|
2023-05-30 10:17:49 +02:00
|
|
|
const timeline = document.createElement("div");
|
|
|
|
timeline.className = "mini-timeline";
|
|
|
|
if (isSingleEtud()) {
|
|
|
|
timeline.classList.add("single");
|
|
|
|
}
|
2023-11-20 16:55:26 +01:00
|
|
|
const timelineDate = date.startOf("day");
|
2023-05-30 10:17:49 +02:00
|
|
|
const dayStart = timelineDate.clone().add(mt_start, "hours");
|
|
|
|
const dayEnd = timelineDate.clone().add(mt_end, "hours");
|
2023-11-08 15:12:42 +01:00
|
|
|
const dayDuration = new Duration(dayStart, dayEnd).minutes;
|
2023-05-30 10:17:49 +02:00
|
|
|
|
|
|
|
timeline.appendChild(setMiniTick(timelineDate, dayStart, dayDuration));
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
if (day == null) {
|
|
|
|
const tlTimes = getTimeLineTimes();
|
|
|
|
array.push({
|
|
|
|
date_debut: tlTimes.deb.format(),
|
|
|
|
date_fin: tlTimes.fin.format(),
|
|
|
|
etat: "CRENEAU",
|
|
|
|
});
|
2023-11-20 16:55:26 +01:00
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
2023-05-30 10:17:49 +02:00
|
|
|
|
|
|
|
array.forEach((assiduité) => {
|
2024-01-12 11:36:00 +01:00
|
|
|
if(assiduité.etat == "CRENEAU" && readOnly) return;
|
2023-11-20 16:55:26 +01:00
|
|
|
let startDate = new Date(Date.removeUTC(assiduité.date_debut));
|
|
|
|
let endDate = new Date(Date.removeUTC(assiduité.date_fin));
|
2023-05-30 10:17:49 +02:00
|
|
|
if (startDate.isBefore(dayStart)) {
|
2023-07-26 16:43:49 +02:00
|
|
|
startDate = dayEnd.clone().startOf("day").add(mt_start, "hours");
|
2023-05-30 10:17:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (endDate.isAfter(dayEnd)) {
|
2023-07-26 16:43:49 +02:00
|
|
|
endDate = dayEnd.clone().startOf("day").add(mt_end, "hours");
|
2023-05-30 10:17:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const block = document.createElement("div");
|
|
|
|
block.className = "mini-timeline-block";
|
2023-11-20 16:55:26 +01:00
|
|
|
const duration = (new Duration(startDate, endDate)).minutes;
|
|
|
|
const startOffset = (new Duration(dayStart, startDate)).minutes;
|
2023-05-30 10:17:49 +02:00
|
|
|
const leftPercentage = (startOffset / dayDuration) * 100;
|
|
|
|
const widthPercentage = (duration / dayDuration) * 100;
|
|
|
|
|
2023-11-20 16:55:26 +01:00
|
|
|
|
2023-05-30 10:17:49 +02:00
|
|
|
block.style.left = `${leftPercentage}%`;
|
|
|
|
block.style.width = `${widthPercentage}%`;
|
|
|
|
|
|
|
|
if (assiduité.etat != "CRENEAU") {
|
2023-06-05 16:18:06 +02:00
|
|
|
block.addEventListener("click", () => {
|
2023-11-08 15:12:42 +01:00
|
|
|
let deb = startDate.getHours() + startDate.getMinutes() / 60;
|
|
|
|
let fin = endDate.getHours() + endDate.getMinutes() / 60;
|
2023-06-05 16:18:06 +02:00
|
|
|
deb = Math.max(mt_start, deb);
|
|
|
|
fin = Math.min(mt_end, fin);
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
if (day == null) setPeriodValues(deb, fin);
|
2023-06-05 16:18:06 +02:00
|
|
|
if (isSingleEtud()) {
|
2023-05-30 10:17:49 +02:00
|
|
|
updateSelectedSelect(getCurrentAssiduiteModuleImplId());
|
|
|
|
updateJustifyBtn();
|
2023-06-05 16:18:06 +02:00
|
|
|
}
|
|
|
|
});
|
2023-05-30 10:17:49 +02:00
|
|
|
//ajouter affichage assiduites on over
|
|
|
|
setupAssiduiteBuble(block, assiduité);
|
|
|
|
}
|
|
|
|
|
|
|
|
const action = (justificatifs) => {
|
|
|
|
if (justificatifs.length > 0) {
|
|
|
|
let j = "invalid_justified";
|
|
|
|
|
|
|
|
justificatifs.forEach((ju) => {
|
|
|
|
if (ju.etat == "VALIDE") {
|
|
|
|
j = "justified";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
block.classList.add(j);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (assiduité.etudid) {
|
|
|
|
getJustificatifFromPeriod(
|
|
|
|
{
|
2023-11-08 15:12:42 +01:00
|
|
|
deb: new Date(assiduité.date_debut),
|
|
|
|
fin: new Date(assiduité.date_fin),
|
2023-05-30 10:17:49 +02:00
|
|
|
},
|
|
|
|
assiduité.etudid,
|
|
|
|
action
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (assiduité.etat) {
|
|
|
|
case "PRESENT":
|
|
|
|
block.classList.add("present");
|
|
|
|
break;
|
|
|
|
case "RETARD":
|
|
|
|
block.classList.add("retard");
|
|
|
|
break;
|
|
|
|
case "ABSENT":
|
|
|
|
block.classList.add("absent");
|
|
|
|
break;
|
|
|
|
case "CRENEAU":
|
|
|
|
block.classList.add("creneau");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
block.style.backgroundColor = "white";
|
|
|
|
}
|
|
|
|
|
|
|
|
timeline.appendChild(block);
|
|
|
|
});
|
|
|
|
|
|
|
|
return timeline;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ajout de la visualisation des assiduités de la mini timeline
|
|
|
|
* @param {HTMLElement} el l'élément survollé
|
|
|
|
* @param {Assiduité} assiduite l'assiduité représentée par l'élément
|
|
|
|
*/
|
|
|
|
function setupAssiduiteBuble(el, assiduite) {
|
|
|
|
if (!assiduite) return;
|
|
|
|
|
2024-01-16 16:15:48 +01:00
|
|
|
const bubble = document.createElement('div');
|
|
|
|
bubble.className = "assiduite-bubble";
|
|
|
|
bubble.classList.add(assiduite.etat.toLowerCase());
|
|
|
|
|
|
|
|
const idDiv = document.createElement("div");
|
|
|
|
idDiv.className = "assiduite-id";
|
|
|
|
idDiv.textContent = `${getModuleImpl(assiduite)}`;
|
|
|
|
bubble.appendChild(idDiv);
|
|
|
|
|
|
|
|
const periodDivDeb = document.createElement("div");
|
|
|
|
periodDivDeb.className = "assiduite-period";
|
|
|
|
periodDivDeb.textContent = `${formatDateModal(assiduite.date_debut)}`;
|
|
|
|
bubble.appendChild(periodDivDeb);
|
|
|
|
const periodDivFin = document.createElement("div");
|
|
|
|
periodDivFin.className = "assiduite-period";
|
|
|
|
periodDivFin.textContent = `${formatDateModal(assiduite.date_fin)}`;
|
|
|
|
bubble.appendChild(periodDivFin);
|
|
|
|
|
|
|
|
const stateDiv = document.createElement("div");
|
|
|
|
stateDiv.className = "assiduite-state";
|
|
|
|
stateDiv.textContent = `État: ${assiduite.etat.capitalize()}`;
|
|
|
|
bubble.appendChild(stateDiv);
|
|
|
|
|
|
|
|
const userIdDiv = document.createElement("div");
|
|
|
|
userIdDiv.className = "assiduite-user_id";
|
|
|
|
userIdDiv.textContent = `saisie le ${formatDateModal(
|
|
|
|
assiduite.entry_date,
|
|
|
|
" à "
|
|
|
|
)}`;
|
|
|
|
|
|
|
|
if (assiduite.user_id != null) {
|
|
|
|
userIdDiv.textContent += `\npar ${assiduite.user_nom_complet}`
|
|
|
|
}
|
|
|
|
bubble.appendChild(userIdDiv);
|
|
|
|
|
|
|
|
el.appendChild(bubble);
|
2023-05-30 10:17:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function setMiniTick(timelineDate, dayStart, dayDuration) {
|
2023-11-08 15:12:42 +01:00
|
|
|
const endDate = timelineDate.clone().startOf("day");
|
|
|
|
endDate.setHours(13, 0);
|
|
|
|
const duration = new Duration(dayStart, endDate).minutes;
|
2023-05-30 10:17:49 +02:00
|
|
|
const widthPercentage = (duration / dayDuration) * 100;
|
|
|
|
const tick = document.createElement('span');
|
|
|
|
tick.className = "mini_tick"
|
|
|
|
tick.textContent = "13h"
|
|
|
|
tick.style.left = `${widthPercentage}%`
|
|
|
|
|
|
|
|
return tick
|
|
|
|
|
|
|
|
}
|
2024-01-16 16:15:48 +01:00
|
|
|
</script>
|