<?php
session_start();

if(!isset($_SESSION['customer_login'])) 
    header('location:index.php');   
?>


<?php

$cust_id=$_SESSION['cust_id'];
include '_inc/dbconn.php';


$success = "";
$error_message = "";

if(!empty($_POST["submit_otp"])) {
	$result = mysqli_query($con,"SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "' AND is_expired!=1 AND NOW() <= DATE_ADD(create_at, INTERVAL 24 HOUR)");
	$count  = mysqli_num_rows($result);
	if(!empty($count)) {
		$result = mysqli_query($con,"UPDATE otp_expiry SET is_expired = 1 WHERE otp = '" . $_POST["otp"] . "'");
		$success = 2;	
	} else {
		$success =1;
		$error_message = "Invalid OTP!";
	}	
}
?>



<?php include 'header.php' ?>

<?php include 'customer_navbar.php'?>
<style>
body{
font-family: calibri;
}
.form_container {
    border: 1px solid rgba(0, 0, 0, .05);
    box-shadow: 15px 26px 30px rgba(0, 0, 0, .09);
    border-left: 1px solid rgba(0, 0, 0, .06);
border-radius: 4px;
max-width: 500px;
padding: 20px 30px 30px;
text-align: center;
margin:0 auto;
}
.sanhead { font-size: 20px; }
.san { padding:20px; }
.error_message {
color: #b12d2d;
text-align: center;
background-color: #ffd9d9;
}
.message {
width: 100%;
max-width: 300px;
padding: 10px 30px;
border-radius: 4px;
margin: 0 auto;
margin-bottom: 5px;    
text-align: center;
}
.inputclass{
border: #CCC 1px solid;
padding: 10px 20px;
border-radius:4px;
}
.submit_button {
padding: 10px 20px;
background: #a9961e;
border: #736615 1px solid;
color: #FFF;
border-radius:4px;
}
</style>

<div class="content-wrapper">
          <div class="content">  



          <?php
if(!empty($error_message)) {
?>
<div class="message error_message"><?php echo $error_message; ?></div>
<?php
}
?>

<form name="frmUser" method="post" action="">

<div class="row justify-content-center mt-50">

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


                                                <?php 
			if(!empty($success == 1)) { 
		?>

<!-- Small Buttons -->
<div class="card card-default">
												<div class="card-header card-header-border-bottom">


													<h4 class="text-mute">Fund Transfer</h4>
												</div>
												<div class="card-body">
													<p class="mb-5">Please check your email for One-Time Password.</p>
                                                    <div class="text-right">


                                                    <input type="text" name="otp" placeholder="One Time Password" required>
													<input type="submit" name="submit_otp" class="btn btn-outline-success" value="Submit OTP">
                                                    <a href="#" class="btn btn-outline-danger">Go Home</a>




                                                    

<?php 
} else if ($success == 2) {
$result = mysqli_query($con,"SELECT * FROM otp_expiry WHERE otp='" . $_POST["otp"] . "'");

$count=mysqli_num_rows($result);
$row=mysqli_fetch_array($result);

if($count > 0){

header('Location: customer_mini_statement.php');
}
}
?>

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

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