2023-06-22 16:25:13 +02:00
|
|
|
{% block pageContent %}
|
|
|
|
{% include "assiduites/widgets/alert.j2" %}
|
|
|
|
|
|
|
|
<div class="pageContent">
|
|
|
|
{{minitimeline | safe }}
|
2023-09-19 23:04:46 +02:00
|
|
|
<h2>Assiduité de {{sco.etud.nomprenom}}</h2>
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
<div class="options">
|
2023-11-16 02:48:39 +01:00
|
|
|
<input type="checkbox" id="show_pres" name="show_pres"><label for="show_pres">afficher les présences</label>
|
|
|
|
<input type="checkbox" name="show_reta" id="show_reta"><label for="show_reta">afficher les retards</label>
|
2023-11-16 14:25:06 +01:00
|
|
|
<input type="checkbox" name="mode_demi" id="mode_demi" checked><label for="mode_demi">mode demi journée</label>
|
2023-11-15 17:34:13 +01:00
|
|
|
</div>
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
<div class="calendrier">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="annee">
|
2023-11-15 17:34:13 +01:00
|
|
|
<span id="label-annee">Année scolaire 2022-2023</span><span id="label-changer" style="margin-left: 5px;">Changer
|
|
|
|
année: </span>
|
2023-06-22 16:25:13 +02:00
|
|
|
<select name="" id="annee" onchange="setterAnnee(this.value)">
|
|
|
|
</select>
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
<span id="label-nom">Assiduité de {{sco.etud.nomprenom}}</span>
|
2023-06-22 16:25:13 +02:00
|
|
|
</div>
|
2023-06-30 14:38:56 +02:00
|
|
|
|
2023-09-19 23:04:46 +02:00
|
|
|
<div class="help">
|
2023-06-30 14:38:56 +02:00
|
|
|
<h3>Calendrier</h3>
|
2023-11-16 14:25:06 +01:00
|
|
|
<p>Code couleur</p>
|
|
|
|
<ul class="couleurs">
|
|
|
|
<li><span title="Vert" class="present demo"></span> → présence de l'étudiant lors de la période
|
|
|
|
</li>
|
|
|
|
<li><span title="Bleu clair" class="nonwork demo"></span> → la période n'est pas travaillée
|
|
|
|
</li>
|
|
|
|
<li><span title="Rouge" class="absent demo"></span> → absence de l'étudiant lors de la période
|
|
|
|
</li>
|
|
|
|
<li><span title="Rose" class="demo color absent est_just"></span> → absence justifiée
|
|
|
|
</li>
|
|
|
|
<li><span title="Orange" class="retard demo"></span> → retard de l'étudiant lors de la période
|
|
|
|
</li>
|
|
|
|
<li><span title="Jaune clair" class="demo color retard est_just"></span> → retard justifié
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li><span title="Quart Bleu" class="est_just demo"></span> → la période est justifiée par un
|
|
|
|
justificatif valide</li>
|
|
|
|
<li><span title="Quart Violet" class="invalide demo"></span> → la période est
|
|
|
|
justifiée par un justificatif non valide / en attente de validation
|
|
|
|
</li>
|
2023-06-30 14:38:56 +02:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
<p>Vous pouvez passer le curseur sur les jours colorés afin de voir les informations supplémentaires</p>
|
2023-06-30 14:38:56 +02:00
|
|
|
</div>
|
2023-11-16 14:25:06 +01:00
|
|
|
<ul class="couleurs print">
|
|
|
|
<li><span title="Vert" class="present demo"></span> présence
|
|
|
|
</li>
|
|
|
|
<li><span title="Bleu clair" class="nonwork demo"></span> non travaillé
|
|
|
|
</li>
|
|
|
|
<li><span title="Rouge" class="absent demo"></span> absence
|
|
|
|
</li>
|
|
|
|
<li><span title="Rose" class="demo color absent est_just"></span> absence justifiée
|
|
|
|
</li>
|
|
|
|
<li><span title="Orange" class="retard demo"></span> retard
|
|
|
|
</li>
|
|
|
|
<li><span title="Jaune clair" class="demo color retard est_just"></span>retard justifié
|
|
|
|
</li>
|
|
|
|
<li><span title="Quart Bleu" class="est_just demo"></span>
|
|
|
|
justificatif valide</li>
|
|
|
|
<li><span title="Quart Violet" class="invalide demo"></span> justificatif non valide
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-06-22 16:25:13 +02:00
|
|
|
</div>
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
<style>
|
|
|
|
.help .couleurs {
|
|
|
|
grid-template-columns: 2;
|
|
|
|
grid-template-rows: auto;
|
|
|
|
display: grid;
|
|
|
|
}
|
2023-06-22 16:25:13 +02:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.couleurs.print {
|
|
|
|
display: none;
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.help .couleurs li:nth-child(odd) {
|
|
|
|
grid-column: 1;
|
|
|
|
list-style-type: none;
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.help .couleurs li:nth-child(even) {
|
|
|
|
grid-column: 2;
|
|
|
|
list-style-type: none;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.color.present {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-color: var(--color-present) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.color.absent {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-color: var(--color-absent) !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.color.absent.est_just {
|
|
|
|
background-color: var(--color-absent-justi) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.color.retard {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-color: var(--color-retard) !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.color.retard.est_just {
|
|
|
|
background-color: var(--color-retard-justi) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.color.nonwork {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-color: var(--color-nonwork) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.color {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-color: var(--color-defaut) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
.pageContent {
|
|
|
|
margin-top: 1vh;
|
|
|
|
max-width: var(--sco-content-max-width);
|
|
|
|
}
|
|
|
|
|
|
|
|
.calendrier {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
border: 1px solid #444;
|
2023-11-16 02:48:39 +01:00
|
|
|
border-radius: 12px;
|
|
|
|
margin-bottom: 12px;
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
.month h3 {
|
2023-06-22 16:25:13 +02:00
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
.day,
|
2023-11-16 14:25:06 +01:00
|
|
|
.demi .day.color.nonwork {
|
|
|
|
text-align: left;
|
2023-06-22 16:25:13 +02:00
|
|
|
margin: 2px;
|
|
|
|
cursor: default;
|
2023-11-16 02:48:39 +01:00
|
|
|
font-size: 13px;
|
2023-06-22 16:25:13 +02:00
|
|
|
position: relative;
|
2023-11-16 02:48:39 +01:00
|
|
|
font-weight: normal;
|
2023-11-15 17:34:13 +01:00
|
|
|
min-width: 6em;
|
2023-11-16 14:25:06 +01:00
|
|
|
display: flex;
|
|
|
|
justify-content: start;
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.color.est_just.sans_etat::before {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
width: 25%;
|
|
|
|
height: 100%;
|
|
|
|
background-color: var(--color-justi) !important;
|
|
|
|
right: 0;
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.color.invalide::before {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
width: 25%;
|
|
|
|
height: 100%;
|
|
|
|
right: 0;
|
|
|
|
background-color: var(--color-justi-invalide) !important;
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.demo.invalide {
|
|
|
|
background-color: var(--color-justi-invalide) !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.demo.est_just {
|
|
|
|
background-color: var(--color-justi) !important;
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
.demi .day.nonwork>span {
|
|
|
|
flex: none;
|
|
|
|
border: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day {
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
.day .dayline {
|
|
|
|
position: absolute;
|
|
|
|
display: none;
|
2023-11-16 14:25:06 +01:00
|
|
|
bottom: -390%;
|
2023-06-22 16:25:13 +02:00
|
|
|
z-index: 50;
|
2023-11-16 14:25:06 +01:00
|
|
|
width: max-content;
|
2023-06-22 16:25:13 +02:00
|
|
|
height: 75px;
|
|
|
|
background-color: #dedede;
|
|
|
|
border-radius: 15px;
|
|
|
|
padding: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.day:hover .dayline {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dayline .mini-timeline {
|
2023-11-16 14:25:06 +01:00
|
|
|
margin-top: 10%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dayline-title {
|
|
|
|
margin: 0;
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.dayline .mini_tick {
|
|
|
|
position: absolute;
|
|
|
|
text-align: center;
|
|
|
|
top: 0;
|
|
|
|
transform: translateY(-110%);
|
|
|
|
z-index: 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dayline .mini_tick::after {
|
|
|
|
display: block;
|
|
|
|
content: "|";
|
|
|
|
position: absolute;
|
|
|
|
bottom: -69%;
|
|
|
|
z-index: 2;
|
|
|
|
transform: translateX(200%);
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
#label-nom,
|
|
|
|
#label-justi {
|
2023-11-15 17:34:13 +01:00
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day>span {
|
|
|
|
display: block;
|
|
|
|
flex: 1;
|
|
|
|
text-align: center;
|
|
|
|
z-index: 1;
|
|
|
|
width: 100%;
|
2023-11-16 02:48:39 +01:00
|
|
|
border: 1px solid #d5d5d5;
|
2023-11-16 14:25:06 +01:00
|
|
|
position: relative;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day>span:first-of-type {
|
|
|
|
width: 3em;
|
|
|
|
min-width: 3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.options>* {
|
|
|
|
margin-right: 5px;
|
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
|
2023-11-16 02:48:39 +01:00
|
|
|
.options input {
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
|
2023-11-16 02:48:39 +01:00
|
|
|
.options label {
|
|
|
|
font-weight: normal;
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
@media print {
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
.couleurs.print {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
align-items: center;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.couleurs.print li {
|
|
|
|
list-style-type: none !important;
|
|
|
|
-webkit-print-color-adjust: exact !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
print-color-adjust: exact !important;
|
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.day,
|
|
|
|
.demi .day.color.color.nonwork {
|
|
|
|
min-width: 5em;
|
|
|
|
font-size: 11px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day>span:first-of-type {
|
|
|
|
width: 2.5em;
|
|
|
|
min-width: 2.5em;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.color {
|
|
|
|
-webkit-print-color-adjust: exact !important;
|
2023-11-15 17:34:13 +01:00
|
|
|
print-color-adjust: exact !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.day.est_just,
|
|
|
|
.demi .day span.est_just {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-image: none;
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.day.invalide,
|
2023-11-15 17:34:13 +01:00
|
|
|
.demi .day span.invalide {
|
2023-11-16 14:25:06 +01:00
|
|
|
background-image: none;
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
.demi .day span.est_just::before {
|
|
|
|
content: "J";
|
|
|
|
}
|
|
|
|
|
|
|
|
.demi .day span.invalide::before {
|
|
|
|
content: "JI";
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
#sidebar,
|
|
|
|
.help,
|
|
|
|
h2,
|
|
|
|
#annee,
|
|
|
|
#label-changer,
|
|
|
|
.options {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
#label-nom,
|
|
|
|
#label-justi {
|
2023-11-15 17:34:13 +01:00
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
|
|
|
|
#gtrcontent {
|
|
|
|
margin: 5px;
|
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
.annee {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
align-items: center;
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
2023-06-22 16:25:13 +02:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function getDaysBetweenDates(start, end) {
|
2023-11-08 15:12:42 +01:00
|
|
|
let now = new Date(start);
|
|
|
|
end = new Date(end);
|
2023-06-22 16:25:13 +02:00
|
|
|
let dates = [];
|
|
|
|
|
2023-11-08 15:12:42 +01:00
|
|
|
while (now.isBefore(end) || now.isSame(end)) {
|
2023-06-22 16:25:13 +02:00
|
|
|
dates.push(now.clone());
|
|
|
|
now.add(1, "days");
|
|
|
|
}
|
|
|
|
|
|
|
|
return dates;
|
|
|
|
}
|
|
|
|
|
|
|
|
function organizeByMonth(dates) {
|
|
|
|
let datesByMonth = {};
|
|
|
|
|
|
|
|
dates.forEach((date) => {
|
2023-11-03 16:55:26 +01:00
|
|
|
let month = date.toLocaleString('fr-FR', { month: "short" }); // Obtenir le mois
|
2023-06-22 16:25:13 +02:00
|
|
|
|
|
|
|
if (!datesByMonth[month]) {
|
|
|
|
datesByMonth[month] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
datesByMonth[month].push(date);
|
|
|
|
});
|
|
|
|
|
|
|
|
return datesByMonth;
|
|
|
|
}
|
|
|
|
|
|
|
|
function organizeAssiduitiesByDay(datesByMonth, assiduities, justificatifs) {
|
|
|
|
let assiduitiesByDay = {};
|
|
|
|
|
|
|
|
Object.keys(datesByMonth).forEach((month) => {
|
|
|
|
assiduitiesByDay[month] = {};
|
|
|
|
|
|
|
|
datesByMonth[month].forEach((date) => {
|
|
|
|
let dayAssiduities = assiduities.filter((assiduity) => {
|
2023-11-03 16:55:26 +01:00
|
|
|
return new Date(date).isBetween(
|
2023-11-10 14:24:29 +01:00
|
|
|
new Date(assiduity.date_debut).startOf("day"),
|
|
|
|
new Date(assiduity.date_fin).startOf("day"),
|
2023-06-22 16:25:13 +02:00
|
|
|
"[]"
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
|
|
|
let dayJustificatifs = justificatifs.filter((justif) => {
|
2023-11-03 16:55:26 +01:00
|
|
|
return new Date(date).isBetween(
|
2023-11-10 14:24:29 +01:00
|
|
|
new Date(justif.date_debut).startOf("day"),
|
|
|
|
new Date(justif.date_fin).startOf("day"),
|
2023-06-22 16:25:13 +02:00
|
|
|
"[]"
|
|
|
|
)
|
|
|
|
});
|
|
|
|
|
2023-11-08 15:12:42 +01:00
|
|
|
assiduitiesByDay[month][date.toLocaleDateString("en-US")] = {
|
2023-06-22 16:25:13 +02:00
|
|
|
assiduites: dayAssiduities,
|
|
|
|
justificatifs: dayJustificatifs
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return assiduitiesByDay;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateCalendar(assiduitiesByDay, nonWorkdays = []) {
|
|
|
|
const calendar = document.querySelector('.calendrier')
|
2023-11-15 17:34:13 +01:00
|
|
|
const options = getOptions();
|
2023-06-22 16:25:13 +02:00
|
|
|
calendar.innerHTML = ""
|
|
|
|
|
|
|
|
const days = {
|
2023-11-08 15:12:42 +01:00
|
|
|
1: "Lun",
|
|
|
|
2: "Mar",
|
|
|
|
3: "Mer",
|
|
|
|
4: "Jeu",
|
|
|
|
5: "Ven",
|
|
|
|
6: "Sam",
|
|
|
|
0: "Dim",
|
2023-06-22 16:25:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Object.keys(assiduitiesByDay).forEach((month) => {
|
|
|
|
const monthEl = document.createElement('div')
|
|
|
|
monthEl.classList.add("month")
|
2023-11-15 17:34:13 +01:00
|
|
|
const title = document.createElement('h3');
|
2023-11-08 15:12:42 +01:00
|
|
|
title.textContent = `${month.capitalize()}`;
|
2023-06-22 16:25:13 +02:00
|
|
|
monthEl.appendChild(title)
|
|
|
|
|
|
|
|
const daysEl = document.createElement('div')
|
|
|
|
daysEl.classList.add('days');
|
2023-11-15 17:34:13 +01:00
|
|
|
if (options.mode_demi) daysEl.classList.add("demi");
|
2023-06-22 16:25:13 +02:00
|
|
|
Object.keys(assiduitiesByDay[month]).forEach((date) => {
|
|
|
|
let dayAssiduities = assiduitiesByDay[month][date].assiduites;
|
|
|
|
let dayJustificatifs = assiduitiesByDay[month][date].justificatifs;
|
2023-11-16 14:25:06 +01:00
|
|
|
let color = "sans_etat";
|
2023-06-22 16:25:13 +02:00
|
|
|
|
|
|
|
if (dayAssiduities.some((a) => a.etat.toLowerCase() === "absent")) color = "absent";
|
2023-11-15 17:34:13 +01:00
|
|
|
else if (dayAssiduities.some((a) => a.etat.toLowerCase() === "retard") && options.show_reta)
|
2023-06-22 16:25:13 +02:00
|
|
|
color = "retard";
|
2023-11-15 17:34:13 +01:00
|
|
|
else if (dayAssiduities.some((a) => a.etat.toLowerCase() === "present") && options.show_pres)
|
2023-06-22 16:25:13 +02:00
|
|
|
color = "present";
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
let est_just = ""
|
|
|
|
if (dayJustificatifs.some((j) => j.etat.toLowerCase() === "valide")) {
|
|
|
|
est_just = "est_just";
|
|
|
|
} else if (dayJustificatifs.some((j) => j.etat.toLowerCase() !== "valide")) {
|
2023-11-16 14:25:06 +01:00
|
|
|
est_just = "invalide";
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
2023-11-03 16:55:26 +01:00
|
|
|
const momentDate = new Date(date);
|
2023-11-08 15:12:42 +01:00
|
|
|
let dayOfMonth = momentDate.getDate();
|
|
|
|
let dayOfWeek = momentDate.getDay();
|
2023-06-22 16:25:13 +02:00
|
|
|
dayOfWeek = days[dayOfWeek];
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
let isNonWorkDay = nonWorkdays.includes(dayOfWeek.toLowerCase());
|
2023-06-22 16:25:13 +02:00
|
|
|
const day = document.createElement('div');
|
2023-11-15 17:34:13 +01:00
|
|
|
day.className = `day`;
|
2023-11-16 14:25:06 +01:00
|
|
|
if (isNonWorkDay) {
|
2023-11-15 17:34:13 +01:00
|
|
|
color = "nonwork";
|
|
|
|
} else if (!options.mode_demi) {
|
|
|
|
day.className = `day ${est_just}`;
|
|
|
|
}
|
2023-06-22 16:25:13 +02:00
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
if (options.mode_demi && !isNonWorkDay) {
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
est_just = []
|
|
|
|
// affichage n° jour + matin + aprem
|
|
|
|
|
|
|
|
const span_jour = document.createElement("span")
|
2023-11-16 14:25:06 +01:00
|
|
|
span_jour.textContent = dayOfWeek[0] + dayOfMonth;
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
const span_matin = document.createElement("span");
|
|
|
|
span_matin.classList.add("color");
|
|
|
|
const matin = [new Date(date), new Date(date)]
|
2023-11-16 14:25:06 +01:00
|
|
|
color = "sans_etat"
|
2023-11-15 17:34:13 +01:00
|
|
|
matin[0].setHours(0, 0, 0, 0)
|
|
|
|
matin[1].setHours(12, 59, 59)
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
const assiduitesMatin = dayAssiduities.filter((el) => {
|
|
|
|
const deb = new Date(el.date_debut);
|
|
|
|
const fin = new Date(el.date_fin);
|
2023-11-16 14:25:06 +01:00
|
|
|
return Date.intersect({ deb: deb, fin: fin }, { deb: matin[0], fin: matin[1] })
|
2023-11-15 17:34:13 +01:00
|
|
|
})
|
|
|
|
const justificatifsMatin = dayJustificatifs.filter((el) => {
|
|
|
|
const deb = new Date(el.date_debut);
|
|
|
|
const fin = new Date(el.date_fin);
|
2023-11-16 14:25:06 +01:00
|
|
|
return Date.intersect({ deb: deb, fin: fin }, { deb: matin[0], fin: matin[1] })
|
2023-11-15 17:34:13 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
if (assiduitesMatin.some((a) => a.etat.toLowerCase() === "absent")) color = "absent";
|
|
|
|
else if (assiduitesMatin.some((a) => a.etat.toLowerCase() === "retard") && options.show_reta)
|
|
|
|
color = "retard";
|
|
|
|
else if (assiduitesMatin.some((a) => a.etat.toLowerCase() === "present") && options.show_pres)
|
|
|
|
color = "present";
|
|
|
|
|
|
|
|
if (color != "") {
|
|
|
|
span_matin.classList.add(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (justificatifsMatin.some((j) => j.etat.toLowerCase() === "valide")) {
|
|
|
|
est_just = ["est_just"];
|
|
|
|
} else if (justificatifsMatin.some((j) => j.etat.toLowerCase() !== "valide")) {
|
2023-11-16 14:25:06 +01:00
|
|
|
est_just = ["invalide"];
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
span_matin.classList.add(...est_just)
|
|
|
|
|
|
|
|
|
|
|
|
est_just = []
|
|
|
|
const span_aprem = document.createElement("span");
|
|
|
|
span_aprem.classList.add("color");
|
|
|
|
const aprem = [new Date(date), new Date(date)]
|
2023-11-16 14:25:06 +01:00
|
|
|
color = "sans_etat"
|
2023-11-15 17:34:13 +01:00
|
|
|
aprem[0].setHours(13, 0, 0, 0)
|
|
|
|
aprem[1].setHours(23, 59, 59)
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
const assiduitesAprem = dayAssiduities.filter((el) => {
|
|
|
|
const deb = new Date(el.date_debut);
|
|
|
|
const fin = new Date(el.date_fin);
|
2023-11-16 14:25:06 +01:00
|
|
|
return Date.intersect({ deb: deb, fin: fin }, { deb: aprem[0], fin: aprem[1] })
|
2023-11-15 17:34:13 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
const justificatifsAprem = dayJustificatifs.filter((el) => {
|
|
|
|
const deb = new Date(el.date_debut);
|
|
|
|
const fin = new Date(el.date_fin);
|
2023-11-16 14:25:06 +01:00
|
|
|
return Date.intersect({ deb: deb, fin: fin }, { deb: aprem[0], fin: aprem[1] })
|
2023-11-15 17:34:13 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
if (assiduitesAprem.some((a) => a.etat.toLowerCase() === "absent")) color = "absent";
|
|
|
|
else if (assiduitesAprem.some((a) => a.etat.toLowerCase() === "retard") && options.show_reta)
|
|
|
|
color = "retard";
|
|
|
|
else if (assiduitesAprem.some((a) => a.etat.toLowerCase() === "present") && options.show_pres)
|
|
|
|
color = "present";
|
|
|
|
|
|
|
|
if (color != "") {
|
|
|
|
span_aprem.classList.add(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (justificatifsAprem.some((j) => j.etat.toLowerCase() === "valide")) {
|
2023-11-16 14:25:06 +01:00
|
|
|
est_just = ["est_just"];
|
2023-11-15 17:34:13 +01:00
|
|
|
} else if (justificatifsAprem.some((j) => j.etat.toLowerCase() !== "valide")) {
|
2023-11-16 14:25:06 +01:00
|
|
|
est_just = ["invalide"];
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
span_aprem.classList.add(...est_just)
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
day.appendChild(span_jour)
|
|
|
|
day.appendChild(span_matin)
|
|
|
|
day.appendChild(span_aprem)
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
} else {
|
|
|
|
day.classList.add("color")
|
|
|
|
if (color != "") {
|
|
|
|
day.classList.add(color);
|
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
if (isNonWorkDay) {
|
|
|
|
const span_jour = document.createElement("span")
|
|
|
|
span_jour.textContent = dayOfWeek[0] + dayOfMonth;
|
|
|
|
day.appendChild(span_jour);
|
|
|
|
} else {
|
|
|
|
day.textContent = `${dayOfWeek} ${dayOfMonth}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
}
|
2023-11-16 14:25:06 +01:00
|
|
|
console.warn(day.classList, day.classList.length)
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
|
2023-06-23 16:12:36 +02:00
|
|
|
if (!nonWorkdays.includes(dayOfWeek.toLowerCase()) && dayAssiduities.length > 0) {
|
2023-06-22 16:25:13 +02:00
|
|
|
const cache = document.createElement('div')
|
|
|
|
cache.classList.add('dayline');
|
2023-11-16 14:25:06 +01:00
|
|
|
const title = document.createElement('div')
|
|
|
|
title.className = "dayline-title";
|
|
|
|
|
|
|
|
title.innerHTML = "<span>Assiduité du </span><br>" + `<span>${formatDate(momentDate)}</span>`;
|
|
|
|
cache.appendChild(title)
|
2023-06-22 16:25:13 +02:00
|
|
|
cache.appendChild(
|
|
|
|
createMiniTimeline(dayAssiduities, date)
|
|
|
|
)
|
|
|
|
day.appendChild(cache)
|
|
|
|
}
|
|
|
|
|
2023-11-16 14:25:06 +01:00
|
|
|
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
daysEl.appendChild(day);
|
|
|
|
});
|
|
|
|
monthEl.appendChild(daysEl)
|
|
|
|
calendar.appendChild(monthEl)
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEtudAssiduites(deb, fin, callback = () => { }) {
|
|
|
|
const url_api =
|
|
|
|
getUrl() +
|
|
|
|
`/api/assiduites/${etudid}/query?date_debut=${deb}&date_fin=${fin}`;
|
2023-11-15 17:34:13 +01:00
|
|
|
async_get(url_api, (data) => {
|
|
|
|
callback(data);
|
2023-06-22 16:25:13 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-11-15 17:34:13 +01:00
|
|
|
function getOptions() {
|
|
|
|
return {
|
|
|
|
"show_pres": document.getElementById("show_pres").checked,
|
|
|
|
"show_reta": document.getElementById("show_reta").checked,
|
|
|
|
"mode_demi": document.getElementById("mode_demi").checked,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
function getEtudJustificatifs(deb, fin) {
|
|
|
|
let list = [];
|
|
|
|
const url_api =
|
|
|
|
getUrl() +
|
|
|
|
`/api/justificatifs/${etudid}/query?date_debut=${deb}&date_fin=${fin}`;
|
|
|
|
sync_get(url_api, (data, status) => {
|
|
|
|
if (status === "success") {
|
|
|
|
list = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return list
|
|
|
|
}
|
|
|
|
|
|
|
|
function generate(annee) {
|
|
|
|
if (annee < 1999 || annee > 2999) {
|
|
|
|
openAlertModal("Année impossible", document.createTextNode("L'année demandé n'existe pas."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const bornes = {
|
|
|
|
deb: `${annee}-09-01T00:00`,
|
2023-07-25 14:06:49 +02:00
|
|
|
fin: `${annee + 1}-08-31T23:59`
|
2023-06-22 16:25:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let assiduities = getEtudAssiduites(bornes.deb, bornes.fin, (data) => {
|
|
|
|
let dates = getDaysBetweenDates(bornes.deb, bornes.fin);
|
|
|
|
let datesByMonth = organizeByMonth(dates);
|
|
|
|
const justifs = getEtudJustificatifs(bornes.deb, bornes.fin);
|
|
|
|
let assiduitiesByDay = organizeAssiduitiesByDay(datesByMonth, data, justifs);
|
|
|
|
generateCalendar(assiduitiesByDay, nonwork);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function setterAnnee(annee) {
|
|
|
|
annee = parseInt(annee);
|
2023-11-15 17:34:13 +01:00
|
|
|
document.querySelector('.annee #label-annee').textContent = `Année scolaire ${annee}-${annee + 1}`
|
2023-06-22 16:25:13 +02:00
|
|
|
generate(annee)
|
|
|
|
|
|
|
|
}
|
2023-11-15 17:34:13 +01:00
|
|
|
|
2023-06-22 16:25:13 +02:00
|
|
|
const defAnnee = {{ annee }}
|
2023-08-22 16:06:56 +02:00
|
|
|
let annees = {{ annees | safe }}
|
|
|
|
annees = annees.filter((x, i) => annees.indexOf(x) === i)
|
2023-06-22 16:25:13 +02:00
|
|
|
const etudid = {{ sco.etud.id }};
|
|
|
|
const nonwork = [{{ nonworkdays | safe }}];
|
|
|
|
window.onload = () => {
|
|
|
|
const select = document.querySelector('#annee');
|
2023-08-22 16:06:56 +02:00
|
|
|
annees.forEach((a) => {
|
2023-06-22 16:25:13 +02:00
|
|
|
const opt = document.createElement("option");
|
2023-08-22 16:06:56 +02:00
|
|
|
opt.value = a + "",
|
|
|
|
opt.textContent = `${a} - ${a + 1}`;
|
|
|
|
if (a === defAnnee) {
|
2023-06-22 16:25:13 +02:00
|
|
|
opt.selected = true;
|
|
|
|
}
|
|
|
|
select.appendChild(opt)
|
2023-08-22 16:06:56 +02:00
|
|
|
})
|
2023-11-15 17:34:13 +01:00
|
|
|
|
|
|
|
document.querySelectorAll(".options input").forEach((e) => {
|
|
|
|
e.addEventListener("click", () => {
|
|
|
|
setterAnnee(select.value)
|
|
|
|
})
|
|
|
|
})
|
2023-06-22 16:25:13 +02:00
|
|
|
setterAnnee(defAnnee)
|
|
|
|
};
|
|
|
|
|
2023-09-11 15:55:18 +02:00
|
|
|
|
|
|
|
function isCalendrier() { return true }
|
2023-06-22 16:25:13 +02:00
|
|
|
</script>
|
2023-11-16 14:25:06 +01:00
|
|
|
{% endblock pageContent %}
|