@extends('layouts.master')

@section('navigation')
    @include('local.managers.admins._new_navigation')
@stop
@section('main')

    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-default panel-button">
                <div class="panel-heading">
                    Reassign Course Programs
                </div>
                <div class="panel-body">

                    <p>Use this to reassign courses matching your specified criteria to the program of your choice. Use
                        <strong>*</strong> (asterisk) to do a wildcard search at the beginning or end. At least
                        <strong>one</strong> field is required.</p>

                    <p>As an example, the following will assign all courses with a code <strong>starting</strong> with 'MAT'
                        and a number <strong>starting</strong> with '3' to the Mathematics Program.</p>
                    <ul>
                        <li>Code: MAT*</li>
                        <li>Number: 3*</li>
                        <li>Program: Mathematics</li>
                    </ul>

                    {{ Form::open(['action' => 'CoursesController@update']) }}

                    <div class="form-group">
                        {{ Form::label('code', 'Code') }}
                        {{ Form::text('code', Input::old('code'), ['class' => 'form-control', 'placeholder' => 'TEST', 'maxLength' => 5]) }}
                    </div>

                    <div class="form-group">
                        {{ Form::label('number', 'Number') }}
                        {{ Form::text('number', Input::old('number'), ['class' => 'form-control', 'placeholder' => '3001', 'maxLength' => 5]) }}
                    </div>

                    <div class="form-group">
                        {{ Form::label('section', 'Section') }}
                        {{ Form::text('section', Input::old('section'), ['class' => 'form-control', 'placeholder' => '001', 'maxLength' => 4]) }}
                    </div>

                    <!-- Program -->
                    <div class="form-group">
                        {{ Form::label('program', 'Program') }}
                        <select id="program" name="program" class="form-control">
                            @foreach ($programs as $program)
                                @if (Input::old('program') != $program->id)
                                    <option value="{{ $program->id }}">{{ $program->name }}
                                        ({{ $program->school->name }})</option>
                                @else
                                    <option selected value="{{ $program->id }}">{{ $program->name }}
                                        ({{ $program->school->name }})</option>
                                @endif
                            @endforeach
                        </select>
                    </div>

                    <br>

                    {{ Form::submit('Submit', ['class' => 'btn btn-primary btn-block', 'name' => 'reassign_program']) }}
                    {{ Form::close() }}

                    <br>

                    @if (Session::has('courses'))
                        <p><strong>The following courses were updated:</strong></p>
                        <ul>
                            @foreach (json_decode(Session::get('courses')) as $course)
                                <li>

                                    @if (Session::has('show_sections'))
                                        {{ $course->code }}{{ $course->number }}-{{ $course->section }}
                                    @else
                                        {{ $course->code }}{{ $course->number }}
                                    @endif
                                </li>
                            @endforeach
                        </ul>
                    @endif
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="panel panel-default panel-button">
                <div class="panel-heading">
                    Reassign Sections' Professors
                </div>
                <div class="panel-body">

                    <p>Use this to reassign a section to a specific professor. Write down the code, number and section of
                        the course. Then, choose a professor from the list. <strong>All fields are required.</strong></p>

                    {{ Form::open(['action' => 'CoursesController@update']) }}

                    <div class="form-group">
                        {{ Form::label('code_prof', 'Code') }}
                        {{ Form::text('code_prof', Input::old('code_prof'), ['class' => 'form-control', 'placeholder' => 'TEST', 'maxLength' => 4]) }}
                    </div>

                    <div class="form-group">
                        {{ Form::label('number_prof', 'Number') }}
                        {{ Form::text('number_prof', Input::old('number_prof'), ['class' => 'form-control', 'placeholder' => '3001', 'maxLength' => 4]) }}
                    </div>

                    <div class="form-group">
                        {{ Form::label('section_prof', 'Section') }}
                        {{ Form::text('section_prof', Input::old('section_prof'), ['class' => 'form-control', 'placeholder' => '001', 'maxLength' => 3]) }}
                    </div>

                    <!-- Program -->
                    <div class="form-group">
                        {{ Form::label('user_prof', 'User') }}
                        <select id="user_prof" name="user_prof" class="form-control">
                            @foreach ($users as $user)
                                @if (Input::old('user_prof') != $user->id)
                                    <option value="{{ $user->id }}">{{ $user->surnames }},
                                        {{ $user->first_name }}</option>
                                @else
                                    <option selected value="{{ $user->id }}">{{ $user->surnames }},
                                        {{ $user->first_name }}</option>
                                @endif
                            @endforeach
                        </select>
                    </div>

                    <!-- Semester -->
                    <div class="form-group">
                        {{ Form::label('semester_prof', 'Semester') }}
                        <select id="semester_prof" name="semester_prof" class="form-control">
                            @foreach ($semesters as $semester)
                                @if (Input::old('semester_prof') != $semester->id)
                                    <option value="{{ $semester->id }}">{{ $semester->name }}</option>
                                @else
                                    <option selected value="{{ $semester->id }}">{{ $semester->name }}</option>
                                @endif
                            @endforeach
                        </select>
                    </div>

                    <br>

                    {{ Form::submit('Submit', ['class' => 'btn btn-primary btn-block', 'name' => 'reassign_professor']) }}
                    {{ Form::close() }}

                </div>
            </div>
        </div>
    </div>
@stop

@section('javascript')

    // --------------------------------------------------------------------------
    // Page load
    // --------------------------------------------------------------------------


    // --------------------------------------------------------------------------
    // Functions
    // --------------------------------------------------------------------------



    // --------------------------------------------------------------------------
    // Events
    // --------------------------------------------------------------------------

@stop
