Updated: Improved vehicle and refuel data handling on dashboard
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 14s
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 14s
Updated: - DashboardController now fetches latest refuel record only for the default vehicle - VehicleController - first created vehicle is now set as default automatically - Refuel model - latest_one() now accepts vehicle_id instead of user_id - Dashboard view - improved handling when no vehicles or refuel records exist - CSS styles - adjusted dashboard layout and global action padding
This commit is contained in:
@ -30,17 +30,21 @@ class VehicleController extends Controller {
|
||||
}
|
||||
|
||||
$vehicle = new Vehicle();
|
||||
$default_vehicle = $vehicle->getDefaultVehicle($_SESSION['user']['id']);
|
||||
$is_default = $default_vehicle ? 0 : 1;
|
||||
|
||||
$result = $vehicle->create([
|
||||
'name' => $name,
|
||||
'registration_plate' => strtoupper($registration_plate),
|
||||
'fuel_type' => $fuel_type,
|
||||
'note' => $note,
|
||||
'user_id' => $_SESSION['user']['id'],
|
||||
'is_default' => $is_default
|
||||
]);
|
||||
|
||||
|
||||
if ($result === true) {
|
||||
$this->redirect('/vehicles');
|
||||
$this->redirect('/');
|
||||
} else {
|
||||
$this->view('vehicles/create', ['title' => 'Create vehicle', 'error' => $result, 'validationErrors' => []] );
|
||||
}
|
||||
@ -72,7 +76,7 @@ class VehicleController extends Controller {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view('vehicles/index', ['title' => 'Vehicles', 'vehicles' => $vehicles]);
|
||||
header("Location: /vehicles");
|
||||
}
|
||||
|
||||
public function setDefault() {
|
||||
@ -84,7 +88,7 @@ class VehicleController extends Controller {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->view('vehicles/index', ['title' => 'Vehicles', 'vehicles' => $vehicles]);
|
||||
header("Location: /");
|
||||
}
|
||||
|
||||
public function api_get() {
|
||||
|
Reference in New Issue
Block a user