Permission fixes and washing reservation fixes
This commit is contained in:
@@ -15,13 +15,20 @@
|
||||
@csrf
|
||||
<label for="time">Tidspunkt:</label>
|
||||
<input type="datetime-local" name="time" id="time" required>
|
||||
<label for="machine">Vaskemaskine:</label>
|
||||
<select name="machine" id="machine" required>
|
||||
<label for="machine_id">Vaskemaskine:</label>
|
||||
<select name="machine_id" id="machine_id" required>
|
||||
<option disabled selected value> -- Vælg Vaskemaskine -- </option>
|
||||
@foreach($machines as $machine)
|
||||
<option value="{{ $machine->id }}">{{ $machine->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label for="user_id">Bruger:</label>
|
||||
<select name="user_id" id="user_id" required>
|
||||
<option disabled selected value> -- Vælg Bruger -- </option>
|
||||
@foreach($users as $user)
|
||||
<option value="{{ $user->id }}">{{ ucfirst($user->name_first) }} {{ ucfirst($user->name_last) }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input type="submit" class="btn btn-dark text-white" value="Opret">
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</tr>
|
||||
@foreach($reservations as $reservation)
|
||||
<tr>
|
||||
<td>{{ \App\WashingMachine::query()->find($reservation->machine)->name }}</td>
|
||||
<td>{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</td>
|
||||
<td>{{ $reservation->time }}</td>
|
||||
<td><a href="{{ route('washing-reservations.edit', ['washing_reservation' => $reservation]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@extends("app.layout.base")
|
||||
@extends("app.layout.header")
|
||||
|
||||
@section("title")
|
||||
Booking Liste
|
||||
@endsection
|
||||
@@ -27,6 +27,7 @@
|
||||
</div>
|
||||
<form method="post" action="{{ route("washing-reservations.store") }}" id="event-container" class="events-container">
|
||||
@csrf
|
||||
<input type="hidden" value="{{auth()->user()->id}}" name="user_id">
|
||||
<p>
|
||||
Maskiner skal dynamisk opdateres alt efter om det er en fra bygning E eller en af de andre bygninger der vil vaske, da bygning E har egen vaskekælder!
|
||||
</p>
|
||||
@@ -112,7 +113,7 @@
|
||||
|
||||
axios({
|
||||
method: 'get',
|
||||
url: '/washing-reservationsapi',
|
||||
url: '{{ route("washing-reservations.api") }}',
|
||||
params: { 'date': date }
|
||||
}).then(function (response) {
|
||||
var data = response.data;
|
||||
@@ -127,7 +128,7 @@
|
||||
let select = document.createElement("select");
|
||||
select.classList.add("events__title");
|
||||
select.id = "washing-machines";
|
||||
select.name = "machine";
|
||||
select.name = "machine_id";
|
||||
|
||||
container.appendChild(span);
|
||||
container.appendChild(select);
|
||||
@@ -139,7 +140,7 @@
|
||||
else {
|
||||
let span = document.createElement("span");
|
||||
span.classList.add("events__title");
|
||||
span.innerText = "Tider";
|
||||
span.innerText = "Tilgængelige tider";
|
||||
|
||||
let select = document.createElement("select");
|
||||
select.classList.add("events__title");
|
||||
@@ -178,13 +179,33 @@
|
||||
|
||||
events.innerHTML = "";
|
||||
for (let hour = 8; hour <= 20; hour++) {
|
||||
|
||||
let value = data["date"].split("T")[0].slice(1, data["date"].split("T")[0].length) + "T" + prependZero(hour) + ":00";
|
||||
let option = document.createElement("option");
|
||||
option.text = prependZero(hour) + ":00";
|
||||
option.value = data["date"].split("T")[0].slice(1, data["date"].split("T")[0].length) + "T" + prependZero(hour) + ":00";
|
||||
|
||||
option.text = prependZero(hour) + ":00";
|
||||
option.value = value;
|
||||
option.id = value;
|
||||
events.appendChild(option);
|
||||
}
|
||||
|
||||
let unavailable_times = data["unavailable_times"];
|
||||
|
||||
unavailable_times.forEach(function (item, index) {
|
||||
console.log(item);
|
||||
document.getElementById(item).remove();
|
||||
});
|
||||
|
||||
if(events.childElementCount == 0){
|
||||
let option = document.createElement("option");
|
||||
option.disabled = "disabled";
|
||||
option.text = "Der er ingen tilgængelige tider";
|
||||
option.selected = "selected";
|
||||
events.appendChild(option);
|
||||
|
||||
document.getElementById("create-reservation").disabled = "disabled";
|
||||
} else {
|
||||
document.getElementById("create-reservation").disabled = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
@extends("app.layout.base")
|
||||
@extends("app.layout.header")
|
||||
@section("title")
|
||||
Booking Liste
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user