224 lines
9.2 KiB
PHP
224 lines
9.2 KiB
PHP
<?php
|
|
/**
|
|
* Template email : Notification de conflit de disponibilité
|
|
*
|
|
* Variables disponibles :
|
|
* @var WP_User $user L'utilisateur (intervenant) concerné
|
|
* @var array $conflicts Les conflits détectés
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Alerte : Conflit de disponibilité</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
line-height: 1.6;
|
|
color: #333;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
background-color: #f5f5f5;
|
|
}
|
|
.email-container {
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
padding: 30px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
.header {
|
|
background-color: #dc3545;
|
|
color: #ffffff;
|
|
padding: 20px;
|
|
border-radius: 6px;
|
|
margin-bottom: 25px;
|
|
}
|
|
.header h1 {
|
|
margin: 0;
|
|
font-size: 24px;
|
|
}
|
|
.intervenant-info {
|
|
background-color: #f8f9fa;
|
|
padding: 15px;
|
|
border-radius: 6px;
|
|
margin-bottom: 25px;
|
|
}
|
|
.intervenant-info h2 {
|
|
margin-top: 0;
|
|
color: #333;
|
|
font-size: 18px;
|
|
}
|
|
.intervenant-info p {
|
|
margin: 5px 0;
|
|
}
|
|
.conflict-section {
|
|
margin-bottom: 30px;
|
|
border-left: 4px solid #dc3545;
|
|
padding-left: 20px;
|
|
}
|
|
.conflict-section h3 {
|
|
color: #dc3545;
|
|
margin-top: 0;
|
|
font-size: 18px;
|
|
}
|
|
.conflict-period {
|
|
background-color: #fff3cd;
|
|
padding: 12px;
|
|
border-radius: 4px;
|
|
margin-bottom: 15px;
|
|
border-left: 3px solid #ffc107;
|
|
}
|
|
.event-item {
|
|
background-color: #f8f9fa;
|
|
padding: 12px;
|
|
margin: 10px 0;
|
|
border-radius: 4px;
|
|
border-left: 3px solid #007bff;
|
|
}
|
|
.event-item strong {
|
|
color: #007bff;
|
|
}
|
|
.event-details {
|
|
margin-top: 8px;
|
|
font-size: 14px;
|
|
color: #666;
|
|
}
|
|
.event-details span {
|
|
display: inline-block;
|
|
margin-right: 15px;
|
|
}
|
|
.beneficiaires-list {
|
|
margin-top: 5px;
|
|
padding-left: 0;
|
|
color: #495057;
|
|
}
|
|
.footer {
|
|
margin-top: 30px;
|
|
padding-top: 20px;
|
|
border-top: 1px solid #dee2e6;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
.footer ul {
|
|
padding-left: 20px;
|
|
}
|
|
.footer li {
|
|
margin-bottom: 8px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="email-container">
|
|
<div class="header">
|
|
<h1>⚠️ Alerte : Conflit de disponibilité détecté</h1>
|
|
</div>
|
|
|
|
<div class="intervenant-info">
|
|
<h2>Intervenant concerné</h2>
|
|
<p><strong>Nom :</strong> <?php echo esc_html($user->display_name); ?></p>
|
|
<p><strong>Email :</strong> <?php echo esc_html($user->user_email); ?></p>
|
|
</div>
|
|
|
|
<p style="font-size: 16px; margin-bottom: 25px;">
|
|
Des événements sont planifiés pendant les périodes d'indisponibilité de cet intervenant.
|
|
Veuillez vérifier et prendre les mesures nécessaires.
|
|
</p>
|
|
|
|
<?php foreach ($conflicts as $key => $conflict): ?>
|
|
<div class="conflict-section">
|
|
<?php if ($key === 'jours_indisponibles'): ?>
|
|
<!-- Conflit de jours indisponibles -->
|
|
<h3>Jours non disponibles</h3>
|
|
<p><strong><?php echo count($conflict['events']); ?> événement(s)</strong> planifié(s) sur des jours où l'intervenant n'est pas disponible.</p>
|
|
|
|
<?php foreach ($conflict['events'] as $event): ?>
|
|
<?php
|
|
$enriched = $event['enriched'] ?? null;
|
|
if ($enriched):
|
|
$date_formatted = date_i18n('d/m/Y', strtotime($enriched['date_rdv']));
|
|
$day_name = date_i18n('l', strtotime($enriched['date_rdv']));
|
|
?>
|
|
<div class="event-item">
|
|
<strong><?php echo esc_html($date_formatted); ?> (<?php echo esc_html($day_name); ?>) à <?php echo esc_html(substr($enriched['heure_rdv'], 0, 5)); ?></strong>
|
|
<div class="event-details">
|
|
<span><strong>Type :</strong> <?php echo esc_html(ucfirst($enriched['type_rdv'])); ?></span>
|
|
<span><strong>Département :</strong> <?php echo esc_html($enriched['departement']); ?></span>
|
|
<span><strong>Type intervention :</strong> <?php echo esc_html($enriched['type_intervention']); ?></span>
|
|
|
|
<?php if (!empty($enriched['beneficiaires'])): ?>
|
|
<div class="beneficiaires-list">
|
|
<strong>Bénéficiaire(s) :</strong> <?php echo esc_html(implode(', ', $enriched['beneficiaires'])); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<span style="color: #999;"><strong>ID :</strong> <?php echo esc_html($enriched['id']); ?></span>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
|
|
<?php else: ?>
|
|
<!-- Conflit de période d'indisponibilité -->
|
|
<?php
|
|
$periode = $conflict['periode'];
|
|
$debut_formatted = date_i18n('d/m/Y', strtotime($periode['debut']));
|
|
$fin_formatted = date_i18n('d/m/Y', strtotime($periode['fin']));
|
|
?>
|
|
|
|
<h3><?php echo esc_html($periode['type']); ?></h3>
|
|
<div class="conflict-period">
|
|
<strong>Période :</strong> du <?php echo esc_html($debut_formatted); ?> au <?php echo esc_html($fin_formatted); ?>
|
|
</div>
|
|
<p><strong><?php echo count($conflict['events']); ?> événement(s)</strong> planifié(s) pendant cette période.</p>
|
|
|
|
<?php foreach ($conflict['events'] as $event): ?>
|
|
<?php
|
|
$enriched = $event['enriched'] ?? null;
|
|
if ($enriched):
|
|
$date_formatted = date_i18n('d/m/Y', strtotime($enriched['date_rdv']));
|
|
?>
|
|
<div class="event-item">
|
|
<strong><?php echo esc_html($date_formatted); ?> à <?php echo esc_html(substr($enriched['heure_rdv'], 0, 5)); ?></strong>
|
|
<div class="event-details">
|
|
<span><strong>Type :</strong> <?php echo esc_html(ucfirst($enriched['type_rdv'])); ?></span>
|
|
<span><strong>Département :</strong> <?php echo esc_html($enriched['departement']); ?></span>
|
|
<span><strong>Type intervention :</strong> <?php echo esc_html($enriched['type_intervention']); ?></span>
|
|
|
|
<?php if (!empty($enriched['beneficiaires'])): ?>
|
|
<div class="beneficiaires-list">
|
|
<strong>Bénéficiaire(s) :</strong> <?php echo esc_html(implode(', ', $enriched['beneficiaires'])); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<span style="color: #999;"><strong>ID :</strong> <?php echo esc_html($enriched['id']); ?></span>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<div class="footer">
|
|
<p><strong>Actions recommandées :</strong></p>
|
|
<ul>
|
|
<li>Vérifier les événements listés ci-dessus</li>
|
|
<li>Contacter l'intervenant pour confirmer sa disponibilité</li>
|
|
<li>Annuler ou déplacer les événements en conflit si nécessaire</li>
|
|
<li>Ajuster les périodes d'indisponibilité si besoin</li>
|
|
</ul>
|
|
<p style="margin-top: 20px; color: #999;">
|
|
Cet email a été envoyé automatiquement par le système Agenda CRVI.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|