<?php $__env->startSection('content'); ?>
    <div class="card card-outline-info">
        <div class="card-header">
            <h4 class="m-b-0 text-white">Dealer Registration</h4>
        </div>
    <div class="card-body">
    <?php echo Form::open(['method' => 'POST','id'=> 'register_frm', 'data-parsley-validate'=>'', 'route' => ['admin.dealers.store']]); ?>

        <div class="form-body control-group">
            <h4 class="card-title">Select Dealer Type And Sponsor Dealer</h4>
                <div class="row">
                  <div class="col-md-12">
                      <div class="form-group">
                      <label for="select_model" class="control-label">Dealer Type<span class="required">*</span></label>                  
                      <select name="dealer_type" class="form-control form-control-normal" id="dealer_type" required>
                          <?php $__currentLoopData = $dealer_types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$dealer_type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <option value="<?php echo e($key); ?>"><?php echo e($dealer_type); ?></option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </select>
                      <?php if($errors->has('dealer_type')): ?>
                          <p class="help-block error">
                              <?php echo e($errors->first('dealer_type')); ?>

                          </p>
                      <?php endif; ?>
                    </div>
                  </div>
                  <div class="col-md-6 payOpt">
                    <div class="form-group">
                    <label for="dealer_username" class="control-label">Dealer Username<span class="required">*</span></label>                  
                          <input type="text" name="dealer_username" id="sponsor-typeahead" class="form-control form-control-normal" placeholder="Dealer's Username" value="<?php echo e(old('dealer_username')); ?>" style="margin-bottom: 0px; " />
                          <p class="help-block"></p>
                          <?php if($errors->has('dealer_username')): ?>
                              <p class="help-block error">
                                  <?php echo e($errors->first('dealer_username')); ?>

                              </p>
                          <?php endif; ?>
                      </div>
                  </div>
                  <div class="col-md-6 payOpt">
                    <div class="form-group">
                    <label for="select_model" class="control-label">Dealer Name<span class="required">*</span></label>
                          <?php echo Form::text('sponsor_name', old('sponsor_name'), ['class' => 'form-control form-control-normal', 'id' => 'sponsor_name', 'placeholder' => '','disabled'=>'']); ?>

                          <p class="help-block"></p>
                          <?php if($errors->has('sponsor_name')): ?>
                              <p class="help-block error">
                                  <?php echo e($errors->first('sponsor_name')); ?>

                              </p>
                          <?php endif; ?>
                      </div>
                  </div>

                </div>
           <h3 class="card-title">Personal Detail</h3>
            <div class="row">
                <div class="col-md-12">
                    <div class="form-group">
                        <?php echo Form::label('full_name', 'Full Name*', ['class' => 'control-label', 'required']); ?>

                        <?php if(isset($bookingWallet->dealer_name)): ?>
                        <?php echo Form::text('full_name', $bookingWallet->dealer_name, ['class' => 'form-control form-control-normal','id'=>'full_name', 'placeholder' => 'Full Name here']); ?>                        
                        <?php else: ?>
                        <?php echo Form::text('full_name', old('full_name'), ['class' => 'form-control form-control-normal','id'=>'full_name', 'placeholder' => 'Full Name here']); ?>

                        <?php endif; ?>
                        <p class="help-block"></p>
                        <?php if($errors->has('full_name')): ?>
                            <p class="help-block error">
                                <?php echo e($errors->first('full_name')); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        <?php echo Form::label('gender', 'Gender*', ['class' => 'control-label']); ?>


                        <?php echo Form::select('gender',array('Male', 'Female'), old('gender'), ['class' => 'form-control form-control-normal', 'required', 'placeholder' => 'Select']); ?>

                        <p class="help-block"></p>
                        <?php if($errors->has('gender')): ?>
                            <p class="help-block error">
                                <?php echo e($errors->first('gender')); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        <?php echo Form::label('mobileno', 'Mobile no.*', ['class' => 'control-label']); ?>

                        <?php if(isset($bookingWallet->dealer_mobile)): ?>
                        <?php echo Form::number('mobileno', $bookingWallet->dealer_mobile, ['class' => 'form-control form-control-normal', 'id'=>'mobileno', 'placeholder' => 'Mobile No.', 'maxlength' => '10', 'required']); ?>

                        <?php else: ?>
                        <?php echo Form::number('mobileno', old('mobileno'), ['class' => 'form-control form-control-normal', 'id'=>'mobileno', 'placeholder' => 'Mobile No.', 'maxlength' => '10', 'required']); ?>                        
                        <?php endif; ?>
                        <p class="help-block">Do not enter 0 or +91 before the mobile number</p>
                        <?php if($errors->has('mobileno')): ?>
                            <p class="help-block error">
                                <?php echo e($errors->first('mobileno')); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    <?php echo Form::label('email', 'Email*', ['class' => 'control-label']); ?>

                    <?php echo Form::email('email', old('email'), ['class' => 'form-control form-control-normal', 'id' => 'email', 'placeholder' => 'Email', 'required']); ?>

                    <p class="help-block"></p>
                    <?php if($errors->has('email')): ?>
                        <p class="help-block">
                            <?php echo e($errors->first('email')); ?>

                        </p>
                    <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        <?php echo Form::label('aadhar', 'Aadhar*', ['class' => 'control-label']); ?>

                        <?php echo Form::number('aadhar', old('aadhar'), ['class' => 'form-control form-control-normal', 'placeholder' => 'Aadhar no.']); ?>

                        <p class="help-block">Only number no space</p>
                        <?php if($errors->has('aadhar')): ?>
                            <p class="help-block error">
                                <?php echo e($errors->first('aadhar')); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                        <?php echo Form::label('panno', 'Pan no.*', ['class' => 'control-label']); ?>

                        <?php echo Form::text('panno', old('panno'), ['class' => 'form-control form-control-normal', 'placeholder' => 'Pan No.']); ?>

                        <p class="help-block">If you don't have PAN card please enter "N/A"</p>
                        <?php if($errors->has('panno')): ?>
                            <p class="help-block error">
                                <?php echo e($errors->first('panno')); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    <?php echo Form::label('address', 'Address', ['class' => 'control-label']); ?>

                    <?php echo Form::textarea('address', old('address'), ['class' => 'form-control form-control-normal', 'placeholder' => 'address', 'rows'=> '2']); ?>

                    <p class="help-block"></p>
                    <?php if($errors->has('address')): ?>
                        <p class="help-block">
                            <?php echo e($errors->first('address')); ?>

                        </p>
                    <?php endif; ?>
                    </div>
                </div>
                <div class="col-md-4">
                    <div class="form-group">
                    <?php echo Form::label('pincode', 'Pincode', ['class' => 'control-label']); ?>

                    <?php echo Form::text('pincode', old('pincode'), ['class' => 'form-control form-control-normal', 'placeholder' => 'pincode']); ?>

                    <p class="help-block"></p>
                    <?php if($errors->has('pincode')): ?>
                        <p class="help-block">
                            <?php echo e($errors->first('pincode')); ?>

                        </p>
                    <?php endif; ?>
                    </div>
                </div>

            <div class="col-md-4">
                <div class="form-group">
                    <label class="control-label" for="city_id">Select State</label>
                    <select name="state_id" id="state-dropdown" class="form-control">
                        <?php $__currentLoopData = $states; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $state): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($state->id); ?>" <?php if($state->id==23): ?> selected="selected" <?php endif; ?>><?php echo e($state->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php if($errors->has('state_id')): ?>
                      <p class="help-block">
                          <strong><?php echo e($errors->first('state_id')); ?></strong>
                      </p>
                    <?php endif; ?>
                </div>
              </div>
              <div class="col-md-4">
                <div class="form-group">
                    <label class="control-label" for="city_id">Select City</label>
                    <select name="city_id" id="city-dropdown" class="form-control">
                        <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($city->id); ?>"><?php echo e($city->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php if($errors->has('city_id')): ?>
                      <p class="help-block">
                          <strong><?php echo e($errors->first('city_id')); ?></strong>
                      </p>
                    <?php endif; ?>
                </div>
            </div>


            </div>
            <div class="row">
                <div class="col-md-12">
                <div class="form-group">
                    <?php echo e(Form::checkbox('agreeterms', 1, null, ['id' => 'agreeterms', 'checked'=>true])); ?>

                    <?php echo Form::label('agreeterms', 'By submitting this form I agree to the Terms and Conditions.', ['class' => 'control-label', 'style'=>'color:#455a64;']); ?>

                    <p class="help-block"></p>
                    <?php if($errors->has('agreeterms')): ?>
                        <p class="help-block error">
                            <?php echo e($errors->first('agreeterms')); ?>

                        </p>
                    <?php endif; ?>
                </div>
              </div>

            </div>
        </div>
        <?php if(isset($bookingWallet->deal_id)): ?>
        <input type="hidden" name="deal_id" value="<?php echo e($bookingWallet->deal_id); ?>">
        <?php endif; ?>
    <?php echo Form::button('Submit', ['class' => 'btn btn-primary', 'id' => "preview_btn", 'data-target' => "#exampleModal"]); ?>

    <div class="modal fade" tabindex="-1" role="dialog" id="exampleModal" aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title">Modal title</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
          <div class="modal-body">
            <p>
              Are you sure? Please check Name, Email and Mobile no.
              These value can not be updated later!
              Passwords will be sent to email and to the mobile no. provided. Please keep it safe.
            </p>
            <p>
              <strong>Full Name : </strong><span id="fullName"></span> <br />
              <strong>Email : </strong><span id="Email"></span> <br />
              <strong>Mobile no : </strong><span id="mobileNo"></span> <br />
            </p>
          </div>
          <div class="modal-footer">
            <?php echo Form::submit('Proceed To register', ['class' => 'btn btn-danger']); ?>

            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          </div>
        </div>
      </div>
    </div>
    <?php echo Form::close(); ?>

    </div>
    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('javascript'); ?>
    <!-- Date picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
    <!-- Daterange picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- Date Picker Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <!-- Date range Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/jqBootstrapValidation.js"></script>
    <link href="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/easy-autocomplete.min.css" rel="stylesheet">
    <script src="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/jquery.easy-autocomplete.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/typeahead.bundle.js"></script>
    <!-- Parsley -->
    <script>
      jQuery('.mydatepicker, #datepicker').datepicker({format: 'dd-mm-yyyy'});

      $(document).ready(function() {
        $('div.payOpt').hide();
        $('select#dealer_type').on('change', function() {
          if( this.value == 'mega' || this.value == ''){
            $('div.payOpt').hide();
          }else{
            $('div.payOpt').show();
          }
        });

        $('#state-dropdown').on('change', function() {
        var state_id = this.value;
        $("#city-dropdown").html('');
        $.ajax({
                url:"<?php echo e(url('/')); ?>/get-cities-by-state",
                type: "POST",
                data: {
                state_id: state_id,
                _token: '<?php echo e(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>');
                });
                }
            });
        });

        $("form#register_frm").not("[type=submit]").jqBootstrapValidation();
        $('#preview_btn').click(function(event) {
          $("#exampleModal").modal();
        });
        $( "input#email" ).change(function() {
          $( "span#Email" ).text($(this).val());
        });
        $( "input#full_name" ).change(function() {
          $( "span#fullName" ).text($(this).val());
        });
        $( "input#mobileno" ).change(function() {
          $( "span#mobileNo" ).text($(this).val());
        });
        $( "input#sponsor-typeahead" ).change(function() {
          $( "span#sponsorName" ).text($(this).val());
        });
      });

      var options = {

        url: function(phrase) {
          return "<?php echo e(url('/')); ?>/admin/dealers/getSponsors/" + phrase;
        },

        getValue: function(element) {
          return element.username;
        },

        template: {
            type: "description",
            fields: {
                description: "full_name"
            }
        },
        list: {
              onSelectItemEvent: function() {
                var data = $("#sponsor-typeahead").getSelectedItemData().full_name;
                $("input#sponsor_name").val(data).trigger("change");
              }
        },
        theme: "plate-dark",
        ajaxSettings: {
          dataType: "json",
          method: "GET",
          data: {
            dataType: "json"
          }
        },
        preparePostData: function(data) {
          data.phrase = $("#sponsor-typeahead").val();
          return data;
        },

        requestDelay: 400
      };

      $("#sponsor-typeahead").easyAutocomplete(options);
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\xampp\htdocs\yeselectricv.loc\resources\views/admin/dealers/create.blade.php ENDPATH**/ ?>