- Inscription sans redirection HelloAsso (acte volontaire séparé) - Génération automatique d'identifiant AlpID (prenom.code mnémotechnique) - Profil en tuiles : identité, compte, mot de passe, OTP, adhésion, adresse, connexions - Double authentification : activation/suppression OTP via Keycloak - Page d'accueil contextuelle (bienvenue si connecté, CTA adhésion si non adhérent) - Historique des connexions avec statistiques et graphiques Chart.js - Géocodage Nominatim + lien OpenStreetMap pour l'adresse - HelloAsso : checkout intent, validation paiement, mise à jour Dolibarr Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
117 lines
4 KiB
PHP
117 lines
4 KiB
PHP
<?php
|
|
require_once __DIR__ . '/inc/config.php';
|
|
require_once __DIR__ . '/inc/auth.php';
|
|
require_once __DIR__ . '/inc/dolibarr.php';
|
|
require_once __DIR__ . '/inc/services.php';
|
|
|
|
session_start_safe();
|
|
require_login();
|
|
|
|
$user = current_user();
|
|
|
|
// Dolibarr est la source de vérité pour l'adhésion
|
|
$membership = null;
|
|
$doli_error = null;
|
|
try {
|
|
$membership = doli_get_membership($user['email']);
|
|
} catch (Exception $e) {
|
|
$doli_error = $e->getMessage();
|
|
}
|
|
|
|
// is_adherent = groupe KC OU cotisation active dans Dolibarr
|
|
$is_adherent = $user['is_adherent']
|
|
|| ($membership && $membership['status'] === 1 && $membership['date_fin_ts'] > time());
|
|
|
|
$services = services_list();
|
|
$title = 'Tableau de bord';
|
|
require __DIR__ . '/views/layout.php';
|
|
?>
|
|
|
|
<div class="dashboard">
|
|
<div class="dashboard-header">
|
|
<h1>Bonjour, <?= htmlspecialchars($user['name']) ?></h1>
|
|
<div class="badges">
|
|
<span class="badge badge-inscrit">Inscrit</span>
|
|
<?php if ($is_adherent): ?>
|
|
<span class="badge badge-adherent">Adhérent</span>
|
|
<?php endif; ?>
|
|
<?php if ($user['is_admin']): ?>
|
|
<span class="badge badge-admin">Admin</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="dashboard-grid">
|
|
<!-- Profil -->
|
|
<div class="card">
|
|
<h2>Mon compte</h2>
|
|
<dl>
|
|
<dt>Identifiant</dt><dd><?= htmlspecialchars($user['username']) ?></dd>
|
|
<dt>Email</dt><dd><?= htmlspecialchars($user['email']) ?></dd>
|
|
<?php if ($user['groups']): ?>
|
|
<dt>Groupes</dt><dd><?= htmlspecialchars(implode(', ', $user['groups'])) ?></dd>
|
|
<?php endif; ?>
|
|
</dl>
|
|
<a href="/password.php" class="btn-outline btn-sm">Changer mon mot de passe</a>
|
|
</div>
|
|
|
|
<!-- Adhésion -->
|
|
<div class="card">
|
|
<h2>Mon adhésion</h2>
|
|
<?php if ($doli_error): ?>
|
|
<p class="text-warning">Impossible de contacter Dolibarr.</p>
|
|
<?php elseif ($membership): ?>
|
|
<dl>
|
|
<dt>Statut</dt>
|
|
<dd><?= $membership['status'] === 1
|
|
? '<span class="text-success">Actif</span>'
|
|
: '<span class="text-warning">Inactif</span>' ?></dd>
|
|
<?php if ($membership['date_fin']): ?>
|
|
<dt>Cotisation jusqu\'au</dt>
|
|
<dd><?= htmlspecialchars($membership['date_fin']) ?></dd>
|
|
<?php endif; ?>
|
|
<?php if ($membership['type_label']): ?>
|
|
<dt>Type</dt><dd><?= htmlspecialchars($membership['type_label']) ?></dd>
|
|
<?php endif; ?>
|
|
</dl>
|
|
<a href="/helloasso/renew.php" class="btn-outline btn-sm">
|
|
Renouveler mon adhésion
|
|
</a>
|
|
<?php else: ?>
|
|
<p>Aucune adhésion trouvée.</p>
|
|
<p class="text-muted small">Adhérez pour accéder aux services réservés aux membres.</p>
|
|
<a href="<?= htmlspecialchars(HELLOASSO_URL) ?>" target="_blank" rel="noopener" class="btn-primary">
|
|
Adhérer via HelloAsso
|
|
</a>
|
|
<p class="text-muted small" style="margin-top:.8rem">Un administrateur validera votre adhésion sous 48h.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Services -->
|
|
<section class="services-section">
|
|
<h2>Mes services</h2>
|
|
<div class="grid">
|
|
<?php foreach ($services as $s): if (!$s['visible']) continue;
|
|
$accessible = !$s['requires_adherent'] || $is_adherent;
|
|
?>
|
|
<div class="service-card <?= $accessible ? '' : 'locked' ?>">
|
|
<div class="service-header">
|
|
<strong><?= htmlspecialchars($s['name']) ?></strong>
|
|
<?php if ($s['requires_adherent']): ?>
|
|
<span class="badge"><?= $accessible ? 'Adhérent' : 'Adhérent requis' ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<p><?= htmlspecialchars($s['description']) ?></p>
|
|
<?php if ($accessible): ?>
|
|
<a href="<?= htmlspecialchars($s['url']) ?>" target="_blank" rel="noopener">Accéder</a>
|
|
<?php else: ?>
|
|
<span class="text-muted small">Adhésion requise</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<?php require __DIR__ . '/views/layout_end.php'; ?>
|