@extends('layouts.app')

@section('content')
<div class="card card-outline-info">
  <div class="card-header">
      <h4 class="m-b-0 text-white">Edit Profile</h4>
  </div>
  <div class="card-body">
    <div class="x_content">
      <form id="demo-form2" action="{{ url('/profile') }}" method="post" data-parsley-validate class="form-horizontal form-label-left">
        <input name="_method" type="hidden" value="PUT">
        {{ csrf_field() }}

            <h3 class="card-title">Personal Detail</h3>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        {!! Form::label('full_name', 'Full Name*', ['class' => 'control-label', 'required']) !!}
                        {!! Form::text('full_name', $user->full_name, ['class' => 'form-control form-control-normal','id'=>'full_name', 'placeholder' => 'Full Name here', 'disabled']) !!}
                        <p class="help-block"></p>
                        @if($errors->has('full_name'))
                            <p class="help-block error">
                                {{ $errors->first('full_name') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('gender', 'Gender*', ['class' => 'control-label']) !!}
                        {!! Form::select('gender',array('Male', 'Female'), $user->gender, ['class' => 'form-control form-control-normal', 'required', 'placeholder' => 'Select']) !!}
                        <p class="help-block"></p>
                        @if($errors->has('gender'))
                            <p class="help-block error">
                                {{ $errors->first('gender') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('mobileno', 'Mobile no.*', ['class' => 'control-label']) !!}
                        {!! Form::number('mobileno', $user->mobileno, ['class' => 'form-control form-control-normal', 'id'=>'mobileno', 'placeholder' => 'Mobile No.', 'maxlength' => '10', 'required', 'disabled']) !!}
                        <p class="help-block">Do not enter 0 or +91 before the mobile number</p>
                        @if($errors->has('mobileno'))
                            <p class="help-block error">
                                {{ $errors->first('mobileno') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    {!! Form::label('email', 'Email*', ['class' => 'control-label']) !!}
                    {!! Form::email('email', $user->email, ['class' => 'form-control form-control-normal', 'id' => 'email', 'placeholder' => 'Email', 'required', 'disabled']) !!}
                    <p class="help-block"></p>
                    @if($errors->has('email'))
                        <p class="help-block">
                            {{ $errors->first('email') }}
                        </p>
                    @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('panno', 'Pan no.*', ['class' => 'control-label']) !!}
                        @if($user->panno!='')
                            {!! Form::text('panno', $user->panno, ['class' => 'form-control form-control-normal', 'placeholder' => 'Pan No.','readonly'=>'true']) !!}
                        @else
                            {!! Form::text('panno', $user->panno, ['class' => 'form-control form-control-normal', 'placeholder' => 'Pan No.']) !!}
                        @endif
                        <p class="help-block">If you don't have PAN card please enter "N/A"</p>
                        @if($errors->has('panno'))
                            <p class="help-block error">
                                {{ $errors->first('panno') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('dob', 'Date of Birth*', ['class' => 'control-label']) !!}
                        @if($user->dob!='')
                            {!! Form::text('dob', $user->dob, ['class' => 'form-control form-control-normal mydatepicker', 'placeholder' => 'Date of birth']) !!}
                        @else
                            {!! Form::text('dob', $user->dob, ['class' => 'form-control form-control-normal mydatepicker', 'placeholder' => 'Date of birth']) !!}
                        @endif
                        <p class="help-block"></p>
                        @if($errors->has('dob'))
                            <p class="help-block error">
                                {{ $errors->first('dob') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    {!! Form::label('address', 'Address', ['class' => 'control-label']) !!}
                    @if($user->address!='')
                        {!! Form::textarea('address', $user->address, ['class' => 'form-control form-control-normal', 'placeholder' => 'address', 'rows'=> '2', 'readonly'=>'true']) !!}
                    @else
                        {!! Form::textarea('address', $user->address, ['class' => 'form-control form-control-normal', 'placeholder' => 'address', 'rows'=> '2']) !!}
                    @endif

                    <p class="help-block"></p>
                    @if($errors->has('address'))
                        <p class="help-block">
                            {{ $errors->first('address') }}
                        </p>
                    @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    {!! Form::label('pincode', 'Pincode', ['class' => 'control-label']) !!}
                    @if($user->pincode!='')
                        {!! Form::text('pincode', $user->pincode, ['class' => 'form-control form-control-normal', 'placeholder' => 'pincode', 'readonly'=>'true']) !!}
                    @else
                        {!! Form::text('pincode', $user->pincode, ['class' => 'form-control form-control-normal', 'placeholder' => 'pincode']) !!}
                    @endif

                    <p class="help-block"></p>
                    @if($errors->has('pincode'))
                        <p class="help-block">
                            {{ $errors->first('pincode') }}
                        </p>
                    @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    {!! Form::label('state', 'State*', ['class' => 'control-label']) !!}
                    @if($user->state!='')
                    {{$user->state_name}}
                    @else
                    <select class="form-control form-control-normal" name="state" id="state-dropdown" required="">
                        <option value="">Select State</option>
                        @foreach ($states as $state) 
                        <option value="{{$state->id}}" @if (old('state')==$state->id) selected  @endif>
                        {{$state->name}}
                        </option>
                        @endforeach
                    </select>
                    @endif
                    <p class="help-block"></p>
                    @if($errors->has('state'))
                        <p class="help-block">
                            {{ $errors->first('state') }}
                        </p>
                    @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    {!! Form::label('city', 'City*', ['class' => 'control-label']) !!}
                    @if($user->city!='')
                    {{$user->city_name}}
                    @else
                    <select class="form-control form-control-normal" name="city" id="city-dropdown" required=""></select>
                    @endif
                    <p class="help-block"></p>
                    @if($errors->has('city'))
                        <p class="help-block">
                            {{ $errors->first('city') }}
                        </p>
                    @endif
                    </div>
                </div>
            </div>
            <h3 class="card-title">Account Detail</h3>
            <div class="row">
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('name_bank_accnt', 'Account Name', ['class' => 'control-label']) !!}
                        @if($user->name_bank_accnt!='')
                            {!! Form::text('name_bank_accnt', $user->name_bank_accnt, ['class' => 'form-control form-control-normal', 'placeholder' => 'Account Name', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('name_bank_accnt', $user->name_bank_accnt, ['class' => 'form-control form-control-normal', 'placeholder' => 'Account Name']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('name_bank_accnt'))
                            <p class="help-block error">
                                {{ $errors->first('name_bank_accnt') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('bank_accnt_no', 'Bank Account No', ['class' => 'control-label']) !!}
                        @if($user->bank_accnt_no!='')
                            {!! Form::text('bank_accnt_no', $user->bank_accnt_no, ['class' => 'form-control form-control-normal', 'placeholder' => 'Account No', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('bank_accnt_no', $user->bank_accnt_no, ['class' => 'form-control form-control-normal', 'placeholder' => 'Account No']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('bank_accnt_no'))
                            <p class="help-block error">
                                {{ $errors->first('bank_accnt_no') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('bank_name', 'Bank Name', ['class' => 'control-label']) !!}
                        @if($user->bank_name!='')
                            {!! Form::text('bank_name', $user->bank_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Bank Name', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('bank_name', $user->bank_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Bank Name']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('bank_name'))
                            <p class="help-block error">
                                {{ $errors->first('bank_name') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('branch_name', 'Branch Name', ['class' => 'control-label']) !!}
                        @if($user->branch_name!='')
                            {!! Form::text('branch_name', $user->branch_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Branch Name', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('branch_name', $user->branch_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Branch Name']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('branch_name'))
                            <p class="help-block error">
                                {{ $errors->first('branch_name') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('accnt_type', 'Account Type', ['class' => 'control-label']) !!}
                        @if($user->accnt_type!='')
                            {!! Form::select('accnt_type', ['Saving', 'Current', 'NRE', 'NRO', 'Other'], $user->accnt_type, ['class' => 'form-control form-control-normal', 'placeholder' => 'Select', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::select('accnt_type', ['Saving', 'Current', 'NRE', 'NRO', 'Other'], $user->accnt_type, ['class' => 'form-control form-control-normal', 'placeholder' => 'Select']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('accnt_type'))
                            <p class="help-block error">
                                {{ $errors->first('accnt_type') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('ifsc', 'IFSC', ['class' => 'control-label']) !!}
                        @if($user->ifsc!='')
                            {!! Form::text('ifsc', $user->ifsc, ['class' => 'form-control form-control-normal', 'placeholder' => 'IFSC', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('ifsc', $user->ifsc, ['class' => 'form-control form-control-normal', 'placeholder' => 'IFSC']) !!}
                        @endif

                        <p class="help-block"></p>
                        @if($errors->has('ifsc'))
                            <p class="help-block error">
                                {{ $errors->first('ifsc') }}
                            </p>
                        @endif
                    </div>
                </div>
            </div>
            <h3 class="card-title">Nominee Detail</h3>
            <div class="row">
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('nom_name', 'Nominee Name', ['class' => 'control-label']) !!}
                        @if($user->nom_name!='')
                            {!! Form::text('nom_name', $user->nom_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Nominee Full Name here', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('nom_name', $user->nom_name, ['class' => 'form-control form-control-normal', 'placeholder' => 'Nominee Full Name here']) !!}
                        @endif
                        <p class="help-block"></p>
                        @if($errors->has('nom_name'))
                            <p class="help-block error">
                                {{ $errors->first('nom_name') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('nom_relation', 'Nominee Relation', ['class' => 'control-label']) !!}
                        @if($user->nom_relation!='')
                            {!! Form::text('nom_relation', $user->nom_relation, ['class' => 'form-control form-control-normal', 'placeholder' => 'Nominee Relation here', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('nom_relation', $user->nom_relation, ['class' => 'form-control form-control-normal', 'placeholder' => 'Nominee Relation here']) !!}
                        @endif

                        
                        <p class="help-block"></p>
                        @if($errors->has('nom_relation'))
                            <p class="help-block error">
                                {{ $errors->first('nom_relation') }}
                            </p>
                        @endif
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        {!! Form::label('nom_dob', 'Nominee Date of Birth', ['class' => 'control-label']) !!}
                        @if($user->nom_dob!='')
                            {!! Form::text('nom_dob', $user->nom_dob, ['class' => 'form-control form-control-normal mydatepicker', 'placeholder' => 'Nominee Date of Birth', 'readonly'=>'true']) !!}
                        @else
                            {!! Form::text('nom_dob', $user->nom_dob, ['class' => 'form-control form-control-normal mydatepicker', 'placeholder' => 'Nominee Date of Birth']) !!}
                        @endif
                        
                        <p class="help-block"></p>
                        @if($errors->has('nom_dob'))
                            <p class="help-block error">
                                {{ $errors->first('nom_dob') }}
                            </p>
                        @endif
                    </div>
                </div>
            </div>
        </div>
        <div class="ln_solid"></div>
        <div class="form-group">
          <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
            <button type="submit" class="btn btn-success">Update</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- /page content -->
@endsection
@section('javascript')
    <!-- Date picker plugins css -->
    <link href="{{ url('assets') }}/plugins/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
    <!-- Daterange picker plugins css -->
    <link href="{{ url('assets') }}/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
    <link href="{{ url('assets') }}/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- Date Picker Plugin JavaScript -->
    <script src="{{ url('assets') }}/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <!-- Date range Plugin JavaScript -->
    <script src="{{ url('assets') }}/plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <script src="{{ url('assets') }}/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script src="{{ url('assets') }}/js/jqBootstrapValidation.js"></script>
    <link href="{{ url('assets') }}/plugins/EasyAutocomplete/easy-autocomplete.min.css" rel="stylesheet">
    <script src="{{ url('assets') }}/plugins/EasyAutocomplete/jquery.easy-autocomplete.min.js"></script>
    <script src="{{ url('assets') }}/js/typeahead.bundle.js"></script>
    <!-- Parsley -->
    <script>
    $(document).ready(function() {
      jQuery('.mydatepicker, #datepicker').datepicker({format: 'dd-mm-yyyy'});
      $('#state-dropdown').on('change', function() {
            var state_id = this.value;
            $("#city-dropdown").html('');
            $.ajax({
                url:"{{url('get-cities-by-state')}}",
                type: "POST",
                data: {
                state_id: state_id,
                _token: '{{csrf_token()}}' 
                },
                dataType : 'json',
                success: function(result){
                $('#city-dropdown').html('<option value="">Select City</option>'); 
                $.each(result.cities,function(key,value){
                $("#city-dropdown").append('<option value="'+value.id+'">'+value.name+'</option>');
                });
                }
            });
        });
    });
    </script>
@endsection