get_all_beneficiaires(); $beneficiaires = []; foreach ($beneficiaires_objects as $beneficiaire) { $beneficiaires[] = [ 'id' => $beneficiaire->id, 'nom' => $beneficiaire->nom . ' ' . $beneficiaire->prenom, ]; } $template = plugin_dir_path(__FILE__) . '../../templates/admin/agenda-page.php'; if (file_exists($template)) { include $template; } else { echo '

Template agenda-page.php introuvable.

'; } } /** * Récupère les types d'intervention groupés par département * @return array Structure: [departement_id => ['nom' => string, 'types' => [['id' => int, 'nom' => string]]]] */ private static function get_types_intervention_by_departement() { $departements = CRVI_Departement_Model::all(true); $result = []; foreach ($departements as $departement) { $departement_id = $departement['id']; $departement_nom = $departement['nom']; // Récupérer le repeater type_dinterventions if (function_exists('get_field')) { $type_dinterventions = get_field('type_dinterventions', $departement_id); if (is_array($type_dinterventions) && !empty($type_dinterventions)) { $types = []; foreach ($type_dinterventions as $item) { // Le repeater contient 'type' (texte) et 'article_intervention' (ID du CPT) $article_intervention_id = $item['article_intervention'] ?? null; if ($article_intervention_id) { $type_intervention_post = get_post($article_intervention_id); if ($type_intervention_post && $type_intervention_post->post_type === 'type_intervention') { $types[] = [ 'id' => $type_intervention_post->ID, 'nom' => $type_intervention_post->post_title, ]; } } } if (!empty($types)) { $result[$departement_id] = [ 'nom' => $departement_nom, 'types' => $types, ]; } } } } return $result; } }