@extends('layouts.admin')

@php
    if($create){
        $title = __('adminforms.users.title_insert');
        $formpar = array('route' => 'admin.user.store');
    } else {
        $title = __('adminforms.users.title_update');
        $formpar = array('route' => array('admin.user.update', $user->id), 'method' => 'PUT');
    }

    $tr = [
        'brand name'      => __('adminforms.users.brand_name'),
        'brand title'     => __('adminforms.users.brand_title'),
        'brand_metadesc'  => __('adminforms.users.brand_metadesc'),
        'brand keyw'      => __('adminforms.users.brand_keyw'),

        'id'           => __('adminforms.users.id'),
        'name'         => __('adminforms.users.name'),
        'lname'        => __('adminforms.users.lname'),
        'email'        => __('adminforms.users.email'),
        'phone'        => __('adminforms.users.phone'),
        'address'      => __('adminforms.users.address'),
        'zip city'      => __('adminforms.users.zip_city'),
        'password'      => __('adminforms.users.password'),
        'company info' => __('adminforms.users.company_info'),
        'com id'       => __('adminforms.users.com_id'),
        'com name'     => __('adminforms.users.com_name'),
        'active'       => __('adminforms.users.active'),
        'verified'     => __('adminforms.users.verified'),
        'created_at'   => __('adminforms.users.created_at'),
    ];
@endphp

@section('title'){{$title}}@endsection
@section('header'){{$title}}@endsection
@section('header_desc') @endsection
@section('breadcumbs') @endsection

@section('content')
    <!-- Main content -->
    <section class="content">



        <div class="row">

            <div class="col-xs-12">
                @if (session('error'))
                    <div class="alert alert-danger alert-dismissible">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <i class="icon fa fa-exclamation-triangle"></i> <strong>Info: </strong> &nbsp;  &nbsp;
                        {{ session('error') }}
                    </div>
                @endif
            </div>

            {!! Form::open($formpar) !!}

            <div class="col-xs-12">

                @if($create == 0)
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list-alt"></i> {{__('adminforms.users.title_info')}}</h3>
                    </div><!-- /. panel-heading -->

                    <div class="panel-body">
                        <div class="row">

                            <div class="col-xs-12">
                                <table class="table ">
                                    <tr>
                                        <th>{{ucfirst(__('adminforms.users.id'))}}</th>
                                        <th>{{ucfirst(__('adminforms.users.name'))}} i {{ucfirst(__('adminforms.users.lname'))}}</th>
                                        <th>{{ucfirst(__('adminforms.users.email'))}}</th>
                                        <th>{{ucfirst(__('adminforms.users.phone'))}}</th>
                                        <th>{{ucfirst(__('adminforms.users.address'))}}</th>
                                        <th>{{ucfirst(__('adminforms.users.created_at'))}}</th>
                                    </tr>
                                    <tr>
                                        <td>{{$user->id}}</td>
                                        <td>{{$user->name}} {{$user->lname}}</td>
                                        <td>{{$user->email}}</td>
                                        <td>{{$user->phone}}</td>
                                        <td>{{$user->address}}</td>
                                        <td>{{sr_date($user->created_at)}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="5">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="5"><strong>{{ucfirst(__('adminforms.users.company_info'))}} : </strong></td>
                                    </tr>
                                    <tr>
                                        <td colspan="5">{{$user->company_info}}</td>
                                    </tr>
                                </table>
                            </div>

                        </div> <!-- /.row -->
                    </div> <!-- /.panel-body -->
                </div> <!-- /.panel panel-default-->

                <br><br>

                @endif

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-list-alt"></i> {{($create) ? __('adminforms.users.title_create') : __('adminforms.users.title_edit')}}</h3>
                    </div><!-- /. panel-heading -->

                    <div class="panel-body">
                        <div class="row">
                            
                            
                            {{-------------------------------------------------------}}

                            @if($create)

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('name', ucfirst(__('adminforms.users.name').':'))}}
                                {{Form::text('name', old('name', $user->name ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('name'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('lname', ucfirst(__('adminforms.users.lname').':'))}}
                                {{Form::text('lname', old('lname', $user->lname ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('lname'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('phone', ucfirst(__('adminforms.users.phone').':'))}}
                                {{Form::text('phone', old('phone', $user->phone ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('phone'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('address', ucfirst(__('adminforms.users.address').':'))}}
                                {{Form::text('address', old('address', $user->address ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('address'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('zip_city', ucfirst(__('adminforms.users.zip_city').':'))}}
                                {{Form::text('zip_city', old('zip_city', $user->zip_city ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('zip_city'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('email', ucfirst(__('adminforms.users.email').':'))}}
                                {{Form::text('email', old('email', $user->email ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('email'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('password', ucfirst(__('adminforms.users.password').':'))}}
                                {{Form::text('password', old('password', $user->password ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('password'),$tr) }}</small>
                            </div>


                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                {{Form::label('password-confirm', ucfirst(__('adminforms.users.password_confirmation').':'))}}
                                {{Form::text('password_confirmation', old('password_confirmation', NULL ), ['class' => 'form-control'])}}
                                <small class="error">{{ strtr($errors->first('password_confirmation'),$tr) }}</small>
                            </div>

                            @endif
                            
                            {{--------------------------------------------------------}}



                            <div class="col-xs-12 col-sm-6 col-md-6 pbb">
                                @php $cgId = old('com_id', $user->com_id); @endphp
                                {{Form::label('com_id', ucfirst(__('adminforms.users.com_id').':'))}}
                                {{Form::select('com_id', $companies, $cgId, ['placeholder' => __('adminforms.users.select_company'), 'class' => 'form-control', 'id' => 'com-select'])}}
                                <small class="error">{{ strtr($errors->first('com_id'),$tr) }}</small>
                            </div>

                            <div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                @php $cgId = old('active', $user->active); @endphp
                                {{Form::label('active', ucfirst(__('adminforms.users.active').':'))}}
                                {{Form::select('active', $boleans, $cgId, ['class' => 'form-control', 'id' => 'act-select'])}}
                                <small class="error">{{ strtr($errors->first('active'),$tr) }}</small>
                            </div>
                            
                            
                            {{--<div class="col-xs-12 col-sm-6 col-md-3 pbb">
                                @if($user->verified == 0)
                                @php $cgId = old('verified', $user->verified); @endphp
                                {{Form::label('verified', ucfirst(__('adminforms.users.verified').':'))}}
                                {{Form::select('verified', $boleans, $cgId, ['class' => 'form-control', 'id' => 'act-select'])}}
                                <small class="error">{{ strtr($errors->first('verified'),$tr) }}</small>
                                @else
                                    <strong>{{ucfirst(__('adminforms.users.is_verified'))}}</strong>
                                    <input type="hidden" name="verified" value="1">
                                @endif
                            </div>--}}


                            <br clear="all">
                            <hr>
                            <div class="col-xs-12">
                                @php $btntext = ($create) ? __('adminforms.users.btn_insert') : __('adminforms.users.btn_update')@endphp
                                {{Form::submit($btntext, ['class' => 'btn btn-success pull-right'])}}
                            </div>

                        </div> <!-- /.row -->
                    </div> <!-- /.panel-body -->
                </div> <!-- /.panel panel-default-->

            </div> <!-- /.col -->



            {!! Form::close() !!}

        </div>
        <!-- /.row -->

    </section>
@endsection

@push('css')
@endpush


@push('scripts')
@endpush