Ekapp/skolehjem/resources/views/admin/feedbacks/index.blade.php

91 lines
3.0 KiB
PHP
Raw Normal View History

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Feedback - Vis
@endsection
@section("path")
<a href="{{ route('feedbacks.index') }}" class="text-white">Vis Feedback</a> /
@endsection
2020-08-03 08:08:03 +00:00
@section("content")
<style>
.letterSpaceTable{
letter-spacing: 1.2px;
}
</style>
<table class="tbl letterSpaceTable" id="table_id">
<thead>
<th class="w-6em">Dato</th>
<th>Feedback Besked</th>
<th class="w-7em">Feedback type</th>
@if(auth()->user()->can('feedback.delete'))
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
@endif
</thead>
<tbody>
@foreach($feedback as $fb)
2020-12-01 11:05:18 +00:00
<tr id="row_{{ $fb->id }}">
<td>{{ date('d-m-Y', strtotime($fb->created_at)) }}</td>
<td>{{ $fb->message }}</td>
<td>{{ $fb->suggestion_form }}</td>
@if(auth()->user()->can('feedback.delete'))
2020-12-01 11:05:18 +00:00
<td>
@csrf
<a class="w-100 nostyle" onclick="delete_feedback({{ $fb->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
@endsection
@section('scripts')
2020-08-03 08:08:03 +00:00
<script>
$(document).ready( function () {
$('#table_id').DataTable({
columnDefs: [
{ orderable: false, targets: [-1] }
]
2020-08-03 08:08:03 +00:00
});
});
2020-12-01 11:05:18 +00:00
function delete_feedback(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 Feedback',
cancelButtonText: 'Annuller'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "POST",
url: "feedbacks/"+id,
data:{'_token':token, _method: 'DELETE'},
success: function () {
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
Swal.fire(
'Feedbacken er slettet!',
'',
'success'
)
},
error:function (data) {
console.log(data);
}
});
}
})
}
2020-08-03 08:08:03 +00:00
</script>
@endsection