2020-06-25 11:30:58 +00:00
|
|
|
@extends("admin.layout.base")
|
|
|
|
@extends("admin.layout.header")
|
|
|
|
|
|
|
|
@section("title")
|
2020-06-29 06:13:53 +00:00
|
|
|
Vaskemaskine Reservationer - Vis
|
2020-06-25 11:30:58 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("path")
|
2020-06-29 06:13:53 +00:00
|
|
|
<a href="{{ route('washing-reservations.index') }}" class="text-white">Vis Vaskemaskine Reservationer</a> /
|
2020-06-25 11:30:58 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("content")
|
2020-08-20 10:18:30 +00:00
|
|
|
<?php
|
|
|
|
date_default_timezone_set('Europe/Copenhagen');
|
|
|
|
?>
|
2020-10-21 07:12:53 +00:00
|
|
|
<style>
|
|
|
|
.letterSpaceTable{
|
|
|
|
letter-spacing: 1.2px;
|
|
|
|
}
|
|
|
|
</style>
|
2020-11-24 12:14:25 +00:00
|
|
|
<table class="tbl mt-0 letterSpaceTable fixOverflow" id="table_id">
|
2020-09-18 08:04:33 +00:00
|
|
|
<thead>
|
2020-08-17 13:06:48 +00:00
|
|
|
<th>Lokation</th>
|
2020-06-25 11:30:58 +00:00
|
|
|
<th>Vaskemaskine</th>
|
2020-07-29 11:43:18 +00:00
|
|
|
<th>Tidspunkt</th>
|
|
|
|
<th>Bruger</th>
|
2020-08-31 08:57:26 +00:00
|
|
|
@if(auth()->user()->can('washing.machine.reservation.delete'))
|
2020-11-26 09:19:12 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
2020-08-31 08:57:26 +00:00
|
|
|
@endif
|
2020-09-18 08:04:33 +00:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach($reservations as $reservation)
|
|
|
|
@if(date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time)
|
2020-12-01 11:05:18 +00:00
|
|
|
<tr id="row_{{ $reservation->id }}">
|
2020-09-18 08:04:33 +00:00
|
|
|
<td>{{ \App\Location::query()->find(\App\WashingMachine::query()->find($reservation->machine_id)->location_id)->name }}</td>
|
|
|
|
<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>
|
|
|
|
@if(auth()->user()->can('washing.machine.reservation.delete'))
|
2020-12-01 11:05:18 +00:00
|
|
|
<td>
|
|
|
|
@csrf
|
|
|
|
<a class="w-100 nostyle" onclick="delete_reservation({{ $reservation->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
2020-09-18 08:04:33 +00:00
|
|
|
</td>
|
|
|
|
@endif
|
|
|
|
</tr>
|
|
|
|
@endif
|
|
|
|
@endforeach
|
|
|
|
</tbody>
|
2020-06-25 11:30:58 +00:00
|
|
|
</table>
|
2020-09-18 08:04:33 +00:00
|
|
|
@endsection
|
|
|
|
@section('scripts')
|
2020-07-29 13:27:07 +00:00
|
|
|
<script>
|
2020-09-18 08:04:33 +00:00
|
|
|
$(document).ready( function () {
|
|
|
|
$('#table_id').DataTable({
|
|
|
|
columnDefs: [
|
|
|
|
{ orderable: false, targets: -1 }
|
|
|
|
]
|
2020-07-29 13:27:07 +00:00
|
|
|
});
|
|
|
|
});
|
2020-12-01 11:05:18 +00:00
|
|
|
|
|
|
|
function delete_reservation(id) {
|
|
|
|
var token = $("input[name='_token']").val();
|
|
|
|
|
|
|
|
Swal.fire({
|
|
|
|
title: 'Er du sikker?',
|
|
|
|
text: "Dette kan ikke blive ændret tilbage!",
|
|
|
|
icon: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
confirmButtonColor: '#3085d6',
|
|
|
|
cancelButtonColor: '#d33',
|
|
|
|
confirmButtonText: 'Slet Reservationen',
|
|
|
|
cancelButtonText: 'Annuller'
|
|
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "/washing-reservations/"+id,
|
|
|
|
data:{'_token':token, _method: 'DELETE'},
|
|
|
|
success: function () {
|
|
|
|
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
|
|
|
|
|
|
|
|
Swal.fire(
|
|
|
|
'Reservationen er slettet!',
|
|
|
|
'',
|
|
|
|
'success'
|
|
|
|
)
|
|
|
|
},
|
|
|
|
error:function (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2020-07-29 13:27:07 +00:00
|
|
|
</script>
|
2020-06-25 11:30:58 +00:00
|
|
|
@endsection
|