@extends('layouts.admin-app')

@section('content')

   <!--- <div class="pageheader">
        <h2><i class="fa fa-home"></i> Dashboard <span>Subtitle goes here...</span></h2>
        <div class="breadcrumb-wrapper">
            <span class="label">You are here:</span>
            <ol class="breadcrumb">
                <li class="active">Dashboard</li>
            </ol>
        </div>
    </div> -->

    <div class="contentpanel" smooth: true,>
        <div class="row">

            <div class="col-sm-12 col-lg-12">

                <div class="panel panel-default">
                    <div class="panel-body">

                        <div class="pull-right">
                            <div class="btn-group mr10">
                                <a href="{{ route('admin.video.create') }}" class="btn btn-white tooltips"
                                   data-toggle="tooltip" data-original-title="新增"><i
                                            class="fa fa-plus"></i></a>
                                <a class="btn btn-white tooltips deleteall" data-toggle="tooltip"
                                   data-original-title="删除" data-href="{{ route('admin.admin_user.destroy.all') }}"><i
                                            class="fa fa-trash"></i></a>
                            </div>
                        </div><!-- pull-right -->

                        <h5 class="subtitle mb5">视频列表</h5>

                        @include('admin._partials.show-page-status',['result'=>$videos])

                        <div class="table-responsive col-md-12">
                            <table class="table mb30">
                                <thead>
                                <tr>
                                    <th>
                                        <span class="ckbox ckbox-primary">
                                            <input type="checkbox" id="selectall"/>
                                            <label for="selectall"></label>
                                        </span>
                                    </th>
                                    <th>名称</th>
                                    <th>关键词</th>
                                    <th>摘要</th>
                                    <th>视频</th>
                                    <th>播放次数</th>
                                    <th>发布</th>
                                    <th>时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($videos as $video)
                                    <tr>
                                        <td>
                                            <div class="ckbox ckbox-default">
                                                <input type="checkbox" name="id" id="id-{{ $video->id }}" value="{{ $video->id }}" class="selectall-item"/>
                                                <label for="id-{{ $video->id }}"></label>
                                            </div>
                                        </td>
                                        <td>{{ $video->title }}</td>
                                        <td>{{ $video->keywords }}</td>
                                        <td>{{ $video->synopsis }}</td>
                                        <td>{{ $video->url }}</td>
                                        <td>{{ $video->number }}</td>
                                        <td>{{ $video->admin_user->name }}</td>
                                        <td>{{ $video->created_at }}</td>
                                        <td>
                                            <a href="{{ route('admin.video.edit', ['id' => $video->id]) }}" class="btn btn-white btn-sm"><i class="fa fa-pencil"></i> 编辑</a>
                                            <a class="btn btn-danger btn-sm video-delete"
                                               href="javascript:if (confirm('确定要删除？')) { $('#form-destroy-{{ $video->id }}').submit(); }"><i  class="fa fa-trash-o"></i> 删除</a>
                                            <form id="form-destroy-{{ $video->id }}" class="hidden" action="{{ route('admin.video.destroy', ['id'=>$video->id]) }}" method="POST">
                                                <input name="_method" type="hidden" value="DELETE">
                                                <input name="_token" type="hidden" value="{{ csrf_token() }}">
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>

                        {{ $videos->links() }}

                    </div><!-- panel-body -->
                </div><!-- panel -->

            </div><!-- col-sm-12 -->

        </div><!-- row -->
    </div><!-- contentpanel -->

    <script type="text/javascript">
        $(document).ready(function() {
            $(".user-delete").click(function () {
                return confirm("确认删除视频？");
            });
            $(".deleteall").click(function () {
                return confirm("确认删除选定视频？");
            });
            $("#selectall").click(function () {
                var v = this.checked;
                $("tbody input:checkbox").attr("checked", v);
            });
        });
    </script>
@endsection