@extends('layouts.app')

@section('content')
    <div class="panel panel-primary">
       @if(Auth::check() && Auth::user()->role == 'admin') <div class="panel-heading">Vytvořit nového administrátora</div>
        @else
            <div class="panel-heading">Registrovat se</div>
        @endif
        <div class="panel-body">
            <form class="form-horizontal" method="POST" action="{{ route('register') }}">
            {{ csrf_field() }}

            <!-- NAME -->
                <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                    <label for="name" class="col-md-4 control-label">Jméno</label>

                    <div class="col-md-6">
                        <input id="name" type="text" class="form-control" name="name"
                               value="{{ old('name') }}" >

                        @if ($errors->has('name'))
                            <span class="help-block">
                                <strong>{{ $errors->first('name') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <div class="form-group{{ $errors->has('lname') ? ' has-error' : '' }}">
                    <label for="lname" class="col-md-4 control-label">Příjmení</label>

                    <div class="col-md-6">
                        <input id="lname" type="text" class="form-control" name="lname"
                               value="{{ old('lname') }}" >

                        @if ($errors->has('lname'))
                            <span class="help-block">
                                <strong>{{ $errors->first('lname') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <!-- EMAIL -->
                <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                    <label for="email" class="col-md-4 control-label">E-mail</label>

                    <div class="col-md-6">
                        <input id="email" type="email" class="form-control" name="email"
                               value="{{ old('email') }}">

                        @if ($errors->has('email'))
                            <span class="help-block">
                                <strong>{{ $errors->first('email') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <!-- TELEPHONE NUMBER -->
                <div class="form-group{{ $errors->has('phone_number') ? ' has-error' : '' }}">
                    <label for="phone_number" class="col-md-4 control-label">Telefonní číslo</label>

                    <div class="col-md-6">
                        <input id="phone_number" type="text" class="form-control" name="phone_number"
                               value="{{ old('phone_number') }}">

                        @if ($errors->has('phone_number'))
                            <span class="help-block">
                                <strong>{{ $errors->first('phone_number') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <!-- ROLE -->
                <div class="form-group">
                    @if(Auth::check() && Auth::user()->role == 'admin')
                        <input id="role" type="hidden" class="form-control" name="role"
                           value="admin" required>
                        @else
                        <input id="role" type="hidden" class="form-control" name="role"
                               value="acco_admin" required>
                    @endif
                </div>


                <!-- PASSWORD -->
                <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                    <label for="password" class="col-md-4 control-label">Heslo</label>

                    <div class="col-md-6">
                        <input id="password" type="password" class="form-control" name="password" required>

                        @if ($errors->has('password'))
                            <span class="help-block">
                                <strong>{{ $errors->first('password') }}</strong>
                            </span>
                        @endif
                    </div>
                </div>

                <!-- PASSWORD -->
                <div class="form-group">
                    <label for="password-confirm" class="col-md-4 control-label">Potvrzení hesla</label>

                    <div class="col-md-6">
                        <input id="password-confirm" type="password" class="form-control"
                               name="password_confirmation" required>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-6 col-md-offset-4">
                        <button type="submit" class="btn btn-primary">
                            @if(Auth::check() && Auth::user()->role == 'admin') Vytvořit administrátora
                                @else Registrovat se
                                @endif
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

@endsection
