@extends('admin.layout')

@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>专业信息</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 method="GET" action="" accept-charset="UTF-8">

                            <div class="col-sm-4">
                                <div class="input-group">
                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="年份/院校/专业/省份/科类"
                                           name="keyword" class="input-sm form-control">
                                    <span class="input-group-btn">
									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
								</span>
                                </div>
                            </div>
                        </form>
                        @if(role('Major/Info/create'))
                            <div class="col-sm-4 pull-right">
                                <a href="{{ U('Major/Info/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>

                                <form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" action="{{ U('Major/Info/import')}}">
                                    {{csrf_field()}}
                                            <input type="file" name="test"  id="form-field-4" class="col-xs-12 col-sm-6 file" />
                                            <button class="btn btn-sm btn-primary pull-right" style="margin-right: 5px" type="submit">
                                                Excel导入
                                            </button>
                                </form>
                            </div>
                        @endif
                    </div>

                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                        <thead>
                        <tr>
                            <th class="sorting" data-sort="year"> 年份</th>
                            <th class="sorting" data-sort="college"> 院校名称</th>
                            <th class="sorting" data-sort="class"> 科类</th>
                            <th class="sorting" data-sort="province"> 省份</th>
                            <th class="sorting" data-sort="major"> 专业名称</th>
                            <th class="sorting" data-sort="min_grade"> 最低分</th>
                            <th class="sorting" data-sort="max_grade">最高分</th>
                            <th class="sorting" data-sort="avg_grade'">平均分</th>
                            <th class="sorting" data-sort="min_rank">最低位次</th>
                            <th class="sorting" data-sort="max_rank">最高位次</th>
                            <th class="sorting" data-sort="avg_rank">平均位次</th>
                            <th class="sorting" data-sort="comment">备注</th>
                            <th width="22%">相关操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @if(isset($list))
                            @foreach($list as $key => $item)
                                <tr>
                                    <td>{{ $item->year }}</td>
                                    <td>{{ $item->college }}</td>
                                    <td>{{ $item->class }}</td>
                                    <td>{{ $item->province }}</td>
                                    <td>{{ $item->major }}</td>
                                    <td>{{ $item->min_grade }}</td>
                                    <td>{{ $item->max_grade }}</td>
                                    <td>{{ $item->avg_grade }}</td>
                                    <td>{{ $item->min_rank }}</td>
                                    <td>{{ $item->max_rank }}</td>
                                    <td>{{ $item->avg_rank }}</td>
                                    <td>{{ $item->comment }}</td>
                                    <td>
                                        <div class="btn-group">
                                            <button data-toggle="dropdown"
                                                    class="btn btn-warning btn-sm dropdown-toggle"
                                                    aria-expanded="false">
                                                操作 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">


                                                @if(role('Major/Info/update'))
                                                    <li><a href="{{ U('Major/Info/update',['id'=>$item->id])}}"
                                                           class="font-bold">修改</a></li>
                                                @endif

                                                @if(role('Major/Info/destroy'))
                                                    <li class="divider"></li>
                                                    <li><a href="{{ U('Major/Info/destroy',['id'=>$item->id])}}"
                                                           onclick="return confirm('你确定执行删除操作？');">删除</a></li>
                                                @endif

                                            </ul>
                                        </div>
                                        @if(role('Major/Info/view'))
                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Major/Info/view',['id'=>$item->id])}}'});"
                                                    class="btn btn-primary ">查看
                                            </button>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                        @endif

                        </tbody>
                    </table>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="dataTables_info" id="DataTables_Table_0_info"
                                 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
                                条，共{{ $list->lastPage() }}页，总{{ $list->total() }}条。
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {!! $list->setPath('')->appends(Request::all())->render() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection