Added: vehicle creation
This commit is contained in:
35
app/views/vehicles/create.php
Normal file
35
app/views/vehicles/create.php
Normal file
@ -0,0 +1,35 @@
|
||||
<link rel="stylesheet" href="/css/form.css">
|
||||
<link rel="stylesheet" href="/css/vehicle_create.css">
|
||||
<section class="form">
|
||||
<h1 class="header-form"><?= $this->get('title', 'Create Vehicle') ?></h1>
|
||||
|
||||
<?php if ($this->get('error')): ?>
|
||||
<div class="error" style="color: red; margin-bottom: 1rem;">
|
||||
<?= htmlspecialchars($this->get('error')) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="/vehicles/add">
|
||||
<label for="name">Vehicle name</label>
|
||||
<input type="text" name="name" id="name" required value="<?= htmlspecialchars($_POST['name'] ?? '') ?>">
|
||||
|
||||
<label for="registration_plate">Registration plate</label>
|
||||
<input type="text" name="registration_plate" id="registration_plate" maxlength="10" onkeypress="return event.charCode != 32" required value="<?= htmlspecialchars($_POST['registration_plate'] ?? '') ?>">
|
||||
|
||||
<label for="fuel_type">Fuel type</label>
|
||||
<select name="fuel_type" id="fuel_type">
|
||||
<option value="Diesel">Diesel</option>
|
||||
<option value="Gasoline 95">Gasoline 95</option>
|
||||
<option value="Gasoline 98">Gasoline 98</option>
|
||||
<option value="Premium Diesel">Premium Diesel</option>
|
||||
<option value="Premium Gasoline 95">Premium Gasoline 95</option>
|
||||
<option value="Premium Gasoline 98">Premium Gasoline 98</option>
|
||||
<option value="Other">Other</option>
|
||||
</select>
|
||||
|
||||
<label for="note">Note</label>
|
||||
<input type="text" name="note" id="note" value="<?= htmlspecialchars($_POST['note'] ?? '') ?>">
|
||||
|
||||
<input type="submit" value="Create vehicle">
|
||||
</form>
|
||||
</section>
|
0
app/views/vehicles/edit.php
Normal file
0
app/views/vehicles/edit.php
Normal file
19
app/views/vehicles/index.php
Normal file
19
app/views/vehicles/index.php
Normal file
@ -0,0 +1,19 @@
|
||||
<link rel="stylesheet" href="/css/vehicles.css">
|
||||
<section class="vehicles">
|
||||
<?php if (empty($this->get('vehicles'))): ?>
|
||||
<p>No vehicles yet. <a href="/vehicles/add">Add your first vehicle</a>.</p>
|
||||
<?php else: ?>
|
||||
<div class="vehicle-wrapper">
|
||||
<?php foreach ($this->get('vehicles') as $vehicle): ?>
|
||||
<div class="vehicle bordered">
|
||||
<b><?= htmlspecialchars($vehicle['name']) ?></b>
|
||||
<a href="/vehicles/edit?id=<?= $vehicle['id'] ?>">Edit</a> |
|
||||
<a href="/vehicles/delete?id=<?= $vehicle['id'] ?>" onclick="return confirm('Are you sure you want to delete this habit?')">Delete</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<a href="/vehicles/create" class="btn-green">Add new vehicle!</a>
|
||||
<?php endif; ?>
|
||||
</section>
|
Reference in New Issue
Block a user