126 lines
5.5 KiB
PHP
126 lines
5.5 KiB
PHP
@extends('layouts.vertical', ["page_title"=> "Datatables"])
|
|
|
|
@section('css')
|
|
<link href="{{asset('assets/libs/datatables/datatables.min.css')}}" rel="stylesheet" type="text/css" />
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 p-2">
|
|
<h4 class="page-title">{{$title}} Management</h4>
|
|
</div>
|
|
<div class="col-md-6 p-2">
|
|
@if(isset($buttons))
|
|
@foreach($buttons as $button)
|
|
<a href="{{$button['link']}}" class="btn btn-{{$button['title']=='Add New'?'success':($button['title']=='Refresh'?'info':'dark')}} waves-effect waves-light float-end me-2" id="btn-{{strtolower(str_replace(' ', '-', $button['title']))}}">{{$button['title']}}</a>
|
|
@endforeach
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
@if(session()->has('message'))
|
|
<div class="alert alert-success">
|
|
{{ session()->get('message') }}
|
|
</div>
|
|
@endif
|
|
@if(session()->has('error'))
|
|
<div class="alert alert-danger">
|
|
{{ session()->get('error') }}
|
|
</div>
|
|
@endif
|
|
|
|
<div class="alert alert-info">
|
|
Exports run in the background. Refresh this page to check whether your file is ready for download.
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<table id="list-page-datatable" class="table w-100 nowrap">
|
|
<thead>
|
|
<tr>
|
|
@foreach($fields as $field => $props)
|
|
<th>{{$props['title']}}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($items as $item)
|
|
<tr>
|
|
@foreach($fields as $field => $props)
|
|
@if($field != 'actions')
|
|
<td>
|
|
@switch($props['type'])
|
|
@case('text')
|
|
@case('select')
|
|
{{ isset($item->{$field}) ? $item->{$field} : '' }}
|
|
@break
|
|
@case('datetime')
|
|
@if(isset($item->{$field}) && $item->{$field})
|
|
{{ date("d M Y, h:iA", strtotime($item->{$field}) + 19800) }}
|
|
@endif
|
|
@break
|
|
@endswitch
|
|
</td>
|
|
@else
|
|
<td>
|
|
@foreach($props['buttons'] as $key => $button)
|
|
@switch($button)
|
|
@case('delete')
|
|
<a href="{{$base_url}}/delete?id={{$item->id}}" class="action-icon"> <i class="mdi mdi-delete text-danger"></i></a>
|
|
@break
|
|
@default
|
|
@php
|
|
$href = isset($button['href']) && $button['href'] != ''
|
|
? $item->{$button['href']}
|
|
: '';
|
|
$canDownload = isset($item->file_status)
|
|
&& $item->file_status === 'ready'
|
|
&& !empty($href)
|
|
&& $href !== '#';
|
|
@endphp
|
|
@if($canDownload)
|
|
<a href="{{$href}}" class="action-icon" target="_blank" rel="noopener"> <i class="mdi mdi-{{$button['icon']}}"></i></a>
|
|
@endif
|
|
@endswitch
|
|
@endforeach
|
|
</td>
|
|
@endif
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@section('script')
|
|
<script src="{{asset('assets/libs/datatables/datatables.min.js')}}"></script>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
$('#list-page-datatable').DataTable({
|
|
stateSave: true,
|
|
scrollX: true,
|
|
order: [[4, 'desc']],
|
|
language: {
|
|
paginate: {
|
|
previous: "<i class='mdi mdi-chevron-left'>",
|
|
next: "<i class='mdi mdi-chevron-right'>"
|
|
}
|
|
},
|
|
drawCallback: function () {
|
|
$('.dataTables_paginate > .pagination').addClass('pagination-rounded');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|