<?php $__env->startSection('content'); ?>
<div class="common-content">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6><?php echo e($title); ?></h6>
                    </div>
                </div>
              <div class="boxings">
              <form id="addDelar" method="POST" action="<?php echo e(url('vendors/add_dealer')); ?>" enctype="multipart/form-data">
              <?php echo csrf_field(); ?>
                  <div class="row">
                      
                    <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                            <div class="form-group">
                                <label>Are you a pre-existing Dealer ?</label>
                                <label><input type="checkbox" name="sendType"  onchange="valueChanged()" id="gstCheck"></label>
                            </div>
                        </div>
                      </div>  
                  
                    <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Manufacturer Name<sup>*</sup></label>
                                <!--<select name="manufacturer_id" class="form-control" required>-->
                                <select id="manufacturer_id" class="form-control <?php $__errorArgs = ['manufacturer_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?> js-example-disabled-results"  name="manufacturer_id" value="<?php echo e(old('manufacturer_id')); ?>" required autocomplete="manufacturer_id" autofocus>
                                <option value="">Select Manufacturer</option>
                                <?php $__currentLoopData = $getmanufacturers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $manufacturers): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($manufacturers->id); ?>"><?php echo e($manufacturers->name); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Email Id</label>
                                <input  type="text" class="form-control" id="email"  name="email" value="" readonly>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Mobile No</label>
                                <input  type="text" class="form-control" name="email" id="phonenum" value="" readonly>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Address</label>
                                <input  type="text" class="form-control" name="email" id="address" value="" readonly>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Contact Name</label>
                                <input  type="text" class="form-control" name="email" id="contactname" value="" readonly>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Contact Person Mobile No</label>
                                <input  type="text" class="form-control" name="email" id="contactphonenum" value="" readonly>
                              </div>
                        </div>
                      </div>
                      <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
                        <div class="form-inputs">
                             <div class="form-group">
                                <label>Other Details</label>
                                <input  type="text" class="form-control" name="details" value="">
                              </div>
                        </div>
                      </div>
                                        <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12  gst_doc">
                                            <div class="form-inputs">
                                                <label>Company Profile<sup>*</sup></label>
                                                <div class="form-group">
                                                     
                                                  <input type="file" class="form-control" accept=".docx,.doc,.pdf" name="Manufacturer_file1" id="Manufacturer_file1">
                                                </div>
                                            </div>
                                        </div>
                           
                  </div>
                  <div class="row">
                     <div class="col-12">
                        <div class="green-button green-button2">
                          <?php if(Auth::user()->user_type==2): ?>
                            <button class="product-submit" id="create">Register as Dealer</button>
                          <?php endif; ?>
                          <?php if(Auth::user()->user_type==3): ?>
                          <button class="product-submit" id="create">Add Manufacturer</button>
                        <?php endif; ?>
                         </div> 
                     </div>
                  </div>
                  </form>
              </div>
          </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>


<script>
var $disabledResults = $(".js-example-disabled-results");
$disabledResults.select2();
</script> 
<script> 


$("#Manufacturer_file1").change(function() {

if(this.val!=''){
  $('label[for="Manufacturer_file1"]').hide();
}
else{

  $('label[for="Manufacturer_file1"]').show();
}
});
$("#manufacturer_id").on('change', function () {
    if($(this).val()!=''){
        $('label[for=manufacturer_id]').hide();
    }
    else{
        $('label[for=manufacturer_id]').show();
    }
});                                      
 
<?php if(Session::has('message')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('message')); ?>",
        type: "success",
        showCancelButton: false,
        dangerMode: false,
        confirmButtonText: 'OK',

    });
<?php endif; ?>
<?php if(Session::has('errormessage')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('errormessage')); ?>",
        type: "error",
        showCancelButton: false,
        dangerMode: true,
        confirmButtonText: 'OK',

    });
<?php endif; ?>

$('#manufacturer_id').on('change', function() {
      var manid = this.value;
      var APP_URL = <?php echo json_encode(url('/getbuyerdetails')); ?> ;
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+manid,
            data: { manid: manid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) {
                console.log(resultData);
                var res = JSON.parse(resultData);
                $("#email").val(res.email);
                $("#phonenum").val(res.phone_no);
                $("#address").val(res.address);
                $("#contactname").val(res.contact_name);
                $("#contactphonenum").val(res.contact_phone_no);
            }
            });
            
    });

    function valueChanged()
    {
        if($('#gstCheck').is(":checked")){
          $(".gst_doc").hide();
          $(".mf_doc").show();

        }else{
          $(".gst_doc").show();
          $(".mf_doc").hide();
          
        }
    }

</script>
<script>
$(function(){
    $('#addDelar').on('submit', function(event){
        event.preventDefault();
    });
});
$("#create").click(function(e){
    $(".pageloader").hide();
        
	$("#addDelar").validate({
       ignore: ":hidden",
        rules: {

			"manufacturer_id": {
                required: true

            },
            mf_doc: {
			      required: true,
			      required: $('#gstCheck').is(':checked')
		    	},
          Manufacturer_file1: {
            required: true,
            
            required: $('#gstCheck').not(':checked')
          }
        },
        submitHandler: function(form, e) {
          $(".pageloader").show();
		        form.submit();
        }
    });
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/vendors/dealerregister.blade.php ENDPATH**/ ?>