
<div id="parallax-wrap" class="parallax-search" data-parallax="scroll" data-position="top" data-bleed="10" data-image-src="<?php echo base_url(''); ?>assets/images/b-2.jpg">

	<div class="search-wraps">
		<h1>Verification</h1>
	</div> <!--search-wraps-->

</div> 

<?php
$client_id = $this->session->userdata('client_id');

?>


<div class="sections section-grey2 section-mobile-verification section-orangeform">
  <div class="container">


  	<?php if($this->session->flashdata('success')){ ?>
				<div class="alert alert-success">
					<?php 
					echo $this->session->flashdata('success'); ?>
				</div>
				<?php unset($_SESSION['success']);
					?>.
			<?php } ?>



  	<?php if($this->session->flashdata('error')){ ?>
				<div class="alert alert-danger">
					<?php 
					echo $this->session->flashdata('error'); ?>.
				</div>
				<?php unset($_SESSION['error']);
					?>.
			<?php } ?>

    <div class="row top30">
      <div class="inner">
        <h1>We have sent verification code to your Email</h1>

        <div class="box-grey rounded">
          <form id="forms-verify" class="needs-validation forms has-validation-callback" method="POST" action="<?php echo base_url('site/verification_email') ?>" novalidate>
            
            <input type="hidden" name="client_id" id="client_id" value="<?php echo $client_id;?>" />
            <input type="hidden" name="redirect" id="redirect" value="" />

            <h4 class="section-header">Please enter your verification code</h4>

            <input type="text" name="code" id="code" class="numeric_only grey-fields" placeholder="Verification Code" required />

            <input type="submit" value="Submit" class="green-button inline" />
          </form>

          <p class="text-small text-center block">
            Did not receive your verification code?
            <a href="javascript:;" class="resend-code">Click here to resend</a>
          </p>
        </div> <!--box-grey-->
      </div> <!--inner-->
    </div> <!--row-->
  </div> <!--container-->
</div> <!--section-grey-->


<script>
$(document).on("click", ".resend-code", function (e) {
  e.preventDefault();
  
  var client_id = $("#client_id").val();

  if (!client_id) {
    alert("Client ID missing.");
    return;
  }

  $.ajax({
    url: "<?php echo base_url('site/resendEmailcode'); ?>",
    method: "POST",
    data: {
      client_id: client_id
    },
    success: function (response) {
      try {
        var res = JSON.parse(response);
        if (res.code === 1) {
          location.reload();
        } else {
          //alert(res.msg); // Error message
        }
      } catch (err) {
        //alert("Unexpected response.");
      }
    },
    error: function () {
      //alert("Failed to send request.");
    }
  });
});
</script>

