
  <div class="modal-body">
<?php
use App\Libraries\phpgangsta\googleauthenticator\PHPGangsta\PHPGangsta_GoogleAuthenticator;
use App\Libraries\Google_authendicator;
$this->session = session();
$validation =  \Config\Services::validation();
echo view('user/common_style1');
?>

<style type="text/css">
.box-header.with-border {
border-bottom-width: 1px;
border-bottom-style: solid;
background-color: gray ;
color: white;
}
.box-header {
color: #172b4c;
display: block;
padding: 1.5rem;
position: relative;
border-bottom: 1px solid rgba(72, 94, 144, 0.16);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.box-solid .box-body {
background-color: #ffffff !important;
color: #737373;
}
.box-body {
padding: 1.5rem;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
border-radius: 10px;
}
</style>

<section class="">
<div class="container">
<div class="row">
<div class="col-lg-10 offset-lg-1">
<div class="icon-square inner-box form-bg bg-white">
<div class="row">


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


<div class="form-reg">
<div class="row">

<div class="form-container mb-10">       


<div class="box box-solid   box-info" style="padding: 10px;margin-right: 10px;">
<div class="box-header theme-primary with-border">
<h4 class="box-title text-center"> Enter OTP </h4>
</div>

<div class="box-body row">
<div class="">

<?php 
$session = \Config\Services::session();

if($session->getFlashData('success_message')) {?>
<p class="frgtpwd frgtpwd1"><i class="fa fa-thumbs-up"></i><?php echo $session->getFlashData('success_message');?></p>
<?php } elseif ($session->getFlashData('error_message')) { ?>
<p class="frgtpwd frgtpwd1 frgtpwdred"><i class="fa fa-thumbs-down"></i><?php echo $session->getFlashData('error_message');?></p>
<?php } else { }?>

<p class="frgtpwd frgtpwd1 frgtpwdred" id="error_diss" style="display: none;"><i class="fa fa-thumbs-down"></i></p>
<p class="frgtpwd frgtpwd1" id="success_diss" style="display: none;"><i class="fa fa-thumbs-up"></i></p>

 <div id="otpmsg"></div> 


<form action="<?php echo $action; ?>" id="password_check_auth" class="form-validate trans_confirm" method="post">
<?php 
$this->db = db_connect();
$this->session = \Config\Services::session();
$this->common_model = model('CommonModel');

$condition = "uusersid = '".$memberid."'";
$uemail = $this->common_model->GetRow('uusers', $condition);                                  
$secret =  $uemail->secret_key;
$authenticator = new Google_authendicator();
$otp_code = $authenticator->getCode($secret); 

?>                                                   
<section class="content">


<div class="container" style="min-height: 10vh;">

<center>
<!--  <p style="color:green;"><b>SCAN THE CODE </b></p>
<img src="<?php echo $qr_code;?>">
<br><br> -->

<input type="hidden" name="memberid" id="memberid" value="<?php echo $memberid;?>">
<input type="hidden" name="gcodes" id="gcodes" value="<?php echo $codess;?>">
<input type="hidden" name="email" id="email" value="<?php echo $email; ?>">
</center>


<div style="margin-bottom:10;margin-top: 20px;" class="form-block form-group has-feedback has-feedback-left">

<input type="password" id="otp_code" name="otp_code" required="required" class="form-control" placeholder="Enter Code"/>

<?php echo $validation->getError('otp_code');?>

</div>

</div>

<span style="margin-top: 10px;margin-left: 26px;"><a id="getcode" style="font-size: 13px;background-color: transparent !important; color: #0d6efd !important;cursor: pointer;">Forgot Security Key ?</a></span>


<input name="tmp_id" type="hidden" id="tmp_id" value="<?php if($memberid){ echo $memberid;} else { echo ""; }?>" />

</section>

<div  class="row" style="margin-top: 10px;">
<div class="" style="display: inline-flex;justify-content: center;">
<button class="btn btn-primary" type="submit" id="step_done" style="">Submit</button>
</div>
</div>
</form>


</div>
</div>
</div>

<div class="form-title">


</div>
<br>



<div class="col-lg-12" style="padding: 20px;margin-bottom: 10px;">
<div class="row">
</div>
</div>

</div>
</div>
</div> 
</div> 

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


<script type="text/javascript">

	$("#password_check_auth").on("submit", function (e) {
	e.preventDefault();
    $('#step_done').pleaseWait();
        var memberid = $('#memberid').val();
        var gcodes = $('#gcodes').val();
        var otp_code = $('#otp_code').val();
        var tmp_id = $('#tmp_id').val();

		$.ajax({
		type: 'post',
		url : '<?php echo $action; ?>',
		data : {'memberid':memberid,'gcodes':gcodes,'otp_code':otp_code,'tmp_id':tmp_id},
		success : function(msg1)
		{

	    $('#step_done').pleaseWait('stop');
        var msg = JSON.parse(msg1);

		if(msg.result=='notok')
		{
		$('#error_diss').css('display','block');
		$('#error_diss').html(msg.message);
		}
		else
		{
		  $('#error_diss').css('display','none');
		
			$.ajax({
			type: 'get',
			url : '<?php echo base_url('/success_password_auth'); ?>',
			success : function(msg1)
			{
			  $('#loader').html(msg1);
			}
			});

		}

	    }
		})


	})


$(document).on("click", '#getcode', function() {

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

if(email !="")
{
$.ajax({
type: 'post',
url : '<?php echo base_url();?>/user/login/verifyregcode',
data : {'email':email},
dataType:'json',
success : function(msg)
{
console.log(msg);
if(msg!=='')
{
var myVar;
setTimeout(function()
{
$('#error_dis').css('display','none');
$("#otpmsg").html('<div  class="alert alert-success">'+msg+'</div>')},500);
}
}
})
}

});

</script>