@extends('layouts.main')
@section('title', 'Benutzerprofil bearbeiten')
@section('headline', 'Benutzerprofil bearbeiten')
@section('content')

    <style>
        #main-wrapper .form-group {
            clear: both;
            margin-bottom: 20px;
        }
    </style>

    {{--<div class="page-title">
        <h3 class="breadcrumb-header">Benutzerprofil bearbeiten</h3>
    </div>--}}
    <div id="main-wrapper">
        <div class="row">
            <div class="col-md-12">
                @if($alert == 'successUpdate')
                    <div class="alert alert-success" role="alert">
                        Die Änderungen wurden erfolgreich gespeichert!
                    </div>
                @endif
                <div class="panel panel-white">

                    {{ Form::open(array('route' => array('edit-user', $user->id), 'class' => 'form-horizontal', 'method' => 'post', 'role' => 'form', 'files' => true )) }}

                        <div class="panel-body">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('id') ? 'has-error' : '' }}">
                                        <label for="inputObjectId" class="col-sm-3 control-label">Benutzer ID:</label>
                                        <div class="col-sm-9">
                                            <input name="id" type="text" class="form-control" id="userId" value="{{ $user->id }}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('user_role') ? 'has-error' : '' }}">
                                        <label for="inputObjectId" class="col-sm-3 control-label">Rolle / Berechtigung:</label>
                                        <div class="col-sm-9">
                                            <select class="form-control" name="user_role" id="userRole" @if(Auth::user()->user_role_id == 2) readonly @endif>
                                                <option value="">- Bitte wählen -</option>
                                                @foreach($userRoles as $userRole)
                                                    <option value="{{ $userRole->id }}" @if($user->user_role_id == $userRole->id) selected @endif>{{ $userRole->title }}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('first_name') ? 'has-error' : '' }}">
                                        <label for="" class="col-sm-3 control-label">Vorname:</label>
                                        <div class="col-sm-9">
                                            <input name="first_name" type="text" class="form-control" id="firstName" value="{{ $user->first_name }}">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('last_name') ? 'has-error' : '' }}">
                                        <label for="" class="col-sm-3 control-label">Nachname:</label>
                                        <div class="col-sm-9">
                                            <input name="last_name" type="text" class="form-control" id="lastName" value="{{ $user->last_name }}">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('email') ? 'has-error' : '' }}">
                                        <label for="inputObjectId" class="col-sm-3 control-label">E-Mail:</label>
                                        <div class="col-sm-9">
                                            <input name="email" type="text" class="form-control" id="email" value="{{ $user->email }}">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('password') ? 'has-error' : '' }}">
                                        <label for="" class="col-sm-3 control-label">Passwort:</label>
                                        <div class="col-sm-9">
                                            <input name="password" type="password" class="form-control" id="password" value="">
                                        </div>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group {{ $errors->formErrors->has('table_page_length') ? 'has-error' : '' }}">
                                        <label for="table_page_length" class="col-sm-3 control-label">Anz. Tabellenzeilen:</label>
                                        <div class="col-sm-9">
                                            <input name="table_page_length" type="text" class="form-control" id="table_page_length" max="999" maxlength="3" value="{{ $user->table_page_length }}">
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row" style="margin-top: 30px;">
                                <div class="col-md-6">
                                    @if(Auth::user()->user_role_id == 1)
                                        <a class="btn btn-default" type="button" href="{{ route('users') }}"><i class="fa fa-times" aria-hidden="true"></i>&nbsp; Abbrechen & zurück</a>
                                    @endif
                                </div>
                                <div class="col-md-6">
                                    <button class="btn btn-primary pull-right" type="submit"><i class="fa fa-floppy-o" aria-hidden="true"></i>&nbsp; Änderungen speichern</button>
                                </div>
                            </div>
                        </div>
                    {!! Form::close() !!}

                </div>
            </div>
        </div>
    </div>

@stop
