2026-09-18 09:11:18 +00:00
< div class = " page-header " >
< div >
< h1 class = " page-title " >
2026-09-20 13:35:59 +00:00
< ? = $isMineOnly ? 'Mes Véhicules' : 'Parc Automobile (Administration)' ?>
2026-09-18 09:11:18 +00:00
</ h1 >
< p class = " page-subtitle " >
2026-09-20 13:35:59 +00:00
< ? php if ( ! $isAdmin ) : ?>
Gestion de vos véhicules déclarés ( L 'accès au parc global est réservé aux administrateurs selon l' API v1 . 1.0 )
< ? php elseif ( $isMineOnly ) : ?>
Véhicules dont vous êtes le propriétaire déclaré
< ? php else : ?>
Supervision et gestion de l ' intégralité du parc automobile ( Mode Administrateur )
< ? php endif ; ?>
2026-09-18 09:11:18 +00:00
</ p >
</ div >
< div class = " page-actions " >
< ? php if ( ! empty ( $_SESSION [ 'user' ])) : ?>
< a href = " /cars/create " class = " btn btn-primary " >
< span >+</ span > Ajouter un véhicule
</ a >
< ? php else : ?>
2026-09-20 13:35:59 +00:00
< a href = " /login?redirect=/cars/create " class = " btn btn-primary " >
🔒 Se connecter pour ajouter un véhicule
2026-09-18 09:11:18 +00:00
</ a >
< ? php endif ; ?>
</ div >
</ div >
< ? php if ( ! empty ( $searchedPlate )) : ?>
< div class = " alert alert-info " >
< span > Résultat de la recherche pour la plaque < strong >< ? = htmlspecialchars ( $searchedPlate ) ?> </strong></span>
< a href = " /cars " class = " btn btn-sm btn-outline " > Réinitialiser le filtre </ a >
</ div >
< ? php endif ; ?>
< ? php if ( ! empty ( $apiError )) : ?>
< div class = " alert alert-danger " >
< strong > Erreur API :</ strong > < ? = htmlspecialchars ( $apiError ) ?>
</ div >
< ? php endif ; ?>
<!-- Barre de recherche et filtres instantanés côté client -->
< div class = " filter-bar " >
< div class = " search-box " >
< span class = " search-icon " > 🔍 </ span >
< input type = " text " id = " searchInput " placeholder = " Filtrer en direct (marque, modèle, plaque, année...) " class = " form-input " >
</ div >
< div class = " filter-tabs " >
2026-09-20 13:35:59 +00:00
< ? php if ( $isAdmin ) : ?>
< a href = " /cars " class = " filter-tab <?= ! $isMineOnly ? 'active' : '' ?> " > Tous les véhicules ( Admin ) </ a >
2026-09-18 09:11:18 +00:00
< a href = " /cars?mine=1 " class = " filter-tab <?= $isMineOnly ? 'active' : '' ?> " > Mes véhicules </ a >
2026-09-20 13:35:59 +00:00
< ? php else : ?>
< span class = " filter-tab active " > Mes véhicules </ span >
< span class = " badge badge-secondary " title = " Accès au parc complet réservé aux administrateurs (API v1.1.0) " style = " margin-left: 0.5rem; align-self: center; " >
🔒 Parc global réservé aux admins
</ span >
2026-09-18 09:11:18 +00:00
< ? php endif ; ?>
</ div >
< div class = " filter-count " >
< span id = " carCounter " >< ? = count ( $cars ) ?> </span> véhicule(s)
</ div >
</ div >
<!-- Liste des voitures sous forme de cartes -->
< div class = " cars-grid " id = " carsGrid " >
< ? php if ( empty ( $cars )) : ?>
< div class = " empty-state " >
< p > Aucun véhicule trouvé .</ p >
< ? php if ( ! empty ( $_SESSION [ 'user' ])) : ?>
< a href = " /cars/create " class = " btn btn-primary " > Ajouter un véhicule maintenant </ a >
< ? php else : ?>
< a href = " /login " class = " btn btn-primary " > Se connecter pour ajouter un véhicule </ a >
< ? php endif ; ?>
</ div >
< ? php else : ?>
< ? php
$user = $_SESSION [ 'user' ] ? ? null ;
foreach ( $cars as $car ) :
$canManage = $car -> canEdit ( $user );
?>
< article class = " car-card " data - search = " <?= strtolower(htmlspecialchars( $car->getFullName () . ' ' . $car->immatriculation . ' ' . $car->annee . ' ' . $car->getOwnerName ())) ?> " >
< div class = " car-card-header " >
< ? php if ( ! empty ( $car -> immatriculation )) : ?>
< div class = " license-plate " title = " Plaque d'immatriculation " >
< span class = " plate-country " > F </ span >
< span class = " plate-number " >< ? = htmlspecialchars ( $car -> immatriculation ) ?> </span>
</ div >
< ? php else : ?>
< span class = " badge badge-secondary " > Sans immatriculation </ span >
< ? php endif ; ?>
< span class = " car-year " >< ? = htmlspecialchars ( $car -> annee ? ? '—' ) ?> </span>
</ div >
< div class = " car-card-body " >
< h2 class = " car-title " >< ? = htmlspecialchars ( $car -> getFullName ()) ?> </h2>
< div class = " car-stats-row " >
< div class = " stat-badge stat-km " >
< span class = " stat-icon " > 🛣️ </ span >
< span class = " stat-text " >< ? = htmlspecialchars ( $car -> getFormattedKm ()) ?> </span>
</ div >
< ? php if ( ! empty ( $car -> dateAchat )) : ?>
< div class = " stat-badge stat-date " title = " Date d'acquisition " >
< span class = " stat-icon " > 📅 </ span >
< span class = " stat-text " >< ? = htmlspecialchars ( $car -> getFormattedDateAchat ()) ?> </span>
</ div >
< ? php endif ; ?>
</ div >
< ? php if ( ! empty ( $car -> vin )) : ?>
< p class = " car-attribute " title = " Numéro de série VIN " >
< strong > VIN :</ strong > < code >< ? = htmlspecialchars ( $car -> vin ) ?> </code>
</ p >
< ? php endif ; ?>
< p class = " car-owner " >
< strong > Propriétaire :</ strong > < ? = htmlspecialchars ( $car -> getOwnerName ()) ?>
</ p >
</ div >
< div class = " car-card-footer " >
< a href = " /cars/<?= $car->id ?> " class = " btn btn-secondary btn-sm " > Détails & Suivi </ a >
< ? php if ( $canManage ) : ?>
< a href = " /cars/<?= $car->id ?>/edit " class = " btn btn-outline btn-sm " > Modifier </ a >
< form action = " /cars/<?= $car->id ?>/delete " method = " POST " class = " inline-form " onsubmit = " return confirmAction('Voulez-vous vraiment supprimer définitivement ce véhicule et toutes ses données associées (kilométrage, entretiens, notes) ?'); " >
< button type = " submit " class = " btn btn-danger btn-sm " > Supprimer </ button >
</ form >
< ? php endif ; ?>
</ div >
</ article >
< ? php endforeach ; ?>
< ? php endif ; ?>
</ div >