feat: initial impl w/ styles, scripts, & server-side logic (steps 1, 2, 3)

This commit is contained in:
Floriansylvain
2025-12-16 21:09:53 +01:00
parent 9e00c10b9c
commit dbce932ce2
15 changed files with 501 additions and 7 deletions
@@ -1 +1,35 @@
<h1>Voitures Client A</h1>
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$cars = DataManager::getCars('clienta');
?>
<h1>Voitures Client A</h1>
<?php if (empty($cars)): ?>
<p>Aucune voiture trouvée.</p>
<?php else: ?>
<ul>
<?php foreach ($cars as $car): ?>
<?php
$yearRaw = $car['year'] ?? null;
$date = '-';
if ($yearRaw !== null && $yearRaw !== '') {
$yr = (int)$yearRaw;
$currentYear = (int)date('Y');
if ($yr >= 1900 && $yr <= $currentYear + 1) {
$date = (string)$yr;
} else {
$ts = (int)$yearRaw;
if ($ts > 0) $date = date('d/m/Y', $ts);
else $date = (string)$yearRaw;
}
}
?>
<li class="car-item" data-car-id="<?php echo htmlspecialchars($car['id'] ?? ''); ?>">
<strong><?php echo htmlspecialchars($car['modelName'] ?? '-'); ?></strong>
- <?php echo htmlspecialchars($car['brand'] ?? '-'); ?>
(<?php echo $date; ?>)
- <?php echo htmlspecialchars((string)($car['power'] ?? '-')); ?> ch
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
@@ -0,0 +1,31 @@
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$id = $_GET['id'] ?? null;
$carFound = null;
$cars = DataManager::getCars('clienta');
if ($id !== null) {
foreach ($cars as $c) {
if (isset($c['id']) && (string)$c['id'] === (string)$id) {
$carFound = $c;
break;
}
}
}
?>
<?php if (!$carFound): ?>
<div>Voiture non trouvée.</div>
<?php else: ?>
<h1>Détails: <?php echo htmlspecialchars($carFound['modelName'] ?? '-'); ?></h1>
<ul>
<li>Marque: <?php echo htmlspecialchars($carFound['brand'] ?? '-'); ?></li>
<li>Année: <?php echo htmlspecialchars($carFound['year'] ?? '-'); ?></li>
<li>Puissance: <?php echo htmlspecialchars((string)($carFound['power'] ?? '-')); ?> ch</li>
<?php if (isset($carFound['garageId'])):
$garage = DataManager::getGarageById($carFound['garageId']); ?>
<li>Garage: <?php echo htmlspecialchars($garage['title'] ?? '-'); ?></li>
<?php endif; ?>
<?php if (!empty($carFound['colorHex'])): ?>
<li>Couleur: <span class="garage-color" style="background-color:<?php echo htmlspecialchars($carFound['colorHex']); ?>; width:12px; height:12px; display:inline-block; border-radius:50%;"></span></li>
<?php endif; ?>
</ul>
<?php endif; ?>
@@ -1 +1,24 @@
<h1>Voitures Client B</h1>
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$cars = DataManager::getCars('clientb');
?>
<h1>Voitures Client B</h1>
<?php if (empty($cars)): ?>
<p>Aucune voiture trouvée.</p>
<?php else: ?>
<ul>
<?php foreach ($cars as $car): ?>
<?php
$model = isset($car['modelName']) ? strtolower($car['modelName']) : '-';
$brand = $car['brand'] ?? '-';
$garage = DataManager::getGarageById($car['garageId'] ?? null);
$garageTitle = $garage['title'] ?? '-';
?>
<li class="car-item" data-car-id="<?php echo htmlspecialchars($car['id'] ?? ''); ?>">
<strong><?php echo htmlspecialchars($model); ?></strong>
- <?php echo htmlspecialchars($brand); ?>
- Garage: <?php echo htmlspecialchars($garageTitle); ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
@@ -0,0 +1,31 @@
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$id = $_GET['id'] ?? null;
$carFound = null;
$cars = DataManager::getCars('clientb');
if ($id !== null) {
foreach ($cars as $c) {
if (isset($c['id']) && (string)$c['id'] === (string)$id) {
$carFound = $c;
break;
}
}
}
?>
<?php if (!$carFound): ?>
<div>Voiture non trouvée.</div>
<?php else: ?>
<h1>Détails: <?php echo htmlspecialchars($carFound['modelName'] ?? '-'); ?></h1>
<ul>
<li>Marque: <?php echo htmlspecialchars($carFound['brand'] ?? '-'); ?></li>
<li>Année: <?php echo htmlspecialchars($carFound['year'] ?? '-'); ?></li>
<li>Puissance: <?php echo htmlspecialchars((string)($carFound['power'] ?? '-')); ?> ch</li>
<?php if (isset($carFound['garageId'])):
$garage = DataManager::getGarageById($carFound['garageId']); ?>
<li>Garage: <?php echo htmlspecialchars($garage['title'] ?? '-'); ?></li>
<?php endif; ?>
<?php if (!empty($carFound['colorHex'])): ?>
<li>Couleur: <span class="garage-color" style="background-color:<?php echo htmlspecialchars($carFound['colorHex']); ?>;"></span></li>
<?php endif; ?>
</ul>
<?php endif; ?>
@@ -1 +1,21 @@
<h1>Voitures Client C</h1>
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$cars = DataManager::getCars('clientc');
?>
<h1>Voitures Client C</h1>
<?php if (empty($cars)): ?>
<p>Aucune voiture trouvée.</p>
<?php else: ?>
<ul>
<?php foreach ($cars as $car): ?>
<?php $color = isset($car['colorHex']) ? $car['colorHex'] : '#ccc'; ?>
<li class="garage-bullet car-item" data-car-id="<?php echo htmlspecialchars($car['id'] ?? ''); ?>">
<span class="garage-color" style="background-color:<?php echo htmlspecialchars($color); ?>"></span>
<span>
<strong><?php echo htmlspecialchars($car['modelName'] ?? '-'); ?></strong>
- <?php echo htmlspecialchars($car['brand'] ?? '-'); ?>
</span>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
@@ -0,0 +1,31 @@
<?php
require_once __DIR__ . '/../../../../src/utils.php';
$id = $_GET['id'] ?? null;
$carFound = null;
$cars = DataManager::getCars('clientc');
if ($id !== null) {
foreach ($cars as $c) {
if (isset($c['id']) && (string)$c['id'] === (string)$id) {
$carFound = $c;
break;
}
}
}
?>
<?php if (!$carFound): ?>
<div>Voiture non trouvée.</div>
<?php else: ?>
<h1>Détails: <?php echo htmlspecialchars($carFound['modelName'] ?? '-'); ?></h1>
<ul>
<li>Marque: <?php echo htmlspecialchars($carFound['brand'] ?? '-'); ?></li>
<li>Année: <?php echo htmlspecialchars($carFound['year'] ?? '-'); ?></li>
<li>Puissance: <?php echo htmlspecialchars((string)($carFound['power'] ?? '-')); ?> ch</li>
<?php if (isset($carFound['garageId'])):
$garage = DataManager::getGarageById($carFound['garageId']); ?>
<li>Garage: <?php echo htmlspecialchars($garage['title'] ?? '-'); ?></li>
<?php endif; ?>
<?php if (!empty($carFound['colorHex'])): ?>
<li>Couleur: <span class="garage-color" style="background-color:<?php echo htmlspecialchars($carFound['colorHex']); ?>;"></span></li>
<?php endif; ?>
</ul>
<?php endif; ?>