Ekapp/skolehjem/resources/views/admin/washing-reservations/index.blade.php

96 lines
3.6 KiB
PHP

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Vaskemaskine Reservationer - Vis
@endsection
@section("path")
<a href="{{ route('washing-reservations.index') }}" class="text-white">Vis Vaskemaskine Reservationer</a> /
@endsection
@section("content")
<div class="row align-items-center">
<!--<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('washing-reservations.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Reservation</a>!-->
<form method="post" action="{{ route("washing-reservations.store") }}">
@csrf
<input type="text" class="form-controller" id="search" name="search" placeholder="//TODO: Søg på vaskemaskine, tid, bruger"></input>
</form>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="vaskemaskine" value="vaskemaskine">
<label for="navn">Vaskemaskine</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="tidspunkt" value="tidspunkt">
<label for="efternavn">Tidspunkt</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="bruger" value="bruger">
<label for="email">Bruger</label>
</div>
<table class="tbl mt-2">
<tr>
<th>Vaskemaskine</th>
<th>Tidspunkt</th>
<th>Bruger</th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
</tr>
@foreach($reservations as $reservation)
<tr>
<td>{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</td>
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y \k\l\. H:i') }}</td>
<td>{{ ucfirst(\App\User::query()->find($reservation->user_id)->name_first) }} {{ ucfirst(\App\User::query()->find($reservation->user_id)->name_last) }}</td>
<td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>
@endforeach
</table>
{{ $reservations->links() }}
<script>
$('#search').on('keyup', function () {
$value = $(this).val();
$checkboxValue = $( "input:checked" ).val();
$.ajax({
type: 'get',
url: '{{route('washing-reservations.search')}}',
data: {'search':$value, 'isCheck': $checkboxValue},
success:function (data) {
$('tbody').html(data);
},
error:function (data) {
console.log(data);
}
});
})
</script>
<script>
$(document).ready(function(){
$("input:checkbox").on('click', function() {
var $box = $(this);
if ($box.is(":checked")) {
var group = "input:checkbox[name='" + $box.attr("name") + "']";
$(group).prop("checked", false);
$box.prop("checked", true);
} else {
$box.prop("checked", false);
}
});
});
</script>
@endsection