@extends('layouts')

@section('content')
<br>
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-6">
                <div class="box box-danger">
                    <div class="box-header">
                    <center><h3 class="box-title">Staff registration form</h3></center>
                    </div>
                    <div class="box-body">
                        <form method="post" action="{{ route('register-update', [$user->id]) }}">
                            @csrf
                        <div class="form-group ">
                            <label class="control-label" for="full_name" >Full name</label>
                               <div class="input-group">
                                    <div class="input-group-addon">
                                        <i class="fa fa-user"></i>
                                    </div>
                                    <input type="text" name="full_name" value="{{ $user->name }}" id="full_name" class="form-control">
                                </div>
                            @if ($errors->has('full_name'))
                                <span class="text-danger">
                                        <strong>{{ $errors->first('full_name') }}</strong>
                                    </span>
                            @endif
                        </div>
                        <div class="form-group ">
                        <label class="control-label" for="email" >E-mail</label>
                           <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-envelope"></i>
                                </div>
                                <input type="email" name="email" id="email" class="form-control" value="{{ $user->email }}" readonly="readonly">
                            </div>
                        @if ($errors->has('email'))
                            <span class="text-danger">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                        @endif
                        </div>
                        <div class="form-group ">
                            <label class="control-label" for="username" >Username</label>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-lock"></i>
                                </div>
                                <input type="text" name="username" id="username" class="form-control {{ $errors->has('username') ? ' is-invalid' : '' }}" value="{{ $user->username }}" readonly="readonly">
                            </div>
                            @if ($errors->has('username'))
                                <span class="text-danger">
                                <strong>{{ $errors->first('username') }}</strong>
                            </span>
                            @endif
                        </div>
                        <div class="form-group ">
                            <label class="control-label" for="Gender" >Gender</label>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-user"></i>
                                </div>
                                <select name="Gender" id="Gender" class="form-control">
                                    <option value="">Select Gender</option>
                                        <option {{ $user->sex == 'm' ? 'selected' : ''}} value="m">Male</option>
                                        <option {{ $user->sex == 'f' ? 'selected' : ''}} value="f">Female</option>
                                </select>
                            </div>
                            @if ($errors->has('Gender'))
                                <span class="text-danger">
                                <strong>{{ $errors->first('Gender') }}</strong>
                            </span>
                            @endif
                        </div>
                        <div class="form-group ">
                            <label class="control-label" for="role" >User role</label>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-book"></i>
                                </div>
                                <select name="role" id="role" class="form-control">
                                    <option value="">Select User Role</option>
                                        <option {{ $user->role == 'Staff' ? 'selected' : ''}}>Staff</option>
                                        <option {{ $user->role == 'Admin' ? 'selected' : ''}}>Admin</option>
                                </select>
                            </div>
                            @if ($errors->has('role'))
                                <span class="text-danger">
                                <strong>{{ $errors->first('role') }}</strong>
                            </span>
                            @endif
                        </div>
                        {{ method_field('PUT') }}


                        <button class="btn btn-flat btn-success btn-sm"> <span class="fa fa-edit"></span> Update </button>
                        <a href="{{ url()->previous() }}" class="btn btn-danger btn-sm btn-flat"><span class="fa fa-times"></span> Cancel </a>

                        </form>

                    </div>
                </div>
            </div>
            <div class="col-lg-6">
            </div>
        </div>
    </div>
@endsection
