<?php $__env->startSection('content'); ?>
<script src="<?php echo e(asset('js/plugins-init/jquery.min.js')); ?>" type="text/javascript"></script>
<style>
  .show {
    display: block;
  }

  .hide {
    display: none;
  }
</style>
  <div class="col-md-6">
      <div class="authincation-content">
          <div class="row no-gutters">
              <div class="col-xl-12">
                  <div class="auth-form">
                      <h4 class="text-center mb-4"><?php echo e(__('Reset Password')); ?></h4>
                      <?php if(session('status')): ?>
                          <div class="alert alert-success" role="alert">
                              <?php echo e(session('status')); ?>

                          </div>
                      <?php endif; ?>
                      <form method="post" action="<?php echo url('/user/getpassword'); ?>">
                        <?php echo csrf_field(); ?>
                        <div id="passdiv">
                            <div class="form-group">
                                <label for="phone" class="col-form-label text-md-right"><?php echo e(__('Phone Number')); ?></label>
                              <div class="">
                                  <input id="phone" type="number" class="form-control" name="phone" placeholder="Enter 10 digit mobile number" pattern="[0-9]{1}[0-9]{9}" maxlength="10" required autofocus>
                              </div>
                            </div>
                            <div class="text-center">
                               <button type="button" class="btn btn-primary" id="getOTPForm">
                                      Get OTP
                                </button>
                            </div>
                        </div>
                        <div id="otpdiv" class ="hide">
                            <div class="form-group col-6">
                                <label for="phone" class="col-form-label text-md-right">OTP</label>
                                <input type="otp" class="form-control" id="otp" placeholder="Enter OTP" name="otp">
                            </div>
                            <div class="form-group col-4">
                                <button id="otpSubmit" class="btn btn-primary btn-block">Submit</button>
                            </div>
                        </div>
                        <div id="passworddiv" class ="hide">
                            <div class="form-group">
                                <label class="mb-1"><strong>Phone Number</strong></label> : &nbsp;&nbsp;
                                <input type="hidden" id="phonenumber" name="phonenumber" class="form-control">
                                <strong><span id="phonediv"></span></strong>
                            </div>
                            <div class="form-group">
                                  <label>New Password</label>
                                  <input type="password" class="form-control" id="password" name="password" placeholder="Enter New Password" required>
                            </div>
                            <div class="form-group">
                                  <label>Confirm New Password</label>
                                  <input type="password" class="form-control" id="confirm_password" name="confirm_password" placeholder="Enter Confirm New Password" required>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn btn-primary btn-block">Send Password</button>
                            </div>
                        </div>
                      </form>
                  </div>
              </div>
          </div>
      </div>
  </div>
<script type="text/javascript">
$(function()
{
    $("#getOTPForm").click(function()
    {
        var phone= $("#phone").val();
        var csrf = "<?php echo e(csrf_token()); ?>";
        if(!phone)
        {
            alert("Please enter all fields");
            return false;
        }
        if(!ValidatePhone(phone))
        {
            return false;
        }
        $.ajax({
              type: "POST",
              url: "<?php echo e(url('/user/getphonenumberotp')); ?>",
              dataType : 'json',
              data: {_token: csrf, phone: phone},
              success: function( result ) 
              {
                if(result.statusCode == 200)
                {                    
                    $("#passdiv").removeClass('show');
                    $("#passdiv").addClass('hide');
                    $("#otpdiv").removeClass('hide'); 
                    $("#otpdiv").addClass('show'); 
                }
                else
                {
                    alert("No account available with this phone number");
                }
                
              }
        });   
    });

    $("#otpSubmit").click(function()
    {
        var phone= $("#phone").val();
        var csrf = "<?php echo e(csrf_token()); ?>";
        var otpentered = $("#otp").val();
        $.ajax({
            type: "POST",
            url: "<?php echo e(url('/user/otpphoneverify_password')); ?>",
            dataType : 'json',
            data: {_token: csrf, phone: phone, otpentered: otpentered},
            success: function( result ) 
            {
                if(result.statusCode == 200)
                {
                        $("#formdiv").removeClass('show');
                        $("#formdiv").addClass('hide');
                        $("#otpdiv").removeClass('show'); 
                        $("#otpdiv").addClass('hide'); 
                        $("#passworddiv").removeClass('hide'); 
                        $("#passworddiv").addClass('show');
                        $("#phonediv").html(phone);
                        $("#phonenumber").val(phone);
                }
                else
                {
                   sweetAlert("Oops...", "OTP doesnot match !!", "error");
                }
            }
        });   
    });
});

function ValidatePhone(phone) 
{
  var phoneformat =/^\d{10}$/;

 if (phone.match(phoneformat))
  {
    return (true);
  }
    alert("You have entered an invalid phone number!");
    return (false);
}
</script>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layout.fullwidth', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmprod/resources/views/public/forgotpassword.blade.php ENDPATH**/ ?>