<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">
  <title>Augmenting Intelligence to Buy, Sell and Manage|Meddbot</title>
  <meta content="" name="description">
  <meta content="" name="keywords">
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
  <!-- Favicons -->
  <link rel="icon" href="<?php echo e(url('assets/img/favicon.png')); ?>" type="image/png" sizes="16x16">

    <!-- Google Font -->
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700;800&display=swap" rel="stylesheet">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="<?php echo e(url('assets/css/bootstrap.min.css')); ?>">

    <!-- font awesome js -->
    <script src="https://kit.fontawesome.com/c026154490.js" crossorigin="anonymous"></script>


    <!-- Custom CSS -->
    <link rel="stylesheet" href="<?php echo e(url('assets/css/my-dashstyle.css')); ?>">

     <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
     <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css" rel="stylesheet" />
    <!--<title>Meddbot</title>-->

    <style>
      label.error{
        color: red !important;
        font-size: 12px !important;
        font-weight: 500;
      }
          input[type="password"]::-ms-reveal {
    display: none;
}
    </style>

  </head>
  <body>
<div class="pageloader" style="display: none;" >
	</div>


<section class="sign-up" >
    <div class="container sigCont">
        <form method="POST" id="buyerregister" action="<?php echo e(route('register')); ?>" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>
        <div class="sign-upbox" id="page1">
            <div class="row" style="margin:0;">
<!--
                 <div class="col-md-5 col-12 green-boxes">
                    <div class="fxt-bg-img">
                        <div class="fxt-header">
                            <div class="logo">
                                <img src="<?php echo e(url('assets/img/logo.png')); ?>" alt="Logo">
                            </div>


                        </div>
                    </div>
                   
                 </div>
-->
                 <div class="col-md-12 col-12 white-boxx">

                    <div class="loginform">
                        <div class="row">
                            <div class="col-12">
                                <div class="logo reg-logo">
                                <img src="<?php echo e(url('assets/img/logo.png')); ?>" alt="Logo">
                            </div>
                                <h6 class="sign-head">Sign Up</h6>
                            </div>

                       

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

                              <div class="form-inputs">
                                <div class="form-group">
                                    <p style="font-weight: 600; font-size: 14px;" class="label">User Type<sup>*</sup></p>
                                </div>
                             
                              <div class="form-group mt-3 mb-4" style="display:flex; align-items: center;">
                               
                                                                        <div class="d-f" style="display:flex; align-items: center; margin-right: 15px;" >
                                                                            <input style="    margin-right: 5px;" type="radio" name="user_type" value="2" checked>
                                                                            <label for="html">Vendor</label>
                                                                         </div>
                                                                         <div class="d-f" style="display:flex; align-items: center;" >
                                                                            <input style="    margin-right: 5px;" type="radio" id="css" name="user_type" value="3">
                                                                            <label for="css">Manufacturer</label><br>
                                                                        </div>
                                                                      </div>
                                                                    </div>

                            </div>
                            <div class="col-lg-12" id="Manufacturer_files" style="display:none;">
                              <div class="form-inputs" >
                                    <div class="form-group" style="margin-bottom: 15px;">
                                      <label>GST/VAT<sup>*</sup></label>
                                      <div class="upload-btn-wrapper">
                                          <div class="custom-file-upload">
                                            <input type="file" id="Manufacturer_file1" required name="Manufacturer_file1" autocomplete="Manufacturer_file1" autofocus>
                                            <label for="name" class="error fileerror1"></label>
                                          
                                          </div>
                                      </div>
                                    </div>
                                    <div class="form-group" style="margin-bottom: 15px;">
                                      <label>Udyog Adhar / Manufacturer registration certificate<sup>*</sup></label>
                                      <div class="upload-btn-wrapper">
                                          <div class="custom-file-upload">
                                            <input type="file" id="Manufacturer_file2"  name="Manufacturer_file2" autocomplete="Manufacturer_file2" autofocus>
                                            <label for="name" class="error fileerror2"></label>
                                          </div>
                                      </div>
                                    </div>
                                
                              </div>
                            </div>

                            <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Establishment Name<sup>*</sup></label>
                                       <input id="name" type="text"  required    name="name" class="form-control" value="<?php echo e(old('name')); ?>"  autocomplete="name" autofocus>
                                       <label for="name" class="error"></label>

                                     
                                       
                                       <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                            <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Email Id<sup>*</sup></label>
                                       <input id="email" type="email" class="form-control <?php $__errorArgs = ['email'];
$__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); ?>" name="email" value="<?php echo e(old('email')); ?>"  autocomplete="email">
                                       <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                              
                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Primary Mobile No<sup>*</sup></label>
                                       <div class="phone-input">  
                                           <select id="country_code" name="country_code" class="form-control">
                                          <option value="91" selected>+91</option>
                                          <!-- Add other country codes here -->
                                      </select>
                                       <input type="number" id="phone_no" class="form-control <?php $__errorArgs = ['phone_no'];
$__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); ?>" name="phone_no" value="<?php echo e(old('phone_no')); ?>" minlength="10" maxlength="10"   autocomplete="phone_no" autofocus>
                                         </div>
                                       <?php $__errorArgs = ['phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                              <div class="col-lg-6">
                                <select style="    padding: 8px 0px;border: 0;border-bottom: 1px solid #ccc !important;border: 0;" class="form-select w-100" id="country" name="state" aria-label="Default select example">
                                  
                                  <option value="101">India</option>
                                </select>
                              </div>


                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Contact Person Name<sup>*</sup></label>
                                       <input type="text" id="contact_name"   class="form-control <?php $__errorArgs = ['contact_name'];
$__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); ?>" name="contact_name" value="<?php echo e(old('contact_name')); ?>"  autocomplete="contact_name" autofocus>
                                       <?php $__errorArgs = ['contact_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>
                             
                            <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Contact Person Mobile No<sup>*</sup></label>
                                         <div class="phone-input"> 
                                              <select id="country_code" name="country_code" class="form-control">
                                          <option value="91" selected>+91</option>
                                          <!-- Add other country codes here -->
                                      </select>
                                       <input type="number" id="contact_phone_no" class="form-control <?php $__errorArgs = ['contact_phone_no'];
$__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); ?>" name="contact_phone_no" value="<?php echo e(old('contact_phone_no')); ?>" minlength="10" maxlength="10"  autocomplete="contact_phone_no" autofocus>
                                         </div>
                                       <?php $__errorArgs = ['contact_phone_no'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <span class="invalid-feedback" role="alert">
                                        <strong><?php echo e($message); ?></strong>
                                    </span>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>

                              <div class="col-lg-6">
                                <div class="form-inputs">
                                     <div class="form-group">
                                        <label class="label">Password<sup>*</sup></label>

                                        <div class="pas-sec">
                                       <input id="password" type="password" class="form-control <?php $__errorArgs = ['password'];
$__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); ?>" name="password" value="<?php echo e(old('password')); ?>" minlength="8"  autocomplete="new-password">
                                       <span toggle="#password-field" class="fa fa-fw fa-eye-slash field_icon toggle-password"></span>
                                        </div>
                                       <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                            <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                            </span>
                                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                      </div>
                                </div>
                              </div>
                              <div class="col-lg-6">
                                <div class="form-inputs" >
                                     <div class="form-group" style="margin-bottom: 15px;">
                                        <label class="label">Confirm Password<sup>*</sup></label>
                                         <div class="pas-sec">
                                       <input id="password-confirm" type="password" class="form-control"  name="password_confirmation" value="<?php echo e(old('password_confirmation')); ?>" minlength="8"  autocomplete="new-password">
                                              <span toggle="#password-field" class="fa fa-fw fa-eye-slash field_icon toggle-password2"></span>
                                         </div>
                                      </div>
                                </div>
                              </div>
                              <div class="g-recaptcha" data-sitekey="6LeXBmQqAAAAAHgAy90DbqB0rfVSn2Cw-uqUj7fY"></div>
                              <input id="user_status" type="hidden" class="form-control " name="user_status"  value="1">

                            <div class="col-12">
                                <div  class="green-button">
                                    
                                    <input type="submit" class="reg-button" value="Submit" id="next" />
                                 </div>
                             </div>
                        </div>
                    </div>
                 </div>
            </div>
        </div>
        


          <div class="sign-upbox" id="page3" style="display:none">
                <div class="row" style="margin: 0;">
                    <div class="col-md-5 col-12 green-boxes">
                        <div class="fxt-bg-img">
                            <div class="fxt-header">
                                <div class="logo">
                                    <img src="<?php echo e(url('assets/img/logo.png')); ?>" alt="Logo">
                                </div>
                              
                            </div>
                        </div>
                    </div>
                    <div class="col-md-7 col-12 white-boxx">

                        <div class="loginform">
                            <div class="row">
                            <div class="col-12">
                                    <h6 class="sign-head">OTP Verification</h6>
                                </div>
                                <div class="col-lg-12">
                                    <!--<label>Please enter the OTP send to your registered Email Id or Phone Number</label>-->
                                    <p id="otpMessage"></p>
                                    <div class="form-inputs">
                                        <div class="form-group">
                                            <label class="label">OTP<sup>*</sup></label>
                                                <input type="text" id="otp" class="form-control" name="otp" value="" required autofocus >
                                          <?php $__errorArgs = ['otp'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="invalid-feedback" role="alert">
                                            <strong><?php echo e($message); ?></strong>
                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                          </div>
                                    </div>
                                  </div>

                                <div class="col-12">
                                    <div class="reg-flex">
                                    <div class="green-button" style="padding: 15px 0;width: 100%;margin: 0">
                                       <input type="submit" value="Verify"  style="max-width: 130px;" class="reg-button"  id="otpverify" />
                                       
                                    </div><br/>
                                    <div class="green-button" style="padding: 15px 0;width: 100%;margin: 0">
                                        <button style="max-width: 130px;" id="resend" type="submit">Resend</button>
                                    </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

         </form>
    </div>
</section>

  <script src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="<?php echo e(url('assets/js/bootstrap.min.js')); ?>"></script>
  <script src="<?php echo e(url('assets/js/my-dashjs.js')); ?>"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
  <script src="<?php echo e(URL::to('assets/js/validation/jquery.validate.min.js')); ?>"> </script>
	<script src="<?php echo e(URL::to('assets/js/validation/additional-methods.js')); ?>"></script>
  <script>
 $(document).ready(function() {
    $(document).on('click', '.toggle-password', function() {
        // Toggle the icon class between fa-eye and fa-eye-slash
        if ($(this).hasClass("fa-eye-slash")) {
            $(this).removeClass("fa-eye-slash").addClass("fa-eye");
        } else {
            $(this).removeClass("fa-eye").addClass("fa-eye-slash");
        }
        
        // Get the password input field
        var input = $("#password");

        // Toggle the type attribute between 'password' and 'text'
        var inputType = input.attr('type');
        input.attr('type', inputType === 'password' ? 'text' : 'password');
    });
    
});

        
$(document).ready(function() {
    $(document).on('click', '.toggle-password2', function() {
        // Toggle the icon class between fa-eye and fa-eye-slash
        if ($(this).hasClass("fa-eye-slash")) {
            $(this).removeClass("fa-eye-slash").addClass("fa-eye");
        } else {
            $(this).removeClass("fa-eye").addClass("fa-eye-slash");
        }
        
        // Get the password input field
        var input = $("#password-confirm");

        // Toggle the type attribute between 'password' and 'text'
        var inputType = input.attr('type');
        input.attr('type', inputType === 'password' ? 'text' : 'password');
    });
    
});
      
      
      
      
      
      
      
      
      
jQuery.validator.addMethod("nameval", function(value, element) {
    //test user value with the regex
    return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
  }, "Enter only Albhabets");

  jQuery.validator.addMethod("letters_numbers_special", function(value, element) {
    return this.optional(element) || /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/i.test(value);
  //(?=.*[a-zA-Z\d].*)[a-zA-Z\d!@#$%&*]
}, "Password should contain at least one digit, one lower case or upper case and  one special characters");


jQuery.validator.addMethod('notEqualTo', function(value, element, param) {
    // param should be the selector or actual value to compare against
    return this.optional(element) || value !== $(param).val();
}, 'Contact mobile number must be different from your mobile number');




jQuery.validator.addMethod("noLeadingZeros", function(value, element) {
    return this.optional(element) || /^[1-9]\d*$/.test(value);
}, "Please enter a valid number without leading zeros");
var validatedata=0;

document.getElementById('phone_no').addEventListener('input', function (event) {
            let input = event.target;
            if (input.value.length > 10) {
                input.value = input.value.slice(0, 10);
            }
        });

        document.getElementById('contact_phone_no').addEventListener('input', function (event) {
            let input = event.target;
            if (input.value.length > 10) {
                input.value = input.value.slice(0, 10);
            }
        });

$("#buyerregister").validate({
    rules: {
        name: {
            required: true,
            nameval: true  
        },
        user_type: {
            required: true
        },
        email: {
            required: true,
            email: true
        },
        phone_no: {
            required: true,
            digits: true,
            noLeadingZeros: true
        },
        contact_name: {
            required: true,
            nameval: true  // Ensure this is defined
        },
        contact_phone_no: {
            required: true,
            digits: true,
            noLeadingZeros: true,
            notEqualTo: '#phone_no'
        },
        password: {
            required: true,
            letters_numbers_special: true  // Ensure this is defined
        },
        password_confirmation: {
            required: true,
            equalTo: "#password"
        }
    },
    messages: {
        name: 
        
        {
          required:"This field is required.",
          nameval:"Enter Alphabets Only"
        },
        email: {
            required: "Please enter your email.",
            email: "Please enter a valid email address."
        },
        phone_no:
        {
          required:"This field is required.",
        },
        contact_name: 
        {
          required:"This field is required.",
           nameval:"Enter Alphabets Only"
        },
        contact_phone_no: {
            required: "This field is required.",
            //notEqualTo: "Contact phone number must be different from your phone number."
        },
        password: {
            required: "Please provide a password.",
            letters_numbers_special: "Password must contain letters, numbers, and special characters."  // Ensure this is defined
        },
        password_confirmation: {
            required: "Please confirm your password.",
            equalTo: "Passwords do not match."
        }
    },
    highlight: function (element) {
        $(element).addClass('error');
    },
    unhighlight: function (element) {
        $(element).removeClass('error');
    },
    errorPlacement: function (error, element) {
        error.insertAfter(element);
    },
    submitHandler: function(form, e) {

      if (grecaptcha.getResponse() == ''){
                
                swal("", "You must complete the antispam verification", "warning");
            }
      else if(validatedata==0) {
    $(".pageloader").show();
        var email   = $('#email').val();
        var phoneno = $('#phone_no').val();
            var data = {
           _token	:'<?php echo e(csrf_token()); ?>',
            email:email,
            phone:phoneno
          }
  
          $.ajax({
            url:'https://www.meddbot.com/emailexist',
            type: "POST",
            data: data,
            success: function (res) {
              var obj = jQuery.parseJSON(res);
             
              if(res==1){ 
                $(".pageloader").hide();
  
                swal("", "Email Id already exist", "warning");
               }
              if(res==2){
                $(".pageloader").hide();
                swal("", "Phone No already exist", "warning");
              }
              if(res==0){
  
                        var email = $('#email').val();
                        var phoneno = $('#phone_no').val();
                        var otp = Math.floor(100000 + Math.random() * 999999);
    
                        var APP_URL = <?php echo json_encode(url('/setotp')); ?> ;
                        var saveData = $.ajax({
                        type: 'GET',
                        url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                        data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                        dataType: "text",
                            success: function(resultData) {
                                console.log(resultData);
                                /*if(resultData == 'success'){
                                    alert('success');
                                }*/
                            }
                        });
                        var SMS_URL = 'https://www.meddbot.com/twiliosms/' ;
                        var saveData = $.ajax({
                            type: 'POST',
                            url: SMS_URL,
                            data: { phoneno: phoneno, otp:otp, _token: '<?php echo e(csrf_token()); ?>' },
                            dataType: "text",
                            success: function(resultData) {


                              console.log(resultData);
                              console.log(otp);

                              
                              $(".pageloader").hide();
                              $("#page1").hide();  
                              
                              $(".pageloader").hide();
                            $("#page1").hide();

                            var email = $('#email').val();
                            var phoneNo = $('#phone_no').val();

                          // Process email
                          var emailParts = email.split('@');
                          var emailPrefix = emailParts[0];
                          var emailDomain = emailParts[1];
                          var obfuscatedEmail = emailPrefix.substring(0, 3) + 'xxxxxxxxxx' + '@' + emailDomain;

                          // Process phone number
                          var phoneLastDigits = phoneNo.slice(-3);
                          var obfuscatedPhoneNo = 'xxxxxxx' + phoneLastDigits;

                          // Show OTP screen with the formatted message
                          $('#otpMessage').text(
                              'OTP sent on the email id: ' + obfuscatedEmail + ' & Mobile no.: ' + obfuscatedPhoneNo + '. Kindly check and enter below:'
                          );

                              $("#page3").show();
                            }
                        });
  
              }
              
            }
          });
  
        }
        else{
          form.submit();
        }

    }
});

    $("#backpage1").click(function(){
            $("#page1").hide();
            $("#page3").hide();
            $("#page2").show();
    });
    $("#backpage").click(function(){
        $("#page3").hide();
        $("#page2").hide();
        $("#page1").show();
    });

    $(document).ready(function() {
   $('#otpverify').on('click', function(event) {
       event.preventDefault();
       if($('#otp').val()==''){ 
        swal("", "Please enter a valid OTP", "warning");
      }
     else{
      $(".pageloader").show();
      var email = $('#email').val();
                    var phoneno = $('#phone_no').val();
                    var otp =  $('#otp').val();
                    var APP_URL = <?php echo json_encode(url('/verifyotp')); ?> ;
                    var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                    data: { email: email,phoneno: phoneno, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "text",
                        success: function(resultData) {
                          $(".pageloader").hide();
                            if(resultData == '1'){

                              $(".pageloader").hide();

                              swal({
                                title: "",
                                text: "OTP is verified successfully",
                                type: "success",
                              }, function () {
                                validatedata=1;
                                $(".pageloader").show();
                                $("form").submit();
                              });

                            }else if(resultData == '0'){
                              swal("", "Please enter a valid OTP", "warning");
                                //alert('Please Enter a valid otp');
                                $('#otp').val('');
                            }else{

                              swal("", "Please enter a valid OTP", "warning");
                                // alert('Please Enter a valid otp');
                                $('#otp').val('');
                            }
                    }
                    });



     }               
    });

   $('#resend').on('click', function(event) {
       event.preventDefault();
       $(".pageloader").show();
                    var email = $('#email').val();
                    var phoneno = $('#phone_no').val();
                    var APP_URL = <?php echo json_encode(url('/checkotp')); ?>

                    var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+email+'/'+phoneno,
                    data: { email: email,phoneno: phoneno, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "text",
                        success: function(resultData) {
                         var res = JSON.parse(resultData);
                         console.log(res);
                         if(res.otp_code !== null && res.otp_code !== ''){
                             var otp = res.otp_code;
                         }else{
                            var otp = Math.floor(100000 + Math.random() * 999999);
                         }
                           
                            var APP_URL = <?php echo json_encode(url('/resendotp')); ?> ;
                            var saveData = $.ajax({
                            type: 'GET',
                            url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                            data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                            dataType: "text",
                                success: function(resultData) {
                                 
                                        
                                }
                            });


                            var SMS_URL = 'https://www.meddbot.com/twiliosms/' ;
                            var saveData = $.ajax({
                                type: 'POST',
                                url: SMS_URL,
                                data: { phoneno: phoneno, otp:otp, _token: '<?php echo e(csrf_token()); ?>' },
                                dataType: "text",
                                success: function(resultData) {
                                  
                                  $(".pageloader").hide();
                                  swal("", "OTP send to your registered Email Id or Mobile Number", "success");
                                }
                            });

                           
                    }
                    })
    });
});






 /*
    $('#country').on('change', function() {
      var countryid = this.value;
      var APP_URL = <?php echo json_encode(url('/getstates')); ?> ;
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+countryid,
            data: { countryid: countryid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) {
              $("#state").html(resultData);
            }
            });

    });


$(".js-example-basic-multiple").select2({
  placeholder: "Select a Manufacturer"
});


    $('#country1').on('change', function() {
      var countryid = this.value;
      var APP_URL = <?php echo json_encode(url('/getstates')); ?> ;
      var saveData = $.ajax({
            type: 'GET',
            url: APP_URL+'/'+countryid,
            data: { countryid: countryid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "text",
            success: function(resultData) {
              $("#state1").html(resultData);
            }
            });

    });
    $(document).ready(function() {

   $('#nextpage').on('click', function() {
    if($("#buyerregister").valid()){
      $(".pageloader").show();
      var email   = $('#email').val();
      var phoneno = $('#phone_no').val();
          var data = {
				 _token	:'<?php echo e(csrf_token()); ?>',
				  email:email,
          phone:phoneno
				}

        $.ajax({
					url:'https://www.meddbot.com/emailexist',
					type: "POST",
					data: data,
					success: function (res) {
						var obj = jQuery.parseJSON(res);
           
						if(res==1){ 
              $(".pageloader").hide();

              swal("", "Email Id already exist", "warning");
             }
            if(res==2){
              $(".pageloader").hide();
              swal("", "Phone No already exist", "warning");
            }
            if(res==0){

                      var email = $('#email').val();
                      var phoneno = $('#phone_no').val();
                      var otp = Math.floor(100000 + Math.random() * 999999);
  
                      var APP_URL = <?php echo json_encode(url('/setotp')); ?> ;
                      var saveData = $.ajax({
                      type: 'GET',
                      url: APP_URL+'/'+email+'/'+phoneno+'/'+otp,
                      data: { email: email,phoneno: phoneno,otp: otp, _token: '<?php echo e(csrf_token()); ?>' },
                      dataType: "text",
                          success: function(resultData) {
                              console.log(resultData);
                              /*if(resultData == 'success'){
                                  alert('success');
                              }
                          }
                      });
                      var SMS_URL = 'https://www.meddbot.com/twiliosms/' ;
                      var saveData = $.ajax({
                          type: 'POST',
                          url: SMS_URL,
                          data: { phoneno: phoneno, otp:otp, _token: '<?php echo e(csrf_token()); ?>' },
                          dataType: "text",
                          success: function(resultData) {
                            $(".pageloader").hide();
                            $("#page1").hide();              
                            $("#page3").show();
                          }
                      });

            }
						
		
					}
				});
          

    }
  
    });
});

    $(document).ready(function() {
    $("#nextpage1").validate({  // initialize plugin on the form
         ignore: [],
        rules: {
            "address": {
                required: true

            },
			"state": {
                required: true

            },
			"city": {
                required: true

            },
            	"zipcode": {
                required: true

            },

            "contact_name": {
                required: true

            },
            "contact_phone_no": {
                required: true,
                matches:"[0-9]+",

            },
            "vendor_type": {
                required: true

            },


        },

    });
   $('#nextpage1').on('click', function() {
        if($("#buyerregister").valid()){
             $("#page1").hide();
        $("#page2").hide();
        $("#page3").show();
        }
    });
});

    $(document).ready(function() {
   $('#gst_no').focusout(function() {
        var gst_no = $('#gst_no').val();
        if($('#gst_no').val() != ""){
                var gst_no = $('#gst_no').val();
                var APP_URL = <?php echo json_encode(url('/getmanufacturedetailsregister')); ?> ;
                var saveData = $.ajax({
                    type: 'GET',
                    url: APP_URL+'/'+gst_no,
                    data: { gst_no: gst_no, _token: '<?php echo e(csrf_token()); ?>' },
                    dataType: "text",
                        success: function(resultData) {
                            console.log(resultData);
                            var res = JSON.parse(resultData);
                            if(res !== null && res !== ''){
                                if(res.user_type == '1'){
                                    alert('This Gst No is already registered as a buyer.');
                                }else if(res.user_type == '2'){
                                    alert('This Gst No is already registered as a Vendor.');
                                }else if(res.user_type == '3'){
                                     alert('This Gst No is already registered as a Manufacturer.');
                                }

                            }else{
                                var gst = $('#gst_no').val();
                                var APP_URL = <?php echo json_encode(url('/getgstdetailsregister')); ?> ;
                                var saveData = $.ajax({
                                    type: 'GET',
                                    url: APP_URL+'/'+gst,
                                    data: { gst: gst, _token: '<?php echo e(csrf_token()); ?>' },
                                    dataType: "text",
                                        success: function(resultData) {
                                        var res = JSON.parse(resultData);
                                        var name= res.taxpayerInfo.tradeNam;
                                        var dno = res.taxpayerInfo.adadr[0].addr.bno;
                                        var bnm = res.taxpayerInfo.adadr[0].addr.bnm;
                                        var st = res.taxpayerInfo.adadr[0].addr.st;
                                        var loc = res.taxpayerInfo.adadr[0].addr.loc;
                                        var dst = res.taxpayerInfo.adadr[0].addr.dst;
                                        var stcd = res.taxpayerInfo.adadr[0].addr.stcd;
                                        var pncd = res.taxpayerInfo.adadr[0].addr.pncd;
                                        var address =dno+','+bnm+','+st+','+loc+','+dst+','+stcd+','+pncd;
                                        $('#name').val(name);
                                        $('#address').val(address);
                                        $('#zipcode').val(pncd);
                                    }
                                });
                            }


                    }
                });
                $(".pageloader").show();
                $(".pageloader").delay(5000).fadeOut("slow");
        }else{
            $('#name').val('');
            $('#address').val('');
            $('#zipcode').val('');
        }
    });
});

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

    var vendor_type=$("#user_type").val();
    if(vendor_type=='')
    {
      //$("#Dealer_files").hide();
      $("#Manufacturer_files").hide();
    }
    
    if(vendor_type=='3')
    {
      //$("#Manufacturer_files").show();
     // $("#Dealer_files").hide();
    }
    if(vendor_type=='2')
    {
      $("#Manufacturer_files").hide();
      //$("#Dealer_files").hide();
    }
  })

//Reference:
//https://www.onextrapixel.com/2012/12/10/how-to-create-a-custom-file-input-with-jquery-css3-and-php/
(function ($) {
  // Browser supports HTML5 multiple file?
  var multipleSupport = typeof $("<input/>")[0].multiple !== "undefined",
    isIE = /msie/i.test(navigator.userAgent);

  $.fn.customFile = function () {
    return this.each(function () {
      var $file = $(this).addClass("custom-file-upload-hidden"), // the original file input
        $wrap = $('<div class="file-upload-wrapper">'),
        $input = $('<input type="text" class="file-upload-input" />'),
        // Button that will be used in non-IE browsers
        $button = $(
          '<button type="button" class="file-upload-button">Select a File</button>'
        ),
        // Hack for IE
        $label = $(
          '<label class="file-upload-button" for="' +
            $file[0].id +
            '">Select a File</label>'
        );

      // Hide by shifting to the left so we
      // can still trigger events
      $file.css({
        position: "absolute",
        left: "-9999px"
      });

      $wrap.insertAfter($file).append($file, $input, isIE ? $label : $button);

      // Prevent focus
      $file.attr("tabIndex", -1);
      $button.attr("tabIndex", -1);

      $button.click(function () {
        $file.focus().click(); // Open dialog
      });

      $file.change(function () {
        var files = [],
          fileArr,
          filename;

        // If multiple is supported then extract
        // all filenames from the file array
        if (multipleSupport) {
          fileArr = $file[0].files;
          for (var i = 0, len = fileArr.length; i < len; i++) {
            files.push(fileArr[i].name);
          }
          filename = files.join(", ");

          // If not supported then just take the value
          // and remove the path to just show the filename
        } else {
          filename = $file.val().split("\\").pop();
        }

        $input
          .val(filename) // Set the value
          .attr("title", filename) // Show filename in title tootlip
          .focus(); // Regain focus
      });

      $input.on({
        blur: function () {
          $file.trigger("blur");
        },
        keydown: function (e) {
          if (e.which === 13) {
            // Enter
            if (!isIE) {
              $file.trigger("click");
            }
          } else if (e.which === 8 || e.which === 46) {
            // Backspace & Del
            // On some browsers the value is read-only
            // with this trick we remove the old input and add
            // a clean clone with all the original events attached
            $file.replaceWith(($file = $file.clone(true)));
            $file.trigger("change");
            $input.val("");
          } else if (e.which === 9) {
            // TAB
            return;
          } else {
            // All other keys
            return false;
          }
        }
      });
    });
  };

  // Old browser fallback
  if (!multipleSupport) {
    $(document).on("change", "input.customfile", function () {
      var $this = $(this),
        // Create a unique ID so we
        // can attach the label to the input
        uniqId = "customfile_" + new Date().getTime(),
        $wrap = $this.parent(),
        // Filter empty input
        $inputs = $wrap
          .siblings()
          .find(".file-upload-input")
          .filter(function () {
            return !this.value;
          }),
        $file = $(
          '<input type="file" id="' +
            uniqId +
            '" name="' +
            $this.attr("name") +
            '"/>'
        );

      // 1ms timeout so it runs after all other events
      // that modify the value have triggered
      setTimeout(function () {
        // Add a new input
        if ($this.val()) {
          // Check for empty fields to prevent
          // creating new inputs when changing files
          if (!$inputs.length) {
            $wrap.after($file);
            $file.customFile();
          }
          // Remove and reorganize inputs
        } else {
          $inputs.parent().remove();
          // Move the input so it's always last on the list
          $wrap.appendTo($wrap.parent());
          $wrap.find("input").focus();
        }
      }, 1);
    });
  }
})(jQuery);

$("input[type=file]").customFile();

*/



var $disabledResults = $(".js-example-disabled-results");
$disabledResults.select2();
</script>
  </body>
</html>
<?php /**PATH /home/meddbot/public_html/resources/views/auth/vendorregister.blade.php ENDPATH**/ ?>