@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">
                            <div class="col-sm-12 pull-right">
                                <a href="{{ $pre_uri . 'index?student_id=' . $student->id }}" class="btn btn-sm btn-primary pull-right">返回列表</a>
                            </div>
                        </div>
                        <form class="form-horizontal" method="POST" action="{{ $pre_uri . 'store' }}">
                            {{ csrf_field() }}

                            <input type="hidden" name="data[student_id]" value="{{ $student->id }}">
                            <div class="form-group row">
                                <label class="col-sm-2 col-sm-offset-1 control-label">合同编号</label>
                                <div class="col-sm-8">
                                    <input type="text" name="data[number]" class="form-control" placeholder="请输入合同编号" value="{{ isset(old('data')['number']) ? old('data')['number'] : '' }}" required>
                                </div>
                                @if($errors->has('number'))
                                    <span class="help-block">{{ $errors->first('number') }}</span>
                                @endif
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-sm-offset-1 control-label">课程种类</label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="data[course_id]">
                                        @foreach($courses as $course)
                                            <option value="{{ $course->id }}" {{ isset(old('data')['course_id']) && old('data')['course_id'] == $course->id ? 'selected' : '' }}>{{ $course->name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                                @if($errors->has('course_id'))
                                    <span class="help-block">{{ $errors->first('course_id') }}</span>
                                @endif
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-sm-offset-1 control-label">报名日期</label>
                                <div class="col-sm-8">
                                    <input type="text" name="data[apply_date]" class="form-control datepicker" placeholder="请输入报名日期" value="{{ isset(old('data')['apply_date']) ? old('data')['apply_date'] : \Carbon\Carbon::now()->toDateString() }}" readonly>
                                </div>
                                @if($errors->has('apply_date'))
                                    <span class="help-block">{{ $errors->first('apply_date') }}</span>
                                @endif
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-sm-offset-1 control-label">课程持续时间</label>
                                <div class="col-sm-8">
                                    <input type="text" name="data[duration]" class="form-control" placeholder="请输入课程持续时间" value="{{ isset(old('data')['duration']) ? old('data')['duration'] : '' }}">
                                </div>
                                @if($errors->has('duration'))
                                    <span class="help-block">{{ $errors->first('duration') }}</span>
                                @endif
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-sm-offset-1 control-label">讲师分配</label>
                                <div class="col-sm-8">
                                    <label class="checkbox-inline">
                                        <input type="checkbox" class="sg-checkbox" id="check-all-teachers" name="assign_teacher" value="1">所有讲师
                                    </label>
                                    @foreach($teachers as $teacher)
                                        <label class="checkbox-inline">
                                            <input type="checkbox" class="sg-checkbox teachers-checkbox" name="teachers[]" value="{{ $teacher->id }}">{{ $teacher->name }}
                                        </label>
                                    @endforeach
                                </div>
                            </div>

                            <div class="form-group row">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button type="submit" class="btn btn-sm btn-primary">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('footer')
<script type="text/javascript">
$(function () {

})
</script>
@endsection