From 10c9496f9a3b49d127d19f9a1029e81e0e3f8e09 Mon Sep 17 00:00:00 2001 From: marijo Date: Fri, 26 Jun 2026 06:05:45 +0000 Subject: [PATCH] Added option: Both tires changed --- index.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 5ac70fb..e9265c7 100644 --- a/index.php +++ b/index.php @@ -149,6 +149,7 @@ $types = [ 'oil_change' => 'Oil change', 'front_tyre_change' => 'Front tyre changed', 'rear_tyre_change' => 'Rear tyre changed', + 'both_tires_change' => 'Both tires changed', 'shaft_oil_change' => 'Drive shaft oil change', 'brake_pads' => 'Brake pads', 'registration' => 'Registration / insurance', @@ -177,9 +178,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'cost' => $cost === '' ? null : $cost, 'note' => $note, ]; - if (array_key_exists($type, $state['last'])) { - $prev = $state['last'][$type] ?? null; - if (!is_array($prev) || $km >= (int)($prev['km'] ?? 0)) $state['last'][$type] = $event; + $serviceKeys = $type === 'both_tires_change' ? ['front_tyre_change', 'rear_tyre_change'] : [$type]; + foreach ($serviceKeys as $serviceKey) { + if (array_key_exists($serviceKey, $state['last'])) { + $prev = $state['last'][$serviceKey] ?? null; + if (!is_array($prev) || $km >= (int)($prev['km'] ?? 0)) $state['last'][$serviceKey] = $event; + } } $event['summary'] = $types[$type] . ' @ ' . $km . ' km' . ($note ? ' - ' . $note : ''); $state['latest_event'] = $event; @@ -195,7 +199,7 @@ function event_class(?string $type): string { return match ($type) { 'odometer' => 'event-odometer', 'oil_change' => 'event-oil', - 'front_tyre_change', 'rear_tyre_change' => 'event-tyre', + 'front_tyre_change', 'rear_tyre_change', 'both_tires_change' => 'event-tyre', 'shaft_oil_change' => 'event-shaft', 'brake_pads' => 'event-brakes', 'registration' => 'event-registration',