Compare commits
No commits in common. "ea3afa2507281dc69d727c3b258c52a4ceb1e909" and "2201430f590c1823dc59a6a2de7d0d500d06410a" have entirely different histories.
ea3afa2507
...
2201430f59
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 121 KiB |
Binary file not shown.
Before Width: | Height: | Size: 72 KiB |
@ -53,13 +53,5 @@ php -S localhost:8000 -t ./public
|
|||||||
4. Track your fuel consumption and spending through the dashboard.
|
4. Track your fuel consumption and spending through the dashboard.
|
||||||
5. View detailed stats and graphs to analyze your driving habits.
|
5. View detailed stats and graphs to analyze your driving habits.
|
||||||
|
|
||||||
## Use case diagram
|
|
||||||

|
|
||||||
## Data logical model
|
|
||||||

|
|
||||||
|
|
||||||
## Class diagram
|
|
||||||

|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This project is licensed under GPL3.0 and later. More information is available in the `LICENSE` file.
|
This project is licensed under GPL3.0 and later. More information is available in the `LICENSE` file.
|
||||||
|
23
TODO.md
23
TODO.md
@ -12,7 +12,7 @@
|
|||||||
- [ ] remove/edit fuel record
|
- [ ] remove/edit fuel record
|
||||||
|
|
||||||
## Until release
|
## Until release
|
||||||
- [x] Sync offline data from locale storage
|
- [ ] Sync offline data from locale storage
|
||||||
- [ ] Include kilometer state of an car
|
- [ ] Include kilometer state of an car
|
||||||
- [ ] More charts
|
- [ ] More charts
|
||||||
- [ ] Average fuel conusption
|
- [ ] Average fuel conusption
|
||||||
@ -21,24 +21,3 @@
|
|||||||
- [ ] Average fuel conusption in last 30 days
|
- [ ] Average fuel conusption in last 30 days
|
||||||
- [ ] Kilometer state in last 30 days`
|
- [ ] Kilometer state in last 30 days`
|
||||||
- [ ] Offline navigation between dashboard and offline form
|
- [ ] Offline navigation between dashboard and offline form
|
||||||
|
|
||||||
## What has to be done
|
|
||||||
- [x] Vehicle delete
|
|
||||||
- [ ] intro tutorial when no car exist or just dont show anything
|
|
||||||
- [ ] change/set default car
|
|
||||||
- [ ] hide errors
|
|
||||||
|
|
||||||
## Nice to have
|
|
||||||
- [ ] specific car view - charts, fuel records
|
|
||||||
- [ ] remove/edit fuel record
|
|
||||||
- [ ] Include kilometer state of an car
|
|
||||||
- [ ] More charts
|
|
||||||
- [ ] Average fuel conusption
|
|
||||||
- [ ] Kilometer state
|
|
||||||
- [ ] More cards
|
|
||||||
- [ ] Average fuel conusption in last 30 days
|
|
||||||
- [ ] Kilometer state in last 30 days`
|
|
||||||
- [ ] Offline navigation between dashboard and offline form
|
|
||||||
- [ ] Fix vehicle deletion - wrong redirect
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,23 +56,7 @@ class VehicleController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
if(!$_SERVER['REQUEST_METHOD'] === 'POST') {
|
// TODO: Delete vehicle (to be implemented later)
|
||||||
echo "Wrong method";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Validate the request
|
|
||||||
$vehicle_id = $_POST['vehicle_id'];
|
|
||||||
|
|
||||||
$vehicle = new Vehicle();
|
|
||||||
$result = $vehicle->delete($vehicle_id, $_SESSION['user']['id']);
|
|
||||||
|
|
||||||
if($result != true) {
|
|
||||||
echo "Something went wrong";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->view('vehicles/index', ['title' => 'Vehicles', 'vehicles' => $vehicles]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function api_get() {
|
public function api_get() {
|
||||||
|
@ -60,28 +60,4 @@ class Vehicle {
|
|||||||
|
|
||||||
return $result->fetch_assoc();
|
return $result->fetch_assoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($vehicle_id, $user_id) {
|
|
||||||
try {
|
|
||||||
$stmt = $this->db->prepare("SELECT id FROM vehicles WHERE id = ? AND user_id = ?");
|
|
||||||
$stmt->bind_param("ii", $vehicle_id, $user_id);
|
|
||||||
$stmt->execute();
|
|
||||||
$result = $stmt->get_result();
|
|
||||||
|
|
||||||
if ($result->num_rows === 0) {
|
|
||||||
return "Error: Unauthorized action or vehicle not found.";
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt = $this->db->prepare("DELETE FROM vehicles WHERE id = ?");
|
|
||||||
$stmt->bind_param("i", $vehicle_id);
|
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return "Error: " . $stmt->error;
|
|
||||||
}
|
|
||||||
} catch (mysqli_sql_exception $e) {
|
|
||||||
return $e->getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,8 @@
|
|||||||
<p><?= htmlspecialchars($vehicle['fuel_type']) ?></p>
|
<p><?= htmlspecialchars($vehicle['fuel_type']) ?></p>
|
||||||
<p><?= htmlspecialchars($vehicle['note'] ?? "") ?></p>
|
<p><?= htmlspecialchars($vehicle['note'] ?? "") ?></p>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<form method="POST" action="/vehicles/delete">
|
<a href="/vehicles/edit?id=<?= $vehicle['id'] ?>">Edit</a>
|
||||||
<input type="number" name="vehicle_id" value="<?= $vehicle['id'] ?>" style="display: none">
|
<a href="/vehicles/delete?id=<?= $vehicle['id'] ?>" onclick="return confirm('Are you sure you want to delete this habit?')">Delete</a>
|
||||||
<input type="submit" value="Delete vehicle" class="btn-danger">
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -46,7 +46,7 @@ $router->group('/vehicles', ['RequireAuth'], function ($router) {
|
|||||||
$router->add('', 'VehicleController@index');
|
$router->add('', 'VehicleController@index');
|
||||||
$router->add('/create', 'VehicleController@create');
|
$router->add('/create', 'VehicleController@create');
|
||||||
$router->add('/edit/{id}', 'VehicleController@edit');
|
$router->add('/edit/{id}', 'VehicleController@edit');
|
||||||
$router->add('/delete', 'VehicleController@delete');
|
$router->add('/delete/{id}', 'VehicleController@delete');
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->group('/refuel', ['RequireAuth'], function ($router) {
|
$router->group('/refuel', ['RequireAuth'], function ($router) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user