@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">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="sg-main-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>状态</th>
                                    <th>时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @if($list->count() <= 0)
                                    <tr>
                                        <td colspan="4" style="text-align: center;">暂无{{ $model_name }}</td>
                                    </tr>
                                @else
                                    @foreach($list as $item)
                                        <tr>
                                            <td>{{ $item->id }}</td>
                                            <td>{!! $item->getStatusLabel() !!}</td>
                                            <td>{{ $item->created_at }}</td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-sm btn-info btn-edit" href="{{ $pre_uri . 'show?id=' . $item->id }}">查看</a>
                                                    <div class="btn btn-sm btn-danger btn-delete" data-id="{{ $item->id }}">删除</div>
                                                </div>
                                            </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