@extends('admin.layout')
<style type="text/css">

</style>
@section('header')

@endsection

@section('content')
<div id="sg-main-container-sg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{{ $model_name . '记录' }}</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form>
                                <div class="col-sm-3 form-group">
                                    <input type="text" class="form-control datepicker" name="begin_date" value="{{ request('begin_date') }}" placeholder="开始时间" autocomplete="off">
                                </div>
                                <div class="col-sm-3 form-group">
                                    <input type="text" class="form-control datepicker" name="end_date" value="{{ request('end_date') }}" placeholder="截止时间" autocomplete="off">
                                </div>
                                <div class="col-sm-3 form-group">
                                    <input type="text" class="form-control" name="keyword" value="{{ request('keyword') }}" placeholder="请输入学员/课程名搜索">
                                </div>
                                <div class="col-sm-3">
                                    <button type="submit" class="btn btn-sm btn-primary">搜索</button>
                                </div>
                            </form>
                        </div>
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="sg-main-table">
                            <thead>
                                <tr>
                                    <th>姓名</th>
                                    <th>课程名称</th>
                                    <th>开始打卡</th>
                                    <th>结束打卡</th>
                                    <th>累计时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if($list->count() <= 0)
                                    <tr>
                                        <td colspan="5" style="text-align: center;">暂无{{ $model_name }}</td>
                                    </tr>
                                @else
                                    @foreach($list as $item)
                                        <tr>
                                            <td>{{ $item->student->name }}</td>
                                            <td>{{ $item->course->name }}</td>
                                            <td>{{ $item->begin_date_time }}</td>
                                            <td>{{ $item->end_date_time }}</td>
                                            <td>{{ $item->duration }}</td>
                                        </tr>
                                    @endforeach
                                @endif
                            </tbody>
                        </table>
                        <div class="row">
                            <div class="col-sm-12">{{ $list->links() }}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-labelledby="delete-label" aria-hidden="true">
    <div class="modal-dialog">
        <form id="delete-form" method="POST" action="{{ $pre_uri . 'delete' }}">
            {{ csrf_field() }}

            <input type="hidden" name="id" id="delete-input-id">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="delete-label">确定要删除吗？</h4>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-danger">删除</button>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection

@section('footer')
<script type="text/javascript">
$(function () {
    $('#sg-main-table').on('click', '.btn-delete', function () {
        $('#delete-input-id').val($(this).attr('data-id'));
        $('#delete-modal').modal('show');
    });
})
</script>
@endsection