Ekapp/skolehjem/resources/views/admin/events/signups.blade.php

83 lines
2.9 KiB
PHP

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Events - Tilmeldte
@endsection
@section("path")
<a href="{{ route("events.index") }}" class="text-white">Vis Events</a> / <a href="" class="text-white">Vis Tilmeldte - {{ $events[0]->name }}</a> /
@endsection
@section("content")
<table class="tbl mt-1" id="table_id">
<thead>
<th>Tilmeldtes Fornavn</th>
<th>Tilmeldtes Efternavn</th>
<th>Tilmeldtes Tlf Nr</th>
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
</thead>
<tbody>
@foreach($events as $event)
@if($event->user_id != null)
<tr id="row_{{ $event->id }}">
<td>{{ $event->name_first }}</td>
<td>{{ $event->name_last }}</td>
<td>{{ $event->phone }}</td>
<td>
@csrf
<a class="w-100 nostyle" onclick="delete_userevent({{ $event->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
@endsection
@section('scripts')
<script>
$(document).ready( function () {
$('#table_id').DataTable({
columnDefs: [
{ orderable: false, targets: [-1] }
]
});
});
function delete_userevent(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: 'Fjern brugeren fra aktiviteten',
cancelButtonText: 'Annuller'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "POST",
url: "/events/"+id,
data:{'_token':token, _method: 'DELETE', 'signup': true},
success: function () {
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
Swal.fire(
'Brugeren er fjernet fra aktiviteten!',
'',
'success'
)
},
error:function (data) {
console.log(data);
}
});
}
})
}
</script>
@endsection