@extends('layout.main')
@section('title') @if( ! empty($title)) {{ $title }} | @endif @parent @endsection

@section('main')

@include('admin.sidebar_menu')

<div id="page-wrapper">
    @if( ! empty($title))
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header"> {{ $title }} </h1>
        </div> <!-- /.col-lg-12 -->
    </div> <!-- /.row -->
    @endif

    @include('admin.flash_msg')

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

            {!! Form::open(['class'=>'form-horizontal', 'files'=>'true']) !!}
            @if(session('missing_mobile'))
            <div class="form-group bg-danger" style="padding:10px 0;">
                <div class="col-sm-8">
                    <p class="help-block">{{ session('missing_mobile') }}</p>
                </div>
            </div>
            @endif
            <div class="form-group {{ $errors->has('name')? 'has-error':'' }}">
                <label for="name" class="col-sm-4 control-label">@lang('app.name')</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="name"
                        value="{{ old('name')? old('name') : $user->name }}" name="name"
                        placeholder="@lang('app.name')">
                    {!! $errors->has('name')? '<p class="help-block">'.$errors->first('name').'</p>':'' !!}
                </div>
            </div>

            <div class="form-group {{ $errors->has('email')? 'has-error':'' }}">
                <label for="email" class="col-sm-4 control-label">@lang('app.email')</label>
                <div class="col-sm-8">
                    <input type="email" class="form-control" id="email"
                        value="{{ old('email')? old('email') : $user->email }}" name="email"
                        placeholder="@lang('app.email')" readonly>
                    {!! $errors->has('email')? '<p class="help-block">'.$errors->first('email').'</p>':'' !!}
                </div>
            </div>

            <div class="form-group {{ $errors->has('gender')? 'has-error':'' }}">
                <label for="gender" class="col-sm-4 control-label">@lang('app.gender')</label>
                <div class="col-sm-8">
                    <select id="gender" name="gender" class="form-control select2">
                        <option value="">Select Gender</option>
                        <option value="male" {{ $user->gender == 'male'?'selected':'' }}>Male</option>
                        <option value="female" {{ $user->gender == 'female'?'selected':'' }}>Fe-Male</option>
                        <option value="third_gender" {{ $user->gender == 'third_gender'?'selected':'' }}>Third Gender
                        </option>
                    </select>

                    {!! $errors->has('gender')? '<p class="help-block">'.$errors->first('gender').'</p>':'' !!}
                </div>
            </div>

            <!--<div class="form-group {{ $errors->has('mobile')? 'has-error':'' }}">-->
            <!--    <label for="mobile" class="col-sm-4 control-label">@lang('app.mobile')</label>-->
            <!--    <div class="col-sm-8">-->
            <!--        <input type="text" class="form-control" id="mobile"-->
            <!--            value="{{ old('mobile')? old('mobile') : $user->mobile }}" name="mobile"-->
            <!--            placeholder="@lang('app.mobile')">-->
            <!--        {!! $errors->has('mobile')? '<p class="help-block">'.$errors->first('mobile').'</p>':'' !!}-->
            <!--    </div>-->
            <!--</div>-->

            <div class="form-group {{ $errors->has('phone')? 'has-error':'' }}">
                <label for="phone" class="col-sm-4 control-label">@lang('app.phone')</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="phone"
                        value="{{ old('phone')? old('phone') : $user->phone }}" name="phone"
                        placeholder="@lang('app.phone')">
                    {!! $errors->has('phone')? '<p class="help-block">'.$errors->first('phone').'</p>':'' !!}
                </div>
            </div>


            <div>


                <div class="form-group {{ $errors->has('address')? 'has-error':'' }}">
                    <label for="address" class="col-sm-4 control-label">@lang('app.address')</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="address"
                            value="{{ old('address')? old('address') : $user->address }}" name="address"
                            placeholder="@lang('app.address')">
                        <p>
                            {!! $errors->has('address')? '<p class="help-block">'.$errors->first('address').'</p>':''
                            !!}
                    </div>
                </div>
                
                <div class="form-group {{ $errors->has('website')? 'has-error':'' }}">
                    <label for="website" class="col-sm-4 control-label">Website</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="website"
                            value="{{ old('website')? old('website') : $user->website }}" name="website"
                            placeholder="Website">
                        <p>
                            {!! $errors->has('address')? '<p class="help-block">'.$errors->first('website').'</p>':''
                            !!}
                    </div>
                </div>



                <div class="form-group  {{ $errors->has('photo')? 'has-error':'' }}">
                    <label class="col-sm-4 control-label">@lang('app.change_avatar')</label>
                    <div class="col-sm-8">
                        <input type="file" id="photo" name="photo" class="filestyle">
                        <p>
                            {!! $errors->has('photo')? '<p class="help-block">'.$errors->first('photo').'</p>':'' !!}
                        </p>
                    </div>
                </div>
                @if(Auth::user()->user_type == 'agent')
                @php
                $user_paper = App\Agent_legality::where('user_id', $user->id)->first();
                @endphp


                <div class="form-group  {{ $errors->has('certificate')? 'has-error':'' }}">
                    <label class="col-sm-4 control-label">@lang('Certificate')</label>
                    <div class="col-sm-8">
                        <input type="file" id="photo" name="certificate" class="filestyle">
                        <p>
                            {!! $errors->has('photo')? '<p class="help-block">'.$errors->first('photo').'</p>':'' !!}
                        </p>
                    </div>
                    @if(isset($user_paper)) <h5>{{$user_paper->agent_certificate}}</h5> @endif
                    <h5></h5>
                </div>

                <hr />
                <div class="form-group">
                    <label for="membership-num" class="col-sm-4 control-label">@lang('Membership Number')</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="" name="membershipNum"
                            placeholder="@lang('Membership Number')" @if(isset($user_paper))
                            value="{{$user_paper->membership_num}}" @endif>
                        <p>
                            {!! $errors->has('membership-num')? '<p class="help-block">
                                '.$errors->first('membership-num').'</p>':'' !!}
                    </div>
                </div>

                <div class="form-group">
                    <label for="membership-name" class="col-sm-4 control-label">@lang('Membership Name')</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="" name="membershipName"
                            placeholder="@lang('Membership Name')" @if(isset($user_paper))
                            value="{{$user_paper->membership_name}}" @endif>
                        <p>
                            {!! $errors->has('membership-name')? '<p class="help-block">
                                '.$errors->first('membership-name').'</p>':''
                            !!}
                    </div>
                </div>
                @endif

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <button type="submit" class="btn btn-primary">@lang('Update')</button>
                    </div>
                </div>

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

            </div>
        </div>

    </div> <!-- /#page-wrapper -->

</div> <!-- /#wrapper -->
@endsection

@section('page-js')
<script src="{{ asset('assets/js/bootstrap-filestyle.min.js') }}"></script>
<script>
    $(":file").filestyle({buttonName: "btn-primary", buttonBefore: true});
</script>
@endsection