V7.10 — Tableau de bord, guide, semaine type et enveloppe de formation
Reprise dans le répertoire de production du travail mené dans le worktree ux-service-enfance : - tableau de bord Service Enfance (dashboard.php) et navigation regroupée ; - guide d'utilisation (faq.php) accessible depuis toute la navigation ; - éditeur de semaine type mis en avant sur l'écran de saisie ; - droit à l'enveloppe de formation par agent, en remplacement de la case « formation déjà prévue dans la répartition annuelle » ; - correctif de « [object Object] » sur les cartes de quota du PTA ; - motif de travail par défaut à la saisie, heures travaillées complètes dans les PDF. Le docker-compose.yml de production est conservé : celui du worktree décrit une pile de test (conteneurs et volume suffixés « test », ports 9080/9081), qui aurait fait redémarrer l'application sur un volume MariaDB vide. Les migrations database/migration_v7_9*.sql sont obligatoires ; le service db-migrate les applique au déploiement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,7 +211,7 @@
|
||||
row.dataset.dateFinContrat = agent.date_fin_contrat || '';
|
||||
row.dataset.idPoste = agent.id_poste ? String(Number(agent.id_poste)) : '';
|
||||
row.dataset.typeContrat = agent.type_contrat || 'PERMANENT';
|
||||
row.dataset.formationRepartitionAnnuelle = Number(agent.formation_repartition_annuelle) ? '1' : '0';
|
||||
row.dataset.droitEnveloppeFormation = Number(agent.droit_enveloppe_formation ?? 1) ? '1' : '0';
|
||||
row.dataset.commentairePta = agent.commentaire_pta || '';
|
||||
row.dataset.structureId = agent.id_structure ? String(Number(agent.id_structure)) : '';
|
||||
}
|
||||
@@ -255,7 +255,7 @@
|
||||
document.querySelector('#edit-agent-profile-contract-end').value = row.dataset.dateFinContrat || '';
|
||||
document.querySelector('#edit-agent-profile-post').value = row.dataset.idPoste || '';
|
||||
document.querySelector('#edit-agent-profile-contract-type').value = row.dataset.typeContrat || 'PERMANENT';
|
||||
document.querySelector('#edit-agent-profile-training-planned').checked = row.dataset.formationRepartitionAnnuelle === '1';
|
||||
document.querySelector('#edit-agent-profile-training-right').checked = row.dataset.droitEnveloppeFormation !== '0';
|
||||
document.querySelector('#edit-agent-profile-pta-comment').value = row.dataset.commentairePta || '';
|
||||
document.querySelector('#edit-agent-profile-structure').value = row.dataset.structureId || '';
|
||||
toggleDiplomaField(document.querySelector('#edit-agent-profile-qualified'), document.querySelector('#edit-agent-profile-diploma'));
|
||||
@@ -302,7 +302,7 @@
|
||||
date_fin_contrat: document.querySelector('#edit-agent-profile-contract-end').value,
|
||||
id_poste: Number(document.querySelector('#edit-agent-profile-post').value),
|
||||
type_contrat: document.querySelector('#edit-agent-profile-contract-type').value,
|
||||
formation_repartition_annuelle: document.querySelector('#edit-agent-profile-training-planned').checked,
|
||||
droit_enveloppe_formation: document.querySelector('#edit-agent-profile-training-right').checked,
|
||||
commentaire_pta: document.querySelector('#edit-agent-profile-pta-comment').value,
|
||||
structure_id: structureValue ? Number(structureValue) : null,
|
||||
}),
|
||||
@@ -407,7 +407,7 @@
|
||||
date_fin_contrat: document.querySelector('#new-agent-contract-end').value,
|
||||
id_poste: Number(document.querySelector('#new-agent-post').value),
|
||||
type_contrat: document.querySelector('#new-agent-contract-type').value,
|
||||
formation_repartition_annuelle: document.querySelector('#new-agent-training-planned').checked,
|
||||
droit_enveloppe_formation: document.querySelector('#new-agent-training-right').checked,
|
||||
commentaire_pta: document.querySelector('#new-agent-pta-comment').value,
|
||||
}),
|
||||
});
|
||||
@@ -419,7 +419,6 @@
|
||||
form.reset();
|
||||
document.querySelector('#new-agent-rate').value = '100';
|
||||
document.querySelector('#new-agent-contract-type').value = 'PERMANENT';
|
||||
document.querySelector('#new-agent-training-planned').checked = false;
|
||||
document.querySelector('#new-agent-qualified').value = '0';
|
||||
toggleDiplomaField(document.querySelector('#new-agent-qualified'), document.querySelector('#new-agent-diploma'));
|
||||
|
||||
|
||||
@@ -254,6 +254,28 @@
|
||||
setMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Le sélecteur de motif est rendu côté serveur avec tous les motifs actifs :
|
||||
* on le reconstruit à l'ouverture pour retirer « Formation » aux agents sans
|
||||
* droit à l'enveloppe de formation. Le motif déjà porté par le créneau reste
|
||||
* proposé, sans quoi le modal changerait silencieusement de motif.
|
||||
*/
|
||||
function renderMotifOptions(selectedMotifId) {
|
||||
const select = document.querySelector('#edit-agent-entry-motif');
|
||||
const motifs = window.PTA_CONFIG?.motifs || [];
|
||||
if (!select || motifs.length === 0) return;
|
||||
|
||||
const agent = shared.lastAgentOverviewData?.agent;
|
||||
const hasTrainingRight = Number(agent?.droit_enveloppe_formation ?? 1) !== 0;
|
||||
|
||||
select.innerHTML = motifs
|
||||
.filter((motif) => hasTrainingRight
|
||||
|| String(motif.code).toUpperCase() !== 'FORMATION'
|
||||
|| Number(motif.id) === Number(selectedMotifId))
|
||||
.map((motif) => `<option value="${Number(motif.id)}">${escapeHtml(motif.label)}</option>`)
|
||||
.join('');
|
||||
}
|
||||
|
||||
function openModal(entryId) {
|
||||
const entry = findEntry(entryId);
|
||||
if (!entry || !canEditEntry(entry)) return;
|
||||
@@ -263,6 +285,7 @@
|
||||
document.querySelector('#edit-agent-entry-id').value = String(Number(entry.id_creneau));
|
||||
document.querySelector('#edit-agent-entry-date').value = entry.date_jour;
|
||||
document.querySelector('#edit-agent-entry-structure').value = String(Number(entry.id_structure));
|
||||
renderMotifOptions(Number(entry.id_motif));
|
||||
document.querySelector('#edit-agent-entry-motif').value = String(Number(entry.id_motif));
|
||||
document.querySelector('#edit-agent-entry-start').value = entry.heure_debut;
|
||||
document.querySelector('#edit-agent-entry-end').value = entry.heure_fin;
|
||||
|
||||
@@ -5,12 +5,9 @@
|
||||
if (!PTA) return;
|
||||
const { readJsonResponse, apiErrorMessage, escapeHtml, formatDate } = PTA.utils;
|
||||
const el = (id) => document.getElementById(id);
|
||||
const escapeAttr = (value) => String(value ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('\"', '"')
|
||||
.replaceAll("'", ''')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>');
|
||||
// escapeHtml échappe désormais aussi les guillemets : une seule
|
||||
// implémentation partagée, valable en contexte texte comme attribut.
|
||||
const escapeAttr = escapeHtml;
|
||||
let current = null;
|
||||
|
||||
function show(text, type = 'info') {
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
entries: [],
|
||||
otherStructureEntries: [],
|
||||
currentStructure: null,
|
||||
currentAgent: null,
|
||||
planningId: null,
|
||||
planningStatus: null,
|
||||
weekDays: [],
|
||||
@@ -44,10 +45,21 @@
|
||||
|
||||
const dayNames = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi'];
|
||||
|
||||
/**
|
||||
* Échappe une valeur pour l'insertion dans du HTML, texte ET attribut.
|
||||
*
|
||||
* La sérialisation via textContent/innerHTML n'échappe ni " ni ' : elle est
|
||||
* sûre entre deux balises, mais permet de sortir d'un attribut value="…" ou
|
||||
* title="…". PTA insère des libellés de vacances, des noms de lieux et des
|
||||
* commentaires dans des attributs : les guillemets doivent être échappés.
|
||||
*/
|
||||
function escapeHtml(value) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = String(value ?? '');
|
||||
return div.innerHTML;
|
||||
return String(value ?? '')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
}
|
||||
|
||||
function showMessage(text, type = 'info') {
|
||||
|
||||
325
assets/js/dashboard.js
Normal file
325
assets/js/dashboard.js
Normal file
@@ -0,0 +1,325 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const PTA = window.PTA;
|
||||
if (!PTA) throw new Error('PTA core doit être chargé avant dashboard.js');
|
||||
|
||||
const { utils } = PTA;
|
||||
const { readJsonResponse, apiErrorMessage, escapeHtml, formatDuration, formatDate } = utils;
|
||||
|
||||
const elements = {
|
||||
week: document.querySelector('#dashboard-week'),
|
||||
weekLabel: document.querySelector('#dashboard-week-label'),
|
||||
weekContext: document.querySelector('#dashboard-week-context'),
|
||||
refresh: document.querySelector('#dashboard-refresh'),
|
||||
message: document.querySelector('#dashboard-message'),
|
||||
loading: document.querySelector('#dashboard-loading'),
|
||||
|
||||
pendingCount: document.querySelector('#dashboard-pending-count'),
|
||||
pendingDetail: document.querySelector('#dashboard-pending-detail'),
|
||||
pendingTile: document.querySelector('#dashboard-tile-pending'),
|
||||
pendingList: document.querySelector('#dashboard-pending-list'),
|
||||
pendingEmpty: document.querySelector('#dashboard-pending-empty'),
|
||||
|
||||
coverageCount: document.querySelector('#dashboard-coverage-count'),
|
||||
coverageDetail: document.querySelector('#dashboard-coverage-detail'),
|
||||
coverageTile: document.querySelector('#dashboard-tile-coverage'),
|
||||
coverageList: document.querySelector('#dashboard-coverage-list'),
|
||||
coverageEmpty: document.querySelector('#dashboard-coverage-empty'),
|
||||
coverageLink: document.querySelector('#dashboard-coverage-link'),
|
||||
coverageUnconfigured: document.querySelector('#dashboard-coverage-unconfigured'),
|
||||
|
||||
quotaCount: document.querySelector('#dashboard-quota-count'),
|
||||
quotaDetail: document.querySelector('#dashboard-quota-detail'),
|
||||
quotaTile: document.querySelector('#dashboard-tile-quota'),
|
||||
quotaSubtitle: document.querySelector('#dashboard-quota-subtitle'),
|
||||
quotaAgents: document.querySelector('#dashboard-quota-agents'),
|
||||
quotaEmptyAgents: document.querySelector('#dashboard-quota-empty'),
|
||||
quotaBody: document.querySelector('#dashboard-quota-body'),
|
||||
quotaEmptyState: document.querySelector('#dashboard-quota-empty-state'),
|
||||
|
||||
setupCount: document.querySelector('#dashboard-setup-count'),
|
||||
setupDetail: document.querySelector('#dashboard-setup-detail'),
|
||||
setupTile: document.querySelector('#dashboard-tile-setup'),
|
||||
|
||||
navBadge: document.querySelector('#pending-validation-tab-badge'),
|
||||
};
|
||||
|
||||
let pendingItems = [];
|
||||
let loading = false;
|
||||
|
||||
function setMessage(text = '', type = 'info') {
|
||||
if (!elements.message) return;
|
||||
elements.message.className = text ? `message message-${type}` : 'message';
|
||||
elements.message.textContent = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Une tuile est neutre quand il n'y a rien à faire, alertante dès qu'un
|
||||
* compteur remonte. La couleur ne dit rien de plus que le chiffre : elle
|
||||
* évite juste d'avoir à lire les quatre tuiles pour savoir où agir.
|
||||
*/
|
||||
function setTileTone(tile, count) {
|
||||
if (!tile) return;
|
||||
tile.classList.toggle('is-alert', Number(count) > 0);
|
||||
tile.classList.toggle('is-clear', Number(count) === 0);
|
||||
}
|
||||
|
||||
function plural(count, singular, pluralForm) {
|
||||
return Number(count) > 1 ? pluralForm : singular;
|
||||
}
|
||||
|
||||
function weekParam() {
|
||||
return elements.week?.value || '';
|
||||
}
|
||||
|
||||
function weekValueOf(item) {
|
||||
return `${item.annee}-W${String(item.numero_semaine).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function setNavBadge(count) {
|
||||
if (!elements.navBadge) return;
|
||||
elements.navBadge.textContent = String(count);
|
||||
elements.navBadge.hidden = Number(count) === 0;
|
||||
elements.navBadge.setAttribute(
|
||||
'aria-label',
|
||||
`${count} planning${Number(count) > 1 ? 's' : ''} en attente de validation`
|
||||
);
|
||||
}
|
||||
|
||||
function renderWeek(week) {
|
||||
if (!week) return;
|
||||
const contexteLabel = {
|
||||
PERISCOLAIRE: 'Semaine scolaire — contexte périscolaire',
|
||||
EXTRASCOLAIRE: 'Semaine de vacances — contexte extrascolaire',
|
||||
MIXTE: 'Semaine à cheval entre période scolaire et vacances',
|
||||
}[week.contexte] || '';
|
||||
|
||||
if (elements.weekLabel) {
|
||||
elements.weekLabel.textContent =
|
||||
`Semaine ${week.numero} · du ${formatDate(week.date_debut)} au ${formatDate(week.date_fin)}`;
|
||||
}
|
||||
if (elements.weekContext) {
|
||||
const vacances = Array.isArray(week.vacances_libelles) ? week.vacances_libelles : [];
|
||||
const suffix = vacances.length ? ` (${vacances.join(', ')})` : '';
|
||||
elements.weekContext.textContent = contexteLabel ? `${contexteLabel}${suffix}` : '';
|
||||
elements.weekContext.hidden = !contexteLabel;
|
||||
}
|
||||
if (elements.coverageLink) {
|
||||
elements.coverageLink.href = `coverage.php?week=${encodeURIComponent(week.valeur)}`;
|
||||
}
|
||||
if (elements.coverageTile) {
|
||||
elements.coverageTile.href = `coverage.php?week=${encodeURIComponent(week.valeur)}`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderPending(validation) {
|
||||
const count = Number(validation.count || 0);
|
||||
pendingItems = Array.isArray(validation.apercu) ? validation.apercu : [];
|
||||
|
||||
setNavBadge(count);
|
||||
setTileTone(elements.pendingTile, count);
|
||||
if (elements.pendingCount) elements.pendingCount.textContent = String(count);
|
||||
if (elements.pendingDetail) {
|
||||
elements.pendingDetail.textContent = count === 0
|
||||
? 'Aucun brouillon en attente'
|
||||
: `${formatDuration(Number(validation.minutes_decomptees || 0))} décomptées · `
|
||||
+ `${validation.agent_count} ${plural(validation.agent_count, 'agent', 'agents')} · `
|
||||
+ `${validation.structure_count} ${plural(validation.structure_count, 'lieu', 'lieux')}`;
|
||||
}
|
||||
|
||||
if (elements.pendingEmpty) elements.pendingEmpty.hidden = count !== 0;
|
||||
if (!elements.pendingList) return;
|
||||
|
||||
elements.pendingList.innerHTML = pendingItems.map((item) => `
|
||||
<li class="dashboard-list-item">
|
||||
<div class="dashboard-list-main">
|
||||
<strong>${escapeHtml(item.agent_prenom)} ${escapeHtml(item.agent_nom)}</strong>
|
||||
<small>${escapeHtml(item.structure_nom)} · semaine ${Number(item.numero_semaine)} du ${formatDate(item.date_debut)}</small>
|
||||
</div>
|
||||
<div class="dashboard-list-meta">
|
||||
<span>${Number(item.nombre_creneaux)} ${plural(item.nombre_creneaux, 'créneau', 'créneaux')}</span>
|
||||
<strong>${formatDuration(Number(item.total_minutes || 0))}</strong>
|
||||
</div>
|
||||
<button class="button button-success dashboard-list-action" type="button" data-planning-id="${Number(item.id_planning)}">
|
||||
Contrôler
|
||||
</button>
|
||||
</li>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function renderCoverage(coverage, week, perimetre) {
|
||||
const gapCount = Number(coverage.gap_count || 0);
|
||||
const unconfigured = Number(coverage.unconfigured_count || 0);
|
||||
// Sans aucun lieu enregistré, « tous les minimums sont atteints » serait
|
||||
// vrai mais trompeur : il n'y a simplement rien à contrôler.
|
||||
const sansLieu = Number(perimetre?.structures || 0) === 0;
|
||||
|
||||
setTileTone(elements.coverageTile, gapCount);
|
||||
setTileTone(elements.setupTile, unconfigured);
|
||||
|
||||
if (elements.coverageCount) elements.coverageCount.textContent = String(gapCount);
|
||||
if (elements.coverageDetail) {
|
||||
elements.coverageDetail.textContent = gapCount === 0
|
||||
? (sansLieu ? 'Aucun lieu d’affectation enregistré' : 'Tous les minimums sont atteints')
|
||||
: `${formatDuration(Number(coverage.gap_minutes || 0))} non couvertes · `
|
||||
+ `${coverage.structure_count} ${plural(coverage.structure_count, 'lieu concerné', 'lieux concernés')}`;
|
||||
}
|
||||
if (elements.setupCount) elements.setupCount.textContent = String(unconfigured);
|
||||
if (elements.setupDetail) {
|
||||
elements.setupDetail.textContent = unconfigured === 0
|
||||
? (sansLieu ? 'Aucun lieu à paramétrer pour l’instant' : 'Tous les lieux ont des horaires attendus')
|
||||
: 'Aucun minimum d’agents n’y est contrôlé';
|
||||
}
|
||||
|
||||
const items = Array.isArray(coverage.apercu) ? coverage.apercu : [];
|
||||
if (elements.coverageEmpty) elements.coverageEmpty.hidden = items.length !== 0;
|
||||
if (elements.coverageList) {
|
||||
const weekValue = week?.valeur || '';
|
||||
elements.coverageList.innerHTML = items.map((gap) => {
|
||||
const href = `coverage.php?week=${encodeURIComponent(weekValue)}&structure_id=${Number(gap.id_structure)}`;
|
||||
return `
|
||||
<li class="dashboard-list-item">
|
||||
<div class="dashboard-list-main">
|
||||
<strong>${escapeHtml(gap.structure_nom)}</strong>
|
||||
<small>${escapeHtml(gap.jour_libelle)} ${formatDate(gap.date)} · ${escapeHtml(gap.heure_debut)} → ${escapeHtml(gap.heure_fin)}</small>
|
||||
</div>
|
||||
<div class="dashboard-list-meta">
|
||||
<span>${Number(gap.agents_planifies)} / ${Number(gap.minimum_agents)} agents</span>
|
||||
<strong class="dashboard-gap-count">−${Number(gap.agents_manquants)}</strong>
|
||||
</div>
|
||||
<a class="button button-secondary dashboard-list-action" href="${href}">Analyser</a>
|
||||
</li>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
if (elements.coverageUnconfigured) {
|
||||
const list = Array.isArray(coverage.unconfigured) ? coverage.unconfigured : [];
|
||||
if (list.length === 0) {
|
||||
elements.coverageUnconfigured.hidden = true;
|
||||
elements.coverageUnconfigured.textContent = '';
|
||||
} else {
|
||||
const names = list.map((structure) => escapeHtml(structure.nom)).join(', ');
|
||||
const reste = unconfigured - list.length;
|
||||
elements.coverageUnconfigured.innerHTML =
|
||||
`<strong>Non contrôlés :</strong> ${names}${reste > 0 ? ` et ${reste} autre${reste > 1 ? 's' : ''}` : ''}. `
|
||||
+ 'Définissez leurs horaires de couverture dans l’administration.';
|
||||
elements.coverageUnconfigured.hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderQuota(quota) {
|
||||
const overCount = Number(quota.depassement_count || 0);
|
||||
setTileTone(elements.quotaTile, overCount);
|
||||
|
||||
if (elements.quotaCount) elements.quotaCount.textContent = String(overCount);
|
||||
if (elements.quotaDetail) {
|
||||
elements.quotaDetail.textContent = overCount === 0
|
||||
? (Number(quota.agent_count || 0) === 0
|
||||
? 'Aucun agent actif à suivre'
|
||||
: `Aucun dépassement sur ${quota.annee}`)
|
||||
: `Sur ${quota.agent_count} ${plural(quota.agent_count, 'agent suivi', 'agents suivis')} en ${quota.annee}`;
|
||||
}
|
||||
if (elements.quotaTile) {
|
||||
elements.quotaTile.href = `annual.php?year=${Number(quota.annee)}`;
|
||||
}
|
||||
if (elements.quotaSubtitle) {
|
||||
elements.quotaSubtitle.textContent =
|
||||
`Année civile ${quota.annee} · heures validées et brouillon comprises, motifs décomptés uniquement.`;
|
||||
}
|
||||
if (elements.quotaAgents) elements.quotaAgents.textContent = String(quota.agent_count || 0);
|
||||
if (elements.quotaEmptyAgents) elements.quotaEmptyAgents.textContent = String(quota.sans_heure_count || 0);
|
||||
|
||||
const items = Array.isArray(quota.apercu) ? quota.apercu : [];
|
||||
if (elements.quotaEmptyState) elements.quotaEmptyState.hidden = items.length !== 0;
|
||||
if (!elements.quotaBody) return;
|
||||
|
||||
elements.quotaBody.innerHTML = items.map((agent) => {
|
||||
const over = Number(agent.minutes_restantes) < 0;
|
||||
const rate = Number(agent.taux_consommation || 0);
|
||||
const href = `annual.php?agent_id=${Number(agent.id_agent)}&year=${Number(quota.annee)}`;
|
||||
return `
|
||||
<tr class="${over ? 'is-over-quota' : ''}">
|
||||
<td>
|
||||
<strong>${escapeHtml(agent.prenom)} ${escapeHtml(agent.nom)}</strong>
|
||||
<small>${escapeHtml(agent.poste_libelle || 'Poste non renseigné')}</small>
|
||||
</td>
|
||||
<td>${escapeHtml(agent.structure_nom || 'Non rattaché')}</td>
|
||||
<td>
|
||||
<strong>${formatDuration(Number(agent.quota_cible_minutes || 0))}</strong>
|
||||
<small>quotité ${Number(agent.quotite_travail)} %</small>
|
||||
</td>
|
||||
<td>
|
||||
<strong>${formatDuration(Number(agent.minutes_affectees || 0))}</strong>
|
||||
<small>${formatDuration(Number(agent.minutes_brouillon || 0))} en brouillon</small>
|
||||
</td>
|
||||
<td class="dashboard-quota-gauge-cell">
|
||||
<progress class="dashboard-quota-gauge${over ? ' is-over' : ''}" max="100" value="${Math.min(100, Math.max(0, rate))}" aria-hidden="true"></progress>
|
||||
<span>${rate} %</span>
|
||||
</td>
|
||||
<td class="dashboard-quota-action-cell">
|
||||
<a class="button button-secondary" href="${href}">Ouvrir</a>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function openPendingPlanning(item) {
|
||||
if (!item) return;
|
||||
const params = new URLSearchParams({
|
||||
structure_id: String(item.id_structure),
|
||||
agent_id: String(item.id_agent),
|
||||
week: weekValueOf(item),
|
||||
focus: 'validation',
|
||||
notice: `Planning de ${item.agent_prenom} ${item.agent_nom} ouvert depuis le tableau de bord.`,
|
||||
});
|
||||
window.location.href = `planning.php?${params.toString()}`;
|
||||
}
|
||||
|
||||
async function load(options = {}) {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
if (!options.silent) setMessage('');
|
||||
if (elements.loading) elements.loading.hidden = false;
|
||||
if (elements.refresh) elements.refresh.disabled = true;
|
||||
|
||||
try {
|
||||
const query = new URLSearchParams();
|
||||
const week = weekParam();
|
||||
if (week) query.set('week', week);
|
||||
|
||||
const response = await fetch(`api/dashboard_summary.php?${query.toString()}`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const data = await readJsonResponse(response);
|
||||
if (!response.ok) throw new Error(apiErrorMessage(data, 'Impossible de charger le tableau de bord.'));
|
||||
|
||||
renderWeek(data.semaine);
|
||||
renderPending(data.validation || {});
|
||||
renderCoverage(data.couverture || {}, data.semaine, data.perimetre);
|
||||
renderQuota(data.quota || {});
|
||||
} catch (error) {
|
||||
setMessage(error.message, 'error');
|
||||
} finally {
|
||||
loading = false;
|
||||
if (elements.loading) elements.loading.hidden = true;
|
||||
if (elements.refresh) elements.refresh.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
elements.refresh?.addEventListener('click', () => load());
|
||||
elements.week?.addEventListener('change', () => load());
|
||||
elements.pendingList?.addEventListener('click', (event) => {
|
||||
const trigger = event.target.closest('[data-planning-id]');
|
||||
if (!trigger) return;
|
||||
const id = Number(trigger.dataset.planningId);
|
||||
openPendingPlanning(pendingItems.find((item) => Number(item.id_planning) === id));
|
||||
});
|
||||
|
||||
load({ silent: true });
|
||||
}
|
||||
|
||||
PTA.modules.dashboard = { init, load, refresh: load };
|
||||
})();
|
||||
@@ -15,6 +15,14 @@
|
||||
if (!planning) return;
|
||||
|
||||
const { structureSelect, agentSelect, weekInput, validateButton } = PTA.elements;
|
||||
|
||||
// Un lien profond qui désigne une semaine précise (file de validation,
|
||||
// tableau de bord, vue annuelle) doit ouvrir la saisie semaine par
|
||||
// semaine, et non l'éditeur de semaine type proposé par défaut.
|
||||
if (params.week || params.focus) {
|
||||
PTA.modules.weekTemplateEditor?.setMode?.('week');
|
||||
}
|
||||
|
||||
if (params.structureId && structureSelect) {
|
||||
structureSelect.value = String(params.structureId);
|
||||
await planning.loadAgents();
|
||||
@@ -73,8 +81,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pastille « À valider » de la barre de navigation.
|
||||
*
|
||||
* Elle n'était alimentée que sur la page « À valider » elle-même, donc
|
||||
* invisible là où elle sert : depuis n'importe quel écran, le service voit
|
||||
* maintenant si des brouillons attendent. La requête est volontairement
|
||||
* réduite à un compteur, et son échec est silencieux — une commodité ne
|
||||
* doit jamais empêcher une page de fonctionner.
|
||||
*/
|
||||
async function refreshNavigationCounters() {
|
||||
const badge = document.querySelector('#pending-validation-tab-badge');
|
||||
if (!badge) return;
|
||||
// Les écrans qui chargent déjà ce compteur s'en chargent eux-mêmes.
|
||||
if (PTA.modules.pendingValidation || PTA.modules.dashboard) return;
|
||||
if (!PTA.config?.permissions?.can_view_pending) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('api/dashboard_summary.php?scope=badges', {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
if (!response.ok) return;
|
||||
const data = await PTA.utils.readJsonResponse(response);
|
||||
const count = Number(data?.validation?.count || 0);
|
||||
badge.textContent = String(count);
|
||||
badge.hidden = count === 0;
|
||||
badge.setAttribute('aria-label', `${count} planning${count > 1 ? 's' : ''} en attente de validation`);
|
||||
} catch (error) {
|
||||
badge.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
initialisePlanning();
|
||||
initialiseStructureOverview();
|
||||
initialiseAgentOverview();
|
||||
initialiseCoverage();
|
||||
refreshNavigationCounters();
|
||||
})();
|
||||
|
||||
@@ -110,8 +110,37 @@
|
||||
updateAgentPdfButton();
|
||||
}
|
||||
|
||||
/**
|
||||
* Motif proposé par défaut sur une nouvelle plage : le temps de travail, très
|
||||
* majoritaire à la saisie. On se rabat sur le premier motif décomptant le quota
|
||||
* si le référentiel ne contient pas le code TRAVAIL.
|
||||
*/
|
||||
function defaultMotifId() {
|
||||
const motifs = window.PTA_CONFIG?.motifs || [];
|
||||
const motif = motifs.find((item) => String(item.code).toUpperCase() === 'TRAVAIL')
|
||||
|| motifs.find((item) => item.quota)
|
||||
|| motifs[0];
|
||||
return motif ? Number(motif.id) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Un agent sans droit à l'enveloppe de formation ne peut pas recevoir le motif
|
||||
* « Formation ». Le droit vaut tant que l'agent n'est pas chargé : on ne retire
|
||||
* jamais une possibilité sur une donnée absente.
|
||||
*/
|
||||
function agentHasTrainingRight() {
|
||||
return Number(state.currentAgent?.droit_enveloppe_formation ?? 1) !== 0;
|
||||
}
|
||||
|
||||
function isMotifAllowedForAgent(motif) {
|
||||
return agentHasTrainingRight() || String(motif.code).toUpperCase() !== 'FORMATION';
|
||||
}
|
||||
|
||||
function motifOptionsHtml(selectedMotifId = null) {
|
||||
return (window.PTA_CONFIG?.motifs || [])
|
||||
// Un motif interdit reste proposé s'il est déjà celui de la plage :
|
||||
// le retirer changerait silencieusement le motif d'une saisie existante.
|
||||
.filter((motif) => isMotifAllowedForAgent(motif) || Number(motif.id) === Number(selectedMotifId))
|
||||
.map((motif) => {
|
||||
const selected = Number(motif.id) === Number(selectedMotifId) ? ' selected' : '';
|
||||
const quotaLabel = motif.quota ? ' · décompte quota' : ' · hors quota';
|
||||
@@ -122,13 +151,16 @@
|
||||
|
||||
function timeRangeHtml(dayLabel, index = 0, selectedMotifId = null) {
|
||||
const suffix = `${dayLabel} plage ${index + 1}`;
|
||||
const fallbackMotifId = defaultMotifId();
|
||||
const motifId = selectedMotifId ?? fallbackMotifId;
|
||||
const placeholder = fallbackMotifId === null ? '<option value="">Choisir un motif</option>' : '';
|
||||
return `
|
||||
<div class="weekly-time-range">
|
||||
<label class="weekly-range-motif-field">
|
||||
<span>Motif</span>
|
||||
<select class="weekly-range-motif" aria-label="Motif ${escapeHtml(suffix)}">
|
||||
<option value="">Choisir un motif</option>
|
||||
${motifOptionsHtml(selectedMotifId)}
|
||||
${placeholder}
|
||||
${motifOptionsHtml(motifId)}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
@@ -649,6 +681,7 @@
|
||||
state.entries = [];
|
||||
state.otherStructureEntries = [];
|
||||
state.currentStructure = null;
|
||||
state.currentAgent = null;
|
||||
state.planningId = null;
|
||||
state.quota = null;
|
||||
state.savedCurrentCountedMinutes = 0;
|
||||
@@ -710,6 +743,7 @@
|
||||
state.entries = [];
|
||||
state.otherStructureEntries = [];
|
||||
state.currentStructure = null;
|
||||
state.currentAgent = null;
|
||||
state.planningId = null;
|
||||
state.savedCurrentCountedMinutes = 0;
|
||||
setStatus(null);
|
||||
@@ -728,6 +762,7 @@
|
||||
|
||||
state.quota = data.quota || null;
|
||||
state.currentStructure = data.current_structure || null;
|
||||
state.currentAgent = data.agent || null;
|
||||
const calendarByDate = new Map((data.calendar_days || []).map((day) => [day.date, day]));
|
||||
state.weekDays = state.weekDays.map((day) => ({ ...day, ...(calendarByDate.get(day.date) || {}) }));
|
||||
state.otherStructureEntries = (data.other_entries || []).map((entry) => ({
|
||||
@@ -819,6 +854,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMotifAllowedForAgent(motif)) {
|
||||
errors.push(`${day?.label || row.dataset.date} ${label} : le motif « ${motif.label} » n’est pas ouvert à cet agent, qui n’a pas droit à l’enveloppe de formation.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!start || !end) {
|
||||
errors.push(`${day?.label || row.dataset.date} ${label} : renseignez l’heure de début et l’heure de fin.`);
|
||||
return;
|
||||
|
||||
@@ -20,6 +20,17 @@
|
||||
return `<article class="summary-card"><span>${escapeHtml(label)}</span><strong>${escapeHtml(value)}</strong>${detail ? `<small>${escapeHtml(detail)}</small>` : ''}</article>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* QuotaModel::enrich() renvoie les durées sous forme d'objet
|
||||
* { minutes, heures_decimales, libelle } et non de chaîne. Passer l'objet
|
||||
* tel quel à une interpolation affiche « [object Object] » — et un objet
|
||||
* étant toujours truthy, un `||` ne rattrape jamais le coup. On lit donc
|
||||
* explicitement le libellé, en gardant le nombre de minutes comme repli.
|
||||
*/
|
||||
function quotaLabel(enriched, fallbackMinutes) {
|
||||
return enriched?.libelle || formatDuration(Number(fallbackMinutes || 0));
|
||||
}
|
||||
|
||||
function renderSummary(data) {
|
||||
current = data;
|
||||
const agent = data.agent || {};
|
||||
@@ -37,9 +48,9 @@
|
||||
el('pta-summary-cards').innerHTML = [
|
||||
card('Année civile PTA', `${formatDate(quota.date_debut_periode)} → ${formatDate(quota.date_fin_periode)}`),
|
||||
card('Quotité', `${Number(quota.quotite_travail || 0).toLocaleString('fr-FR')} %`, `Référence : ${formatDuration(Number(quota.quota_reference_minutes || 96420))}`),
|
||||
card('Quota à réaliser', quota.quota_cible || formatDuration(Number(quota.quota_cible_minutes || 0))),
|
||||
card('Déjà affecté', quota.affectees || formatDuration(Number(quota.minutes_affectees || 0))),
|
||||
card('Reste à affecter', quota.restantes || formatDuration(Number(quota.minutes_restantes || 0))),
|
||||
card('Quota à réaliser', quotaLabel(quota.quota_cible, quota.quota_cible_minutes)),
|
||||
card('Déjà affecté', quotaLabel(quota.affectees, quota.minutes_affectees)),
|
||||
card('Reste à affecter', quotaLabel(quota.restantes, quota.minutes_restantes)),
|
||||
card('Formation', `${counters.formation_duree || '0 h 00'} / ${counters.formation_cible_duree || '0 h 00'}`),
|
||||
card('Congés annuels', `${Number(counters.conges_annuels_jours || 0)} / ${Number(counters.conges_annuels_cible || 25)} jours`),
|
||||
card('Fractionnement', `${Number(counters.jours_fractionnement || 0)} / ${Number(counters.jours_fractionnement_cible || 2)} jours`),
|
||||
|
||||
579
assets/js/week-template-editor.js
Normal file
579
assets/js/week-template-editor.js
Normal file
@@ -0,0 +1,579 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const PTA = window.PTA;
|
||||
if (!PTA) throw new Error('PTA core doit être chargé avant week-template-editor.js');
|
||||
|
||||
const { state } = PTA;
|
||||
const { structureSelect, agentSelect, weekInput } = PTA.elements;
|
||||
const { escapeHtml, readJsonResponse, apiErrorMessage, formatDuration, timeToMinutes, motifInfo } = PTA.utils;
|
||||
|
||||
const panel = document.querySelector('#template-mode-panel');
|
||||
const weekPanel = document.querySelector('#week-mode-panel');
|
||||
const modeTemplateButton = document.querySelector('#editor-mode-template');
|
||||
const modeWeekButton = document.querySelector('#editor-mode-week');
|
||||
|
||||
const templateSelect = document.querySelector('#template-editor-select');
|
||||
const nameInput = document.querySelector('#template-editor-name');
|
||||
const gridElement = document.querySelector('#template-editor-grid');
|
||||
const emptyElement = document.querySelector('#template-editor-empty');
|
||||
const messageElement = document.querySelector('#template-editor-message');
|
||||
const totalElement = document.querySelector('#template-editor-total');
|
||||
const totalDetailElement = document.querySelector('#template-editor-total-detail');
|
||||
|
||||
const saveButton = document.querySelector('#template-editor-save');
|
||||
const deleteButton = document.querySelector('#template-editor-delete');
|
||||
const applyPeriodButton = document.querySelector('#template-editor-apply-period');
|
||||
const applyWeekButton = document.querySelector('#template-editor-apply-week');
|
||||
|
||||
const DAYS = [
|
||||
{ weekday: 1, label: 'Lundi' },
|
||||
{ weekday: 2, label: 'Mardi' },
|
||||
{ weekday: 3, label: 'Mercredi' },
|
||||
{ weekday: 4, label: 'Jeudi' },
|
||||
{ weekday: 5, label: 'Vendredi' },
|
||||
];
|
||||
|
||||
/** Plages de la semaine type en cours d'édition, indexées par jour. */
|
||||
let draft = new Map();
|
||||
let templates = [];
|
||||
let currentTemplateId = null;
|
||||
let loading = false;
|
||||
|
||||
function setMessage(text = '', type = 'info') {
|
||||
if (!messageElement) return;
|
||||
messageElement.className = text ? `message message-${type}` : 'message';
|
||||
messageElement.textContent = text;
|
||||
}
|
||||
|
||||
function agentId() {
|
||||
return Number(agentSelect?.value || 0) || null;
|
||||
}
|
||||
|
||||
function defaultStructureId() {
|
||||
const selected = Number(structureSelect?.value || 0);
|
||||
if (selected) return selected;
|
||||
const first = structureSelect?.querySelector('option[value]:not([value=""])');
|
||||
return first ? Number(first.value) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Un agent sans droit à l'enveloppe de formation ne peut pas recevoir le
|
||||
* motif « Formation ». Même règle qu'à la saisie semaine par semaine : le
|
||||
* droit vaut tant que l'agent n'est pas chargé, on ne retire jamais une
|
||||
* possibilité sur une donnée absente.
|
||||
*/
|
||||
function agentHasTrainingRight() {
|
||||
return Number(state.currentAgent?.droit_enveloppe_formation ?? 1) !== 0;
|
||||
}
|
||||
|
||||
function motifs() {
|
||||
return window.PTA_CONFIG?.motifs || [];
|
||||
}
|
||||
|
||||
function defaultMotifId() {
|
||||
const list = motifs();
|
||||
const motif = list.find((item) => String(item.code).toUpperCase() === 'TRAVAIL')
|
||||
|| list.find((item) => item.quota)
|
||||
|| list[0];
|
||||
return motif ? Number(motif.id) : null;
|
||||
}
|
||||
|
||||
function motifOptionsHtml(selectedMotifId = null) {
|
||||
return motifs()
|
||||
// Un motif interdit reste proposé s'il est déjà celui de la plage :
|
||||
// le retirer changerait silencieusement une saisie existante.
|
||||
.filter((motif) => agentHasTrainingRight()
|
||||
|| String(motif.code).toUpperCase() !== 'FORMATION'
|
||||
|| Number(motif.id) === Number(selectedMotifId))
|
||||
.map((motif) => {
|
||||
const selected = Number(motif.id) === Number(selectedMotifId) ? ' selected' : '';
|
||||
const quotaLabel = motif.quota ? ' · décompte quota' : ' · hors quota';
|
||||
return `<option value="${Number(motif.id)}"${selected}>${escapeHtml(motif.label)}${quotaLabel}</option>`;
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
function structureOptionsHtml(selectedStructureId = null) {
|
||||
return [...(structureSelect?.querySelectorAll('option[value]:not([value=""])') || [])]
|
||||
.map((option) => {
|
||||
const selected = Number(option.value) === Number(selectedStructureId) ? ' selected' : '';
|
||||
return `<option value="${Number(option.value)}"${selected}>${escapeHtml(option.textContent.trim())}</option>`;
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
function copyTargetOptionsHtml(weekday) {
|
||||
const others = DAYS.filter((day) => day.weekday !== weekday);
|
||||
return [
|
||||
'<option value="">Copier vers…</option>',
|
||||
...others.map((day) => `<option value="${day.weekday}">${escapeHtml(day.label)}</option>`),
|
||||
'<option value="all">Tous les autres jours</option>',
|
||||
].join('');
|
||||
}
|
||||
|
||||
function rangesFor(weekday) {
|
||||
return draft.get(weekday) || [];
|
||||
}
|
||||
|
||||
function emptyDraft() {
|
||||
const next = new Map();
|
||||
DAYS.forEach((day) => next.set(day.weekday, []));
|
||||
return next;
|
||||
}
|
||||
|
||||
function newRange() {
|
||||
return {
|
||||
heure_debut: '',
|
||||
heure_fin: '',
|
||||
id_motif: defaultMotifId(),
|
||||
id_structure: defaultStructureId(),
|
||||
};
|
||||
}
|
||||
|
||||
function rangeMinutes(range) {
|
||||
if (!range.heure_debut || !range.heure_fin) return 0;
|
||||
return Math.max(0, timeToMinutes(range.heure_fin) - timeToMinutes(range.heure_debut));
|
||||
}
|
||||
|
||||
function dayMinutes(weekday) {
|
||||
return rangesFor(weekday).reduce((total, range) => total + rangeMinutes(range), 0);
|
||||
}
|
||||
|
||||
function totals() {
|
||||
let all = 0;
|
||||
let counted = 0;
|
||||
DAYS.forEach((day) => {
|
||||
rangesFor(day.weekday).forEach((range) => {
|
||||
const minutes = rangeMinutes(range);
|
||||
all += minutes;
|
||||
if (motifInfo(range.id_motif)?.quota) counted += minutes;
|
||||
});
|
||||
});
|
||||
return { all, counted };
|
||||
}
|
||||
|
||||
function rangeHtml(weekday, index, range) {
|
||||
const label = `${DAYS.find((day) => day.weekday === weekday)?.label || 'Jour'} plage ${index + 1}`;
|
||||
return `
|
||||
<div class="template-range" data-weekday="${weekday}" data-index="${index}">
|
||||
<label class="template-range-field template-range-field-motif">
|
||||
<span>Motif</span>
|
||||
<select class="template-range-motif" aria-label="Motif ${escapeHtml(label)}">
|
||||
${motifOptionsHtml(range.id_motif)}
|
||||
</select>
|
||||
</label>
|
||||
<label class="template-range-field">
|
||||
<span>Début</span>
|
||||
<input class="template-range-start" type="time" step="900" value="${escapeHtml(range.heure_debut)}" aria-label="Début ${escapeHtml(label)}">
|
||||
</label>
|
||||
<span class="template-range-separator" aria-hidden="true">→</span>
|
||||
<label class="template-range-field">
|
||||
<span>Fin</span>
|
||||
<input class="template-range-end" type="time" step="900" value="${escapeHtml(range.heure_fin)}" aria-label="Fin ${escapeHtml(label)}">
|
||||
</label>
|
||||
<label class="template-range-field template-range-field-structure">
|
||||
<span>Lieu</span>
|
||||
<select class="template-range-structure" aria-label="Lieu ${escapeHtml(label)}">
|
||||
${structureOptionsHtml(range.id_structure)}
|
||||
</select>
|
||||
</label>
|
||||
<button type="button" class="button button-ghost template-range-remove" aria-label="Supprimer ${escapeHtml(label)}" title="Supprimer cette plage">×</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function render() {
|
||||
if (!gridElement) return;
|
||||
|
||||
const ready = Boolean(agentId());
|
||||
if (emptyElement) emptyElement.hidden = ready;
|
||||
gridElement.hidden = !ready;
|
||||
|
||||
if (ready) {
|
||||
gridElement.innerHTML = DAYS.map((day) => {
|
||||
const ranges = rangesFor(day.weekday);
|
||||
const minutes = dayMinutes(day.weekday);
|
||||
return `
|
||||
<article class="template-day${ranges.length === 0 ? ' is-empty' : ''}" data-weekday="${day.weekday}">
|
||||
<header class="template-day-header">
|
||||
<strong>${escapeHtml(day.label)}</strong>
|
||||
<span class="template-day-total">${minutes > 0 ? formatDuration(minutes) : '—'}</span>
|
||||
</header>
|
||||
<div class="template-day-ranges">
|
||||
${ranges.length === 0
|
||||
? '<p class="template-day-empty">Aucune plage — jour non travaillé.</p>'
|
||||
: ranges.map((range, index) => rangeHtml(day.weekday, index, range)).join('')}
|
||||
</div>
|
||||
<footer class="template-day-actions">
|
||||
<button type="button" class="button button-secondary template-day-add" data-weekday="${day.weekday}">+ Ajouter une plage</button>
|
||||
<label class="template-day-copy-field">
|
||||
<span class="visually-hidden">Copier ${escapeHtml(day.label)} vers un autre jour</span>
|
||||
<select class="template-day-copy" data-weekday="${day.weekday}" aria-label="Copier ${escapeHtml(day.label)} vers un autre jour"${ranges.length === 0 ? ' disabled' : ''}>
|
||||
${copyTargetOptionsHtml(day.weekday)}
|
||||
</select>
|
||||
</label>
|
||||
</footer>
|
||||
</article>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
const { all, counted } = totals();
|
||||
if (totalElement) totalElement.textContent = formatDuration(all);
|
||||
if (totalDetailElement) totalDetailElement.textContent = `dont ${formatDuration(counted)} décomptées`;
|
||||
|
||||
refreshButtons();
|
||||
}
|
||||
|
||||
function hasAnyRange() {
|
||||
return DAYS.some((day) => rangesFor(day.weekday).length > 0);
|
||||
}
|
||||
|
||||
function refreshButtons() {
|
||||
const ready = Boolean(agentId());
|
||||
const named = Boolean(nameInput?.value.trim());
|
||||
|
||||
if (templateSelect) templateSelect.disabled = !ready;
|
||||
if (nameInput) nameInput.disabled = !ready;
|
||||
if (saveButton) saveButton.disabled = !ready || !named || !hasAnyRange() || loading;
|
||||
if (deleteButton) deleteButton.disabled = !ready || currentTemplateId === null || loading;
|
||||
// Dupliquer suppose un modèle déjà enregistré : on ne duplique jamais un
|
||||
// brouillon d'écran, seulement ce qui est réellement en base.
|
||||
if (applyPeriodButton) applyPeriodButton.disabled = !ready || currentTemplateId === null || loading;
|
||||
if (applyWeekButton) applyWeekButton.disabled = !ready || currentTemplateId === null || loading;
|
||||
}
|
||||
|
||||
function renderTemplateSelect() {
|
||||
if (!templateSelect) return;
|
||||
const options = ['<option value="">➕ Nouvelle semaine type</option>'];
|
||||
templates.forEach((template) => {
|
||||
const selected = Number(template.id) === Number(currentTemplateId) ? ' selected' : '';
|
||||
const detail = `${template.entry_count} plage${template.entry_count > 1 ? 's' : ''}`;
|
||||
options.push(`<option value="${Number(template.id)}"${selected}>${escapeHtml(template.name)} — ${detail}</option>`);
|
||||
});
|
||||
templateSelect.innerHTML = options.join('');
|
||||
}
|
||||
|
||||
async function loadTemplates() {
|
||||
const agent = agentId();
|
||||
if (!agent) {
|
||||
templates = [];
|
||||
renderTemplateSelect();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`api/week_templates.php?agent_id=${agent}`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const data = await readJsonResponse(response);
|
||||
if (!response.ok) throw new Error(apiErrorMessage(data, 'Impossible de charger les semaines types.'));
|
||||
templates = Array.isArray(data.templates) ? data.templates : [];
|
||||
renderTemplateSelect();
|
||||
} catch (error) {
|
||||
setMessage(error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function openTemplate(templateId) {
|
||||
const agent = agentId();
|
||||
if (!agent || !templateId) {
|
||||
currentTemplateId = null;
|
||||
draft = emptyDraft();
|
||||
if (nameInput) nameInput.value = '';
|
||||
render();
|
||||
return;
|
||||
}
|
||||
|
||||
loading = true;
|
||||
refreshButtons();
|
||||
try {
|
||||
const response = await fetch(`api/week_template.php?agent_id=${agent}&template_id=${Number(templateId)}`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
const data = await readJsonResponse(response);
|
||||
if (!response.ok) throw new Error(apiErrorMessage(data, 'Impossible d’ouvrir cette semaine type.'));
|
||||
|
||||
currentTemplateId = Number(data.template.id);
|
||||
if (nameInput) nameInput.value = data.template.name;
|
||||
|
||||
draft = emptyDraft();
|
||||
(data.entries || []).forEach((entry) => {
|
||||
const weekday = Number(entry.jour_semaine);
|
||||
if (!draft.has(weekday)) return;
|
||||
draft.get(weekday).push({
|
||||
heure_debut: entry.heure_debut,
|
||||
heure_fin: entry.heure_fin,
|
||||
id_motif: Number(entry.id_motif),
|
||||
id_structure: Number(entry.id_structure),
|
||||
});
|
||||
});
|
||||
setMessage('');
|
||||
} catch (error) {
|
||||
setMessage(error.message, 'error');
|
||||
} finally {
|
||||
loading = false;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
/** Lit les valeurs saisies à l'écran dans le brouillon en mémoire. */
|
||||
function syncDraftFromDom() {
|
||||
if (!gridElement || gridElement.hidden) return;
|
||||
const next = emptyDraft();
|
||||
gridElement.querySelectorAll('.template-range').forEach((element) => {
|
||||
const weekday = Number(element.dataset.weekday);
|
||||
if (!next.has(weekday)) return;
|
||||
next.get(weekday).push({
|
||||
heure_debut: element.querySelector('.template-range-start')?.value || '',
|
||||
heure_fin: element.querySelector('.template-range-end')?.value || '',
|
||||
id_motif: Number(element.querySelector('.template-range-motif')?.value || 0) || null,
|
||||
id_structure: Number(element.querySelector('.template-range-structure')?.value || 0) || null,
|
||||
});
|
||||
});
|
||||
draft = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contrôles faits à l'écran pour éviter un aller-retour serveur inutile.
|
||||
* Le serveur revalide tout : ceci n'est qu'une commodité.
|
||||
*/
|
||||
function localValidationError() {
|
||||
for (const day of DAYS) {
|
||||
const ranges = rangesFor(day.weekday);
|
||||
for (const range of ranges) {
|
||||
if (!range.heure_debut || !range.heure_fin) {
|
||||
return `${day.label} : une plage n’a pas d’horaire de début ou de fin.`;
|
||||
}
|
||||
if (timeToMinutes(range.heure_fin) <= timeToMinutes(range.heure_debut)) {
|
||||
return `${day.label} : la fin doit être postérieure au début (${range.heure_debut} → ${range.heure_fin}).`;
|
||||
}
|
||||
if (!range.id_motif || !range.id_structure) {
|
||||
return `${day.label} : chaque plage doit avoir un motif et un lieu d’affectation.`;
|
||||
}
|
||||
}
|
||||
const sorted = [...ranges].sort((a, b) => a.heure_debut.localeCompare(b.heure_debut));
|
||||
for (let index = 1; index < sorted.length; index++) {
|
||||
if (sorted[index].heure_debut < sorted[index - 1].heure_fin) {
|
||||
return `${day.label} : deux plages se chevauchent (${sorted[index - 1].heure_debut}–${sorted[index - 1].heure_fin} et ${sorted[index].heure_debut}–${sorted[index].heure_fin}).`;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function flatEntries() {
|
||||
const entries = [];
|
||||
DAYS.forEach((day) => {
|
||||
rangesFor(day.weekday).forEach((range) => {
|
||||
entries.push({
|
||||
jour_semaine: day.weekday,
|
||||
heure_debut: range.heure_debut,
|
||||
heure_fin: range.heure_fin,
|
||||
id_motif: range.id_motif,
|
||||
id_structure: range.id_structure,
|
||||
});
|
||||
});
|
||||
});
|
||||
return entries;
|
||||
}
|
||||
|
||||
async function save(replace = false) {
|
||||
const agent = agentId();
|
||||
const name = nameInput?.value.trim() || '';
|
||||
if (!agent || !name) return;
|
||||
|
||||
syncDraftFromDom();
|
||||
const error = localValidationError();
|
||||
if (error) {
|
||||
setMessage(error, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
loading = true;
|
||||
refreshButtons();
|
||||
try {
|
||||
const response = await fetch('api/save_week_template_entries.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({
|
||||
csrf_token: window.PTA_CONFIG.csrfToken,
|
||||
agent_id: agent,
|
||||
name,
|
||||
replace,
|
||||
entries: flatEntries(),
|
||||
}),
|
||||
});
|
||||
const data = await readJsonResponse(response);
|
||||
|
||||
if (response.status === 409 && data.code === 'TEMPLATE_EXISTS' && !replace) {
|
||||
loading = false;
|
||||
if (window.confirm(`Une semaine type « ${name} » existe déjà pour cet agent. La remplacer ?`)) {
|
||||
await save(true);
|
||||
return;
|
||||
}
|
||||
setMessage('Enregistrement annulé : le nom est déjà utilisé.', 'warning');
|
||||
refreshButtons();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) throw new Error(apiErrorMessage(data, 'Impossible d’enregistrer la semaine type.'));
|
||||
|
||||
currentTemplateId = Number(data.template.id);
|
||||
setMessage(`${data.message} Elle peut maintenant être dupliquée sur une période.`, 'success');
|
||||
await loadTemplates();
|
||||
renderTemplateSelect();
|
||||
} catch (err) {
|
||||
setMessage(err.message, 'error');
|
||||
} finally {
|
||||
loading = false;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function removeTemplate() {
|
||||
const agent = agentId();
|
||||
if (!agent || currentTemplateId === null) return;
|
||||
const template = templates.find((item) => Number(item.id) === Number(currentTemplateId));
|
||||
if (!window.confirm(`Supprimer définitivement la semaine type « ${template?.name || ''} » ? Les plannings déjà créés ne sont pas affectés.`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading = true;
|
||||
refreshButtons();
|
||||
try {
|
||||
const response = await fetch('api/delete_week_template.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({
|
||||
csrf_token: window.PTA_CONFIG.csrfToken,
|
||||
agent_id: agent,
|
||||
template_id: currentTemplateId,
|
||||
}),
|
||||
});
|
||||
const data = await readJsonResponse(response);
|
||||
if (!response.ok) throw new Error(apiErrorMessage(data, 'Impossible de supprimer la semaine type.'));
|
||||
|
||||
currentTemplateId = null;
|
||||
draft = emptyDraft();
|
||||
if (nameInput) nameInput.value = '';
|
||||
setMessage(data.message || 'Semaine type supprimée.', 'success');
|
||||
await loadTemplates();
|
||||
} catch (error) {
|
||||
setMessage(error.message, 'error');
|
||||
} finally {
|
||||
loading = false;
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
function copyDay(sourceWeekday, target) {
|
||||
syncDraftFromDom();
|
||||
const source = rangesFor(sourceWeekday);
|
||||
if (source.length === 0) return;
|
||||
|
||||
const targets = target === 'all'
|
||||
? DAYS.filter((day) => day.weekday !== sourceWeekday).map((day) => day.weekday)
|
||||
: [Number(target)];
|
||||
|
||||
targets.forEach((weekday) => {
|
||||
draft.set(weekday, source.map((range) => ({ ...range })));
|
||||
});
|
||||
|
||||
const sourceLabel = DAYS.find((day) => day.weekday === sourceWeekday)?.label || 'Ce jour';
|
||||
const targetLabel = target === 'all'
|
||||
? 'tous les autres jours'
|
||||
: (DAYS.find((day) => day.weekday === Number(target))?.label || 'le jour choisi').toLowerCase();
|
||||
setMessage(`${sourceLabel} copié sur ${targetLabel}. Pensez à enregistrer la semaine type.`, 'info');
|
||||
render();
|
||||
}
|
||||
|
||||
function setMode(mode) {
|
||||
const isTemplate = mode === 'template';
|
||||
if (panel) panel.hidden = !isTemplate;
|
||||
if (weekPanel) weekPanel.hidden = isTemplate;
|
||||
modeTemplateButton?.classList.toggle('is-active', isTemplate);
|
||||
modeWeekButton?.classList.toggle('is-active', !isTemplate);
|
||||
modeTemplateButton?.setAttribute('aria-selected', String(isTemplate));
|
||||
modeWeekButton?.setAttribute('aria-selected', String(!isTemplate));
|
||||
}
|
||||
|
||||
function onAgentChanged() {
|
||||
currentTemplateId = null;
|
||||
draft = emptyDraft();
|
||||
if (nameInput) nameInput.value = '';
|
||||
setMessage('');
|
||||
loadTemplates().then(render);
|
||||
}
|
||||
|
||||
function init() {
|
||||
draft = emptyDraft();
|
||||
|
||||
modeTemplateButton?.addEventListener('click', () => setMode('template'));
|
||||
modeWeekButton?.addEventListener('click', () => setMode('week'));
|
||||
|
||||
agentSelect?.addEventListener('change', onAgentChanged);
|
||||
structureSelect?.addEventListener('change', () => {
|
||||
// Le lieu par défaut des nouvelles plages suit la sélection.
|
||||
loadTemplates();
|
||||
});
|
||||
|
||||
templateSelect?.addEventListener('change', (event) => openTemplate(event.target.value));
|
||||
nameInput?.addEventListener('input', refreshButtons);
|
||||
|
||||
gridElement?.addEventListener('click', (event) => {
|
||||
const addButton = event.target.closest('.template-day-add');
|
||||
if (addButton) {
|
||||
syncDraftFromDom();
|
||||
const weekday = Number(addButton.dataset.weekday);
|
||||
draft.get(weekday)?.push(newRange());
|
||||
render();
|
||||
return;
|
||||
}
|
||||
|
||||
const removeButton = event.target.closest('.template-range-remove');
|
||||
if (removeButton) {
|
||||
const range = removeButton.closest('.template-range');
|
||||
syncDraftFromDom();
|
||||
const weekday = Number(range.dataset.weekday);
|
||||
const index = Number(range.dataset.index);
|
||||
draft.get(weekday)?.splice(index, 1);
|
||||
render();
|
||||
}
|
||||
});
|
||||
|
||||
gridElement?.addEventListener('change', (event) => {
|
||||
const copySelect = event.target.closest('.template-day-copy');
|
||||
if (copySelect) {
|
||||
const target = copySelect.value;
|
||||
copySelect.value = '';
|
||||
if (target) copyDay(Number(copySelect.dataset.weekday), target);
|
||||
return;
|
||||
}
|
||||
// Toute autre modification met simplement les totaux à jour.
|
||||
syncDraftFromDom();
|
||||
render();
|
||||
});
|
||||
|
||||
saveButton?.addEventListener('click', () => save(false));
|
||||
deleteButton?.addEventListener('click', removeTemplate);
|
||||
applyPeriodButton?.addEventListener('click', () => {
|
||||
PTA.modules.weekTemplates?.openPeriodModal?.(currentTemplateId);
|
||||
});
|
||||
applyWeekButton?.addEventListener('click', () => {
|
||||
if (!weekInput?.value) {
|
||||
setMessage('Choisissez d’abord une semaine dans la sélection en haut de page.', 'warning');
|
||||
return;
|
||||
}
|
||||
PTA.modules.weekTemplates?.openApplyModal?.(currentTemplateId);
|
||||
});
|
||||
|
||||
render();
|
||||
if (agentId()) loadTemplates().then(render);
|
||||
}
|
||||
|
||||
PTA.modules.weekTemplateEditor = {
|
||||
init,
|
||||
setMode,
|
||||
refresh: () => loadTemplates().then(render),
|
||||
};
|
||||
})();
|
||||
@@ -195,7 +195,7 @@
|
||||
|
||||
templateSelect.disabled = false;
|
||||
templateSelect.innerHTML = '<option value="">Choisir une semaine type</option>' + templates.map((template) => (
|
||||
`<option value="${template.id}">${escapeHtml(template.name)}</option>`
|
||||
`<option value="${Number(template.id)}">${escapeHtml(template.name)}</option>`
|
||||
)).join('');
|
||||
renderSelectedTemplateDetails();
|
||||
}
|
||||
@@ -219,7 +219,11 @@
|
||||
`;
|
||||
}
|
||||
|
||||
async function openApplyModal() {
|
||||
/**
|
||||
* `preselectedId` permet à l'éditeur de semaine type d'ouvrir la modale
|
||||
* directement sur le modèle en cours d'édition, sans le rechercher.
|
||||
*/
|
||||
async function openApplyModal(preselectedId = null) {
|
||||
if (!contextReady()) {
|
||||
showMessage('Sélectionnez un agent et la semaine cible avant d’importer une semaine type.', 'warning');
|
||||
return;
|
||||
@@ -235,6 +239,10 @@
|
||||
try {
|
||||
await loadTemplates();
|
||||
renderTemplateSelect();
|
||||
if (preselectedId && templateSelect) {
|
||||
templateSelect.value = String(Number(preselectedId));
|
||||
renderSelectedTemplateDetails();
|
||||
}
|
||||
setInlineMessage(applyMessage);
|
||||
} catch (error) {
|
||||
setInlineMessage(applyMessage, error.message, 'error');
|
||||
@@ -364,7 +372,7 @@
|
||||
}
|
||||
periodTemplateSelect.disabled = false;
|
||||
periodTemplateSelect.innerHTML = '<option value="">Choisir une semaine type</option>' + templates.map((template) => (
|
||||
`<option value="${template.id}">${escapeHtml(template.name)}</option>`
|
||||
`<option value="${Number(template.id)}">${escapeHtml(template.name)}</option>`
|
||||
)).join('');
|
||||
}
|
||||
|
||||
@@ -379,7 +387,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function openPeriodModal() {
|
||||
async function openPeriodModal(preselectedId = null) {
|
||||
if (!contextReady()) {
|
||||
showMessage('Sélectionnez un agent et une semaine avant d’appliquer une semaine type sur une période.', 'warning');
|
||||
return;
|
||||
@@ -397,6 +405,10 @@
|
||||
try {
|
||||
await loadTemplates();
|
||||
renderPeriodTemplateSelect();
|
||||
if (preselectedId && periodTemplateSelect) {
|
||||
periodTemplateSelect.value = String(Number(preselectedId));
|
||||
invalidatePeriodPreview();
|
||||
}
|
||||
setInlineMessage(periodMessage);
|
||||
} catch (error) {
|
||||
setInlineMessage(periodMessage, error.message, 'error');
|
||||
@@ -687,5 +699,8 @@
|
||||
init,
|
||||
refreshButtons,
|
||||
loadTemplates,
|
||||
// Ouverts aussi depuis l'éditeur de semaine type.
|
||||
openApplyModal,
|
||||
openPeriodModal,
|
||||
};
|
||||
})();
|
||||
|
||||
609
assets/style.css
609
assets/style.css
@@ -2553,3 +2553,612 @@ textarea:disabled {
|
||||
@media print {
|
||||
.annual-validation-card { display: none !important; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
PTA V7.9 - Navigation regroupée et tableau de bord
|
||||
============================================================ */
|
||||
|
||||
/* --- Barre de navigation par intention --------------------- */
|
||||
.view-tabs-grouped {
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
padding: 0.45rem 0.35rem 0.4rem;
|
||||
}
|
||||
|
||||
.view-tab-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
padding: 0 0.6rem;
|
||||
}
|
||||
|
||||
.view-tabs-grouped .view-tab-group + .view-tab-group {
|
||||
border-left: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.view-tab-group-label {
|
||||
padding-left: 0.35rem;
|
||||
color: #7b8794;
|
||||
font-size: 0.64rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.view-tab-group-items {
|
||||
display: flex;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.view-tabs-grouped .view-tab {
|
||||
padding: 0.55rem 0.8rem;
|
||||
font-size: 0.94rem;
|
||||
}
|
||||
|
||||
/* Sans titres de groupe, la barre retrouve son alignement d'origine. */
|
||||
.view-tabs:not(.view-tabs-grouped) .view-tab-group,
|
||||
.view-tabs:not(.view-tabs-grouped) .view-tab-group-items {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.page-header-identity { min-width: 0; }
|
||||
.page-header-identity .subtitle { max-width: 68ch; }
|
||||
|
||||
/* --- Tuiles d'action --------------------------------------- */
|
||||
.dashboard-context-card .section-heading { align-items: flex-end; }
|
||||
.dashboard-context-actions {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
.dashboard-week-field { min-width: 190px; }
|
||||
.dashboard-context-note {
|
||||
margin: 14px 0 0;
|
||||
padding: 10px 13px;
|
||||
border-radius: 10px;
|
||||
border-left: 5px solid #2563eb;
|
||||
background: #eff6ff;
|
||||
color: #1e3a5f;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.dashboard-tiles {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.dashboard-tile {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 18px 20px;
|
||||
border: 1px solid #e4e8eb;
|
||||
border-left: 6px solid #cbd5e1;
|
||||
border-radius: 16px;
|
||||
background: #fff;
|
||||
box-shadow: 0 6px 24px rgba(23, 32, 42, 0.05);
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
transition: transform 0.12s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
.dashboard-tile:hover,
|
||||
.dashboard-tile:focus-visible {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 12px 28px rgba(23, 32, 42, 0.11);
|
||||
}
|
||||
.dashboard-tile-label {
|
||||
color: #5f6b7a;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.dashboard-tile-value { font-size: 2.1rem; line-height: 1.1; }
|
||||
.dashboard-tile-detail { color: #66737d; font-size: 0.84rem; }
|
||||
.dashboard-tile-cta {
|
||||
margin-top: 6px;
|
||||
color: #1f4c73;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
.dashboard-tile-cta::after { content: ' →'; }
|
||||
|
||||
.dashboard-tile.is-alert { border-left-color: #c72f3f; }
|
||||
.dashboard-tile.is-alert .dashboard-tile-value { color: #a3212f; }
|
||||
.dashboard-tile.is-clear { border-left-color: #2f855a; }
|
||||
.dashboard-tile.is-clear .dashboard-tile-value { color: #256d3b; }
|
||||
|
||||
/* --- Listes « à traiter » ---------------------------------- */
|
||||
.dashboard-columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
.dashboard-columns > .card { margin-bottom: 0; }
|
||||
.dashboard-list-card { display: flex; flex-direction: column; }
|
||||
|
||||
.dashboard-list {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.dashboard-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 11px 13px;
|
||||
border: 1px solid #e6ebee;
|
||||
border-radius: 11px;
|
||||
background: #f9fbfc;
|
||||
}
|
||||
.dashboard-list-main { flex: 1 1 auto; min-width: 0; }
|
||||
.dashboard-list-main strong { display: block; }
|
||||
.dashboard-list-main small { color: #66737d; font-size: 0.82rem; }
|
||||
.dashboard-list-meta {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dashboard-list-meta span { color: #66737d; font-size: 0.78rem; }
|
||||
.dashboard-list-action {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
min-height: 38px;
|
||||
padding: 8px 14px;
|
||||
font-size: 0.86rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
.dashboard-gap-count { color: #a3212f; }
|
||||
|
||||
.dashboard-inline-note {
|
||||
margin-top: 14px;
|
||||
padding: 11px 13px;
|
||||
border-radius: 10px;
|
||||
border-left: 5px solid #d97706;
|
||||
background: #fffbeb;
|
||||
color: #7d5c00;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
/* --- Suivi des quotas -------------------------------------- */
|
||||
.dashboard-quota-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.dashboard-quota-table-wrap { overflow-x: auto; }
|
||||
.dashboard-quota-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.dashboard-quota-table th,
|
||||
.dashboard-quota-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #eceff1;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dashboard-quota-table th {
|
||||
color: #5f6b7a;
|
||||
font-size: 0.76rem;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.dashboard-quota-table td small { display: block; color: #66737d; font-size: 0.78rem; }
|
||||
.dashboard-quota-table tr.is-over-quota { background: #fef4f4; }
|
||||
.dashboard-quota-action-cell { text-align: right; }
|
||||
.dashboard-quota-action-cell .button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 36px;
|
||||
padding: 7px 13px;
|
||||
font-size: 0.84rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.dashboard-quota-gauge-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Jauge native : la CSP interdit l'attribut style, la largeur ne peut donc pas
|
||||
être calculée en JavaScript sur une simple div. */
|
||||
.dashboard-quota-gauge {
|
||||
width: 110px;
|
||||
height: 9px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: #e4e9ec;
|
||||
appearance: none;
|
||||
}
|
||||
.dashboard-quota-gauge::-webkit-progress-bar { background: #e4e9ec; border-radius: 999px; }
|
||||
.dashboard-quota-gauge::-webkit-progress-value { background: #2f6f9f; border-radius: 999px; }
|
||||
.dashboard-quota-gauge::-moz-progress-bar { background: #2f6f9f; border-radius: 999px; }
|
||||
.dashboard-quota-gauge.is-over::-webkit-progress-value { background: #c72f3f; }
|
||||
.dashboard-quota-gauge.is-over::-moz-progress-bar { background: #c72f3f; }
|
||||
|
||||
/* --- Raccourcis -------------------------------------------- */
|
||||
.dashboard-shortcuts {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.dashboard-shortcut {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #e4e8eb;
|
||||
border-radius: 12px;
|
||||
background: #f9fbfc;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
.dashboard-shortcut:hover,
|
||||
.dashboard-shortcut:focus-visible { border-color: #b9c6cf; background: #fff; }
|
||||
.dashboard-shortcut small { color: #66737d; font-size: 0.82rem; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.view-tabs-grouped { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
|
||||
.view-tabs-grouped .view-tab-group + .view-tab-group { border-left: 0; }
|
||||
.view-tab-group { width: 100%; padding: 0; }
|
||||
.view-tab-group-items { flex-wrap: wrap; }
|
||||
.dashboard-context-card .section-heading { align-items: stretch; }
|
||||
.dashboard-context-actions { flex-wrap: wrap; }
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.dashboard-list-item { flex-wrap: wrap; }
|
||||
.dashboard-list-meta { text-align: left; }
|
||||
.dashboard-list-action { width: 100%; justify-content: center; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
PTA V7.10 - Guide d'utilisation (FAQ)
|
||||
============================================================ */
|
||||
|
||||
/* --- Bouton d'accès ancré à droite de la navigation --------- */
|
||||
/* La barre défile horizontalement quand les onglets débordent ;
|
||||
`position: sticky` garde le guide visible quoi qu'il arrive. */
|
||||
.view-tab-help {
|
||||
display: flex;
|
||||
position: sticky;
|
||||
right: 0;
|
||||
align-items: center;
|
||||
margin-left: auto;
|
||||
padding-left: 0.55rem;
|
||||
background: #f8fafc;
|
||||
box-shadow: -14px 0 12px -10px rgba(15, 23, 42, 0.16);
|
||||
}
|
||||
|
||||
.view-tabs-grouped .view-tab-help { border-left: 1px solid #e2e8f0; }
|
||||
|
||||
.view-tab-faq {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
color: #263238;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.view-tab-faq-mark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.35rem;
|
||||
height: 1.35rem;
|
||||
border-radius: 50%;
|
||||
background: #263238;
|
||||
color: #fff;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.view-tab-faq:hover,
|
||||
.view-tab-faq:focus-visible { background: #fff; }
|
||||
|
||||
/* --- Mise en page du guide --------------------------------- */
|
||||
.faq-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
|
||||
align-items: start;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.faq-summary {
|
||||
position: sticky;
|
||||
top: 18px;
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
.faq-summary-title {
|
||||
margin: 0 0 10px;
|
||||
color: #7b8794;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.faq-summary-list {
|
||||
margin: 0;
|
||||
padding-left: 1.1rem;
|
||||
color: #66737d;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.faq-summary-list li { margin-bottom: 7px; }
|
||||
.faq-summary-list a { color: #263238; text-decoration: none; }
|
||||
.faq-summary-list a:hover,
|
||||
.faq-summary-list a:focus-visible { text-decoration: underline; }
|
||||
|
||||
.faq-summary-note {
|
||||
margin: 14px 0 0;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #eceff1;
|
||||
color: #66737d;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.faq-section { scroll-margin-top: 18px; }
|
||||
.faq-section h3 { margin: 22px 0 8px; font-size: 1rem; }
|
||||
.faq-section p { line-height: 1.55; }
|
||||
.faq-section code {
|
||||
padding: 1px 5px;
|
||||
border-radius: 5px;
|
||||
background: #eef1f4;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
.faq-section kbd {
|
||||
padding: 1px 6px;
|
||||
border: 1px solid #cfd8dc;
|
||||
border-bottom-width: 2px;
|
||||
border-radius: 5px;
|
||||
background: #f8fafc;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
/* --- Le parcours en huit étapes ---------------------------- */
|
||||
.faq-flow {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 12px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.faq-flow li {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
padding: 13px 15px;
|
||||
border: 1px solid #e4e8eb;
|
||||
border-radius: 12px;
|
||||
background: #f9fbfc;
|
||||
}
|
||||
|
||||
.faq-flow-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1.6rem;
|
||||
height: 1.6rem;
|
||||
border-radius: 50%;
|
||||
background: #263238;
|
||||
color: #fff;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.faq-flow li small { color: #66737d; font-size: 0.82rem; line-height: 1.4; }
|
||||
|
||||
/* --- Étapes numérotées et listes --------------------------- */
|
||||
.faq-steps { margin: 0; padding-left: 1.3rem; }
|
||||
.faq-steps li { margin-bottom: 9px; line-height: 1.55; }
|
||||
.faq-list { margin: 0 0 4px; padding-left: 1.3rem; }
|
||||
.faq-list li { margin-bottom: 7px; line-height: 1.55; }
|
||||
|
||||
.faq-callout { margin: 16px 0 0; }
|
||||
|
||||
.faq-table th,
|
||||
.faq-table td { vertical-align: top; line-height: 1.5; }
|
||||
.faq-table tr.faq-row-current { background: #f2f7f4; }
|
||||
|
||||
.faq-level {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.74rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.faq-level-error { background: #fdecec; color: #a3212f; }
|
||||
.faq-level-warning { background: #fffbeb; color: #7d5c00; }
|
||||
.faq-level-info { background: #eef2f7; color: #37474f; }
|
||||
|
||||
/* --- Questions / réponses ---------------------------------- */
|
||||
.faq-qa { margin: 0; }
|
||||
.faq-qa dt {
|
||||
margin-top: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.faq-qa dt:first-child { margin-top: 0; }
|
||||
.faq-qa dd {
|
||||
margin: 5px 0 0;
|
||||
padding-left: 13px;
|
||||
border-left: 3px solid #e4e8eb;
|
||||
color: #4b5563;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.faq-layout { grid-template-columns: minmax(0, 1fr); }
|
||||
.faq-summary { position: static; }
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.view-tab-help {
|
||||
position: static;
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
.view-tabs-grouped .view-tab-help { border-left: 0; }
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
PTA V7.15 - Méthode de saisie et éditeur de semaine type
|
||||
============================================================ */
|
||||
.editor-mode-choices {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.editor-mode-choice {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding: 16px 18px;
|
||||
border: 1px solid #dbe3ee;
|
||||
border-left: 6px solid #cbd5e1;
|
||||
border-radius: 14px;
|
||||
background: #fff;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.12s ease, box-shadow 0.15s ease;
|
||||
}
|
||||
.editor-mode-choice:hover { border-color: #b9c6cf; }
|
||||
.editor-mode-choice strong { font-size: 1.05rem; }
|
||||
.editor-mode-choice small { color: #66737d; }
|
||||
.editor-mode-choice.is-active {
|
||||
border-left-color: #256d3b;
|
||||
box-shadow: 0 6px 22px rgba(23, 32, 42, 0.09);
|
||||
}
|
||||
|
||||
.editor-mode-choice-badge {
|
||||
justify-self: start;
|
||||
margin-bottom: 2px;
|
||||
padding: 3px 9px;
|
||||
border-radius: 999px;
|
||||
background: #dff3e5;
|
||||
color: #256d3b;
|
||||
font-size: 0.68rem;
|
||||
font-weight: 900;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* --- Éditeur de semaine type -------------------------------- */
|
||||
.template-editor-total { text-align: right; }
|
||||
.template-editor-total small { display: block; color: #65737b; font-size: 0.78rem; }
|
||||
|
||||
.template-editor-toolbar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) auto;
|
||||
align-items: end;
|
||||
gap: 16px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.template-editor-toolbar-actions { display: flex; gap: 10px; }
|
||||
|
||||
.template-editor-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.template-day {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 14px;
|
||||
border: 1px solid #e1e6e9;
|
||||
border-radius: 12px;
|
||||
background: #fafbfb;
|
||||
}
|
||||
.template-day.is-empty { background: #f5f7f8; }
|
||||
|
||||
.template-day-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #e6ebee;
|
||||
}
|
||||
.template-day-total { color: #5f6b7a; font-size: 0.85rem; font-weight: 800; }
|
||||
.template-day-empty { margin: 4px 0; color: #98a1a7; font-size: 0.85rem; }
|
||||
.template-day-ranges { display: grid; gap: 10px; }
|
||||
|
||||
.template-range {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto auto auto auto;
|
||||
align-items: end;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid #dde3e6;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
.template-range-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
||||
.template-range-field > span { color: #66737d; font-size: 0.72rem; font-weight: 800; }
|
||||
.template-range-field-motif { grid-column: 1 / -1; }
|
||||
.template-range-field-structure { grid-column: 1 / -1; }
|
||||
.template-range input,
|
||||
.template-range select { min-height: 38px; padding: 6px 9px; }
|
||||
.template-range-separator { padding-bottom: 10px; color: #98a1a7; }
|
||||
.template-range-remove {
|
||||
min-height: 38px;
|
||||
padding: 4px 10px;
|
||||
font-size: 1.1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.template-day-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.template-day-actions .button { min-height: 38px; padding: 7px 12px; font-size: 0.85rem; }
|
||||
.template-day-copy-field { flex: 1 1 130px; min-width: 130px; }
|
||||
.template-day-copy { min-height: 38px; padding: 6px 9px; font-size: 0.85rem; }
|
||||
|
||||
.template-editor-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.template-editor-toolbar { grid-template-columns: 1fr; }
|
||||
.template-editor-toolbar-actions { justify-content: flex-start; }
|
||||
.template-range { grid-template-columns: 1fr 1fr auto; }
|
||||
.template-range-separator { display: none; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user