@extends('admin._layout.layout')

@section('header')
    {{ trans('admin.head.cron_log') }}

    &nbsp;&nbsp;

@endsection

@section('main')
    <div class="row">
        <div class="col-md-12">

            <div class="panel">
                <div class="table-primary">
                    <table class="table table-striped table-bordered" id="cron-log-table" width="100%">
                        <thead>
                        <tr>
                            <th>{{ trans('admin.fields.id') }}</th>
                            <th>{{ trans('admin.cron_log.command') }}</th>
                            <th>{{ trans('admin.cron_log.expression') }}</th>
                            <th>{{ trans('admin.cron_log.next_execution') }}</th>
                            <th>{{ trans('admin.cron_log.start_at') }}</th>
                            <th>{{ trans('admin.cron_log.end_at') }}</th>
                            <th>{{ trans('admin.cron_log.execution_time') }}</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                        <tfoot>
                        <tr>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                            <th class="column-searchable"><input class="form-control table-footer-search" /></th>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <style>
        th{
            vertical-align: center;
        }
        td{
            vertical-align: center;
        }
    </style>
    <script>
        $(function() {
            var cron_log_table = $('#cron-log-table').DataTable({
                "processing": true,
                "serverSide": true,
                "pageLength": 20,
                "lengthMenu": [[15, 30], [15, 30]],
                "order": [[ 0, "desc" ]],
                "ajax": {
                    "url": "{{ route('admin.cron.log.list') }}"
                },
                "columns": [
                    {data: 'id', name: 'id'},
                    {data: 'command', name: 'command'},
                    {data: 'expression', name: 'expression'},
                    {data: 'next_execution', name: 'next_execution'},
                    {data: 'start_at', name: 'start_at'},
                    {data: 'end_at', name: 'end_at'},
                    {data: 'execution_time', name: 'execution_time'}
                ],
                "initComplete": function () {
                    this.api().columns().every(function () {
                        var column = this;
                        var column_class = column.footer().className;
                        if (column_class === 'column-searchable') {
                            var input = $(column.footer()).find('input');

                            input.on('change', function () {
                                column.search($(this).val(), false, false, true).draw();
                            });
                        }
                    });
                }
            });
        });
    </script>
@endsection