v1.3.0 - Implemented DataTables
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
<?php
|
||||
date_default_timezone_set('Europe/Copenhagen');
|
||||
?>
|
||||
<table class="tbl mt-0">
|
||||
<tr>
|
||||
<table class="tbl mt-0" id="table_id">
|
||||
<thead>
|
||||
<th>Lokation</th>
|
||||
<th>Vaskemaskine</th>
|
||||
<th>Tidspunkt</th>
|
||||
@@ -22,67 +22,38 @@
|
||||
@if(auth()->user()->can('washing.machine.reservation.delete'))
|
||||
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
||||
@endif
|
||||
</tr>
|
||||
@foreach($reservations as $reservation)
|
||||
@if(date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time)
|
||||
<tr>
|
||||
<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'))
|
||||
<td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
@method("delete")
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($reservations as $reservation)
|
||||
@if(date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time)
|
||||
<tr>
|
||||
<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'))
|
||||
<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>
|
||||
@endif
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
<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>
|
||||
@endif
|
||||
</tr>
|
||||
@endif
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ $reservations->links() }}
|
||||
|
||||
|
||||
@endsection
|
||||
@section('scripts')
|
||||
<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);
|
||||
}
|
||||
$(document).ready( function () {
|
||||
$('#table_id').DataTable({
|
||||
columnDefs: [
|
||||
{ orderable: false, targets: -1 }
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user