Auto-commit for deploy to staging - 2026-06-20 10:02:41
Deploy HouseHub / deploy (push) Successful in 2s
Deploy HouseHub / deploy (push) Successful in 2s
This commit is contained in:
+12
-2
@@ -217,15 +217,25 @@ require __DIR__ . '/header.php';
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group"><label class="form-label">Kilométrage</label><input class="form-control" id="vehicle-current-km" name="current_km" type="number" placeholder="85000"></div>
|
<div class="form-group"><label class="form-label">Kilométrage</label><input class="form-control" id="vehicle-current-km" name="current_km" type="number" placeholder="85000"></div>
|
||||||
<div class="form-group"><label class="form-label">Couleur</label><input class="form-control" id="vehicle-color" name="color" placeholder="Blanc nacré"></div>
|
<div class="form-group">
|
||||||
|
<label class="form-label">Conso. moy. (L/100km)</label>
|
||||||
|
<input class="form-control" id="vehicle-consumption" name="consumption" type="number" step="0.1" min="0" placeholder="ex: 6.5">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group"><label class="form-label">Date d'achat</label><input class="form-control" id="vehicle-purchase-date" name="purchase_date" type="date"></div>
|
<div class="form-group"><label class="form-label">Date d'achat</label><input class="form-control" id="vehicle-purchase-date" name="purchase_date" type="date"></div>
|
||||||
<div class="form-group"><label class="form-label">Prix d'achat (€)</label><input class="form-control" id="vehicle-purchase-price" name="purchase_price" type="number" step="0.01"></div>
|
<div class="form-group"><label class="form-label">Prix d'achat (€)</label><input class="form-control" id="vehicle-purchase-price" name="purchase_price" type="number" step="0.01"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group"><label class="form-label">VIN</label><input class="form-control" id="vehicle-vin" name="vin" placeholder="VF1..."></div>
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group"><label class="form-label">VIN</label><input class="form-control" id="vehicle-vin" name="vin" placeholder="VF1..."></div>
|
||||||
|
<div class="form-group"><label class="form-label">Couleur</label><input class="form-control" id="vehicle-color" name="color" placeholder="Blanc nacré"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="form-label">Photo</label>
|
<label class="form-label">Photo</label>
|
||||||
<input class="form-control" id="vehicle-photo" name="photo" type="file" accept="image/*" onchange="previewPhoto('vehicle-photo','vehicle-photo-preview')">
|
<input class="form-control" id="vehicle-photo" name="photo" type="file" accept="image/*" onchange="previewPhoto('vehicle-photo','vehicle-photo-preview')">
|
||||||
|
|||||||
+21
-4
@@ -109,14 +109,31 @@ if ($action === 'vehicles') {
|
|||||||
}
|
}
|
||||||
if ($method === 'POST') {
|
if ($method === 'POST') {
|
||||||
$photo = handleUpload('photo', $UPLOAD_DIR); $d = $_POST ?: gBody();
|
$photo = handleUpload('photo', $UPLOAD_DIR); $d = $_POST ?: gBody();
|
||||||
$stmt = $pdo->prepare("INSERT INTO pf_vehicles (name,brand,model,year,license_plate,vin,fuel_type,color,purchase_date,purchase_price,current_km,photo,notes) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
// Ajout de consumption dans la liste des champs et d'un '?' supplémentaire
|
||||||
$stmt->execute([$d['name']??'', $d['brand']??'', $d['model']??'', $d['year']??null, $d['license_plate']??null, $d['vin']??null, $d['fuel_type']??'Essence', $d['color']??null, $d['purchase_date']??null, $d['purchase_price']??null, $d['current_km']??0, $photo, $d['notes']??null]);
|
$stmt = $pdo->prepare("INSERT INTO pf_vehicles (name,brand,model,year,license_plate,vin,fuel_type,consumption,color,purchase_date,purchase_price,current_km,photo,notes) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
|
$stmt->execute([
|
||||||
|
$d['name']??'',
|
||||||
|
$d['brand']??'',
|
||||||
|
$d['model']??'',
|
||||||
|
$d['year']??null,
|
||||||
|
$d['license_plate']??null,
|
||||||
|
$d['vin']??null,
|
||||||
|
$d['fuel_type']??'Essence',
|
||||||
|
($d['consumption'] !== '' && $d['consumption'] !== null) ? (float)$d['consumption'] : null, // Cast propre en float
|
||||||
|
$d['color']??null,
|
||||||
|
$d['purchase_date']??null,
|
||||||
|
$d['purchase_price']??null,
|
||||||
|
$d['current_km']??0,
|
||||||
|
$photo,
|
||||||
|
$d['notes']??null
|
||||||
|
]);
|
||||||
gOk(['id' => $pdo->lastInsertId()]);
|
gOk(['id' => $pdo->lastInsertId()]);
|
||||||
}
|
}
|
||||||
if ($method === 'PUT') {
|
if ($method === 'PUT') {
|
||||||
$id = $_GET['id'] ?? null; if (!$id) gErr('ID manquant'); $d = gBody();
|
$id = $_GET['id'] ?? null; if (!$id) gErr('ID manquant'); $d = gBody();
|
||||||
$int_fields = ['year','current_km']; $float_fields = ['purchase_price'];
|
$int_fields = ['year','current_km'];
|
||||||
$fields = ['name','brand','model','year','license_plate','vin','fuel_type','color','purchase_date','purchase_price','current_km','notes'];
|
$float_fields = ['purchase_price', 'consumption'];
|
||||||
|
$fields = ['name','brand','model','year','license_plate','vin','fuel_type','consumption','color','purchase_date','purchase_price','current_km','notes'];
|
||||||
$sets = array_map(fn($f) => "$f = ?", $fields);
|
$sets = array_map(fn($f) => "$f = ?", $fields);
|
||||||
$vals = array_map(function($f) use ($d, $int_fields, $float_fields) {
|
$vals = array_map(function($f) use ($d, $int_fields, $float_fields) {
|
||||||
$v = $d[$f] ?? null;
|
$v = $d[$f] ?? null;
|
||||||
|
|||||||
+1409
-643
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user