@extends('ui::layouts.app')
@section('content')
    <div class="ui menu top attached">
        <a href="{{ route('epicentrum::users.index') }}" class="item">
            <i class="icon angle left"></i>
        </a>
        <h3 class="ui header item">@lang('overide::menu.add_user')</h3>
    </div>

    <div class="ui segment very padded bottom attached">
        {!! Form::open()->post()->action(route('overide::users.store')) !!}
        {!! Form::text('name', old('name'))->label(trans('overide::users.name'))->required() !!}
        {!! Form::text('email', old('email'))->label(trans('overide::users.email'))->required() !!}

        <div class="field required">
            <label>@lang('overide::users.password')</label>
            <div class="ui action input">
                {!! Form::text('password', old('password'))->id('password') !!}
                <button class="ui button small" type="button" data-role="randomize-password">@lang('overide::action.generate_password')</button>
            </div>
        </div>

        @if($multipleRole)
            {!! Form::checkboxGroup('roles', $roles)->label(trans('overide::users.roles')) !!}
        @else
            {!! Form::radioGroup('roles', $roles)->label(trans('overide::users.roles')) !!}
        @endif

        <div class="field required">
            <label>@lang('overide::users.status')</label>
            {!! Form::select('status', $statuses, old('status')) !!}
        </div>

        <div class="ui divider hidden"></div>
        <div class="field">
            <div class="ui checkbox">
                <input type="checkbox" name="send_account_information" {{ request()->old('send_account_information')?'checked':'' }}>
                <label>@lang('overide::users.send_account_information_via_email')</label>
            </div>
        </div>
        <div class="field">
            <div class="ui checkbox">
                <input type="checkbox" name="must_change_password" {{ request()->old('must_change_password')?'checked':'' }}>
                <label>@lang('overide::users.change_password_on_first_login')</label>
            </div>
        </div>
        <div class="ui divider hidden"></div>

        <button class="ui button primary" type="submit" name="submit" value="1">@lang('overide::action.save')</button>
        <a href="{{ route('overide::users.index') }}" class="ui button">@lang('overide::action.cancel')</a>
        {!! Form::close() !!}

    </div>
@endsection

@push('body')
<script>
    $(function(){
        $('[data-role="randomize-password"]').on('click', function(){
            document.getElementById('password').setAttribute('value', Math.random().toString(36).substr(2,8));
        });
    });
</script>
@endpush
