105 lines
3.7 KiB
PHP
105 lines
3.7 KiB
PHP
<?php
|
||
/**
|
||
* Hub d'administration principal du plugin CRVI Agenda
|
||
* Emplacement : templates/admin/admin_hub.php
|
||
*
|
||
* Ce fichier sert de point d'entrée pour l'interface d'administration centrale du plugin.
|
||
* À compléter avec les composants d'administration (tableaux de bord, accès rapides, etc.)
|
||
*/
|
||
|
||
// Sécurité WordPress : empêche l'accès direct au fichier
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit;
|
||
}
|
||
|
||
// Génération des URLs admin pour les entités et pages spécifiques
|
||
function crvi_admin_url($page) {
|
||
return admin_url('edit.php?post_type=' . $page);
|
||
}
|
||
|
||
function crvi_import_form($entity) {
|
||
$action = 'crvi_import_' . $entity;
|
||
$label = 'Importer ' . ucfirst($entity) . ' (CSV)';
|
||
$nonce = wp_create_nonce('crvi_import_' . $entity);
|
||
return '<form method="post" enctype="multipart/form-data" action="' . esc_url(admin_url('admin-post.php')) . '" style="margin-top:1em;">'
|
||
. '<input type="hidden" name="action" value="' . esc_attr($action) . '">'
|
||
. '<input type="hidden" name="_wpnonce" value="' . esc_attr($nonce) . '">'
|
||
. '<input type="file" name="import_csv" accept=".csv" required style="margin-bottom:0.5em;">'
|
||
. '<button type="submit" class="button">' . esc_html($label) . '</button>'
|
||
. '</form>';
|
||
}
|
||
|
||
$entities = [
|
||
'beneficiaire' => 'Bénéficiaires',
|
||
'intervenant' => 'Intervenants',
|
||
'local' => 'Locaux',
|
||
'traducteur' => 'Traducteurs',
|
||
'departement' => 'Départements',
|
||
'type_intervention' => 'Types d\'intervention',
|
||
];
|
||
|
||
// Affichage du message de succès/erreur après import
|
||
function crvi_hub_notice() {
|
||
if (!empty($_GET['import'])) {
|
||
$type = $_GET['import'] === 'success' ? 'success' : 'error';
|
||
$msg = isset($_GET['msg']) ? sanitize_text_field($_GET['msg']) : ($type === 'success' ? 'Import réussi.' : 'Erreur lors de l\'import.');
|
||
echo '<div class="notice notice-' . esc_attr($type) . ' is-dismissible"><p>' . esc_html($msg) . '</p></div>';
|
||
}
|
||
}
|
||
|
||
?>
|
||
<style>
|
||
.crvi-hub-grid {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
grid-template-rows: repeat(3, 1fr);
|
||
gap: 2rem;
|
||
margin-top: 2rem;
|
||
}
|
||
.crvi-hub-block {
|
||
background: #fff;
|
||
border: 1px solid #e5e5e5;
|
||
border-radius: 6px;
|
||
padding: 2rem 1.5rem;
|
||
box-shadow: 0 1px 2px rgba(0,0,0,0.03);
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: flex-start;
|
||
}
|
||
.crvi-hub-block h2 {
|
||
margin-top: 0;
|
||
font-size: 1.1em;
|
||
margin-bottom: 1em;
|
||
}
|
||
.crvi-hub-block .button {
|
||
width: 100%;
|
||
margin-bottom: 0.5em;
|
||
}
|
||
.crvi-hub-block form {
|
||
width: 100%;
|
||
text-align: center;
|
||
}
|
||
</style>
|
||
<div class="wrap">
|
||
<h1>CRVI Agenda – Hub d'administration</h1>
|
||
<p>Bienvenue sur le hub d'administration du plugin CRVI Agenda.</p>
|
||
<?php crvi_hub_notice(); ?>
|
||
<div class="crvi-hub-grid">
|
||
<?php foreach ($entities as $slug => $label): ?>
|
||
<div class="crvi-hub-block">
|
||
<h2><?php echo esc_html($label); ?></h2>
|
||
<a href="<?php echo esc_url( crvi_admin_url($slug) ); ?>" class="button button-primary">Voir <?php echo esc_html(strtolower($label)); ?></a>
|
||
<?php echo crvi_import_form($slug); ?>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
<div class="crvi-hub-block">
|
||
<h2>Agenda</h2>
|
||
<a href="<?php echo esc_url( admin_url('admin.php?page=crvi_agenda') ); ?>" class="button button-primary">Accéder à l'agenda</a>
|
||
</div>
|
||
<div class="crvi-hub-block">
|
||
<h2>Statistiques</h2>
|
||
<a href="<?php echo esc_url( admin_url('admin.php?page=crvi_agenda_stats') ); ?>" class="button button-primary">Voir les statistiques</a>
|
||
</div>
|
||
</div>
|
||
</div>
|