Filip Rojek
ccbb0eac64
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 12s
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
class DashboardController extends Controller {
|
|
public function index() {
|
|
$vehicle = new Vehicle();
|
|
$vehicles = $vehicle->getVehiclesByUser($_SESSION['user']['id']);
|
|
|
|
$default_car = $vehicle->getDefaultVehicle($_SESSION['user']['id']);
|
|
|
|
$refuel = new Refuel();
|
|
$data = [
|
|
"date" => [],
|
|
"price" => [],
|
|
];
|
|
$raw_data = $refuel->latest_data($default_car['id'], 5);
|
|
foreach($raw_data as $one) {
|
|
array_push($data['date'], date('d. m.', strtotime($one['created_at'])));
|
|
array_push($data['price'], $one['price_per_liter']);
|
|
}
|
|
|
|
$latest_record = [
|
|
'name',
|
|
'liters',
|
|
'price_per_liter',
|
|
'total_price',
|
|
'created_at'
|
|
];
|
|
|
|
$latest_record = $refuel->latest_one($_SESSION['user']['id'])[0];
|
|
|
|
$this->view('dashboard/index', [
|
|
'title' => 'Dashboard',
|
|
'vehicles' => $vehicles,
|
|
'date_price_data' => $data,
|
|
'default_car' => $default_car,
|
|
'latest_record' => $latest_record,
|
|
]);
|
|
}
|
|
|
|
public function reroute(){
|
|
$this->redirect('/dashboard');
|
|
}
|
|
}
|