<?php
/**
 * updatepass.php -- Update Password
 */

include '../inc/config.inc.php'; // Configuration

ob_start();
session_start();

//date_default_timezone_set('Africa/Lagos');

error_reporting(E_ALL);
ini_set('display_errors', 1);

if ( !isset($_SESSION['admin']) || $_SESSION["loggedin"] !== true || trim($_SESSION['admin']) == '' ){
//header('Location: ' . $BASE_URL . 'wp-admin/');
header('Location: ' . $BASE_URL . 'signin');
exit;
}
if (isset($_POST['submit'])) {
    $uname = $_POST["uname"];
    if ($uname == FALSE) {
    $message = '<div class="alert alert-danger" style="color:red;">tax code cannot be empty</div>';
    } else {
        $stmt = $db_con->prepare("INSERT INTO `code`(code)VALUES('$uname')");
        $s =  $stmt->execute();
        if ($s) {
            $message ='<div class="alert alert-primary" >tax code created successfully</div>';
        } else {
            $message ='<div class="alert alert-danger" style="color:red;">tax code creation failed</div>';
    
        }
    }
    }
// Admin Details
$stmt = $db_con->prepare("SELECT * FROM admin WHERE id=:admin_id");
$stmt->execute(array(":admin_id"=>$_SESSION['admin']));
$adminRow = $stmt->fetch(PDO::FETCH_ASSOC);

?>

<!doctype html>
<html lang="en-uk">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="keywords" content="investment, Forex, Trading, Bitcoin, Cryptocurrency, Global investment, Live Trade, Trading class, indics">
<meta name="author" content="Paul HubWeb & Tech">
<meta name="theme-color" content="#313131" />
<!-- Site Properties -->
<title>create tax code- Live Fx Arena</title>
<link rel="shortcut icon" href="../img/Signals-Alert-3.png" type="image/x-icon">
<link rel="apple-touch-icon-precomposed" href="../img/Signals-Alert-3.png">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Typography CSS -->
<link rel="stylesheet" href="css/typography.css">
<!-- Style CSS -->
<link rel="stylesheet" href="css/style.css">
<!-- Responsive CSS -->
<link rel="stylesheet" href="css/responsive.css">
<style>
* {
box-sizing: border-box;
}

body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}

.header {
overflow: none;
background-color: none;
padding: 20px 10px;
padding-left: 5px;
position: fixed;
}

/*.header a {
float: center;
width:30px;
color: #fff;
text-align: center;
padding: 12px;
text-decoration: none;
font-size: 18px; 
line-height: 25px;
border-radius: 4px;
background-color:rgb(196, 0, 0);
border-color: rgb(196, 0, 0);
}*/

.header a.logo {
font-size: 25px;
font-weight: bold;
}

/*.header a:hover {
background-color:  #010847;
color: #fff;
}*/

/*.header a.active {
background-color: dodgerblue;
color: white;
}*/

.header-center {
float: left;
}

@media screen and (max-width: 500px) {
.header a {
float: none;
display: block;
text-align: left;
}

.header-right {
float: none;
}
}
</style>

<script src="../plugins/sweetalerts/promise-polyfill.js"></script>
<link href="../plugins/sweetalerts/sweetalert.css" rel="stylesheet" type="text/css" />

<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" rel="stylesheet" />
<style>
/*------ Google Font Style ------ */
body {font-family:'Roboto'!important;}
</style>

</head>
<body class="sidebar-main-active right-column-fixed">
<!-- loader Start -->
<div id="loading">
<div id="loading-center">
</div>
</div>
<!-- loader END -->
<!-- Wrapper Start -->
<div class="wrapper">
<?php include 'navbar.php' ?>
<!-- Page Content  -->
<div id="content-page" class="content-page" style="margin-top:90px;">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="iq-edit-list-data">
<div class="tab-content">
<div class="tab-pane fade active show" id="chang-pwd" role="tabpanel">

<!-- Update Password -->
<div class="iq-card">
<div class="iq-card-header d-flex justify-content-between">
<div class="iq-header-title">
<!-- <h4 class="card-title">Change Password</h4> -->
</div>
</div>
<div class="iq-card-body">
<form method="post" id="Register" action="">


<h1 class="mb-4">Coupon Code</h1>

<br>
<?php
if (isset($message)) {
echo $message;
}
?>
<div class="input-group mb-3">
<div class="input-group mb-3">
<input type="text" id="code" name="uname" class="form-control" placeholder="Recipient's username"
aria-label="input coupon code" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-secondary" onclick="document.getElementById('code').value = randomNumber(9)" type="button">Generate Coupon Code</button>
</div>
</div>
</div>
<button type="submit" class="btn btn-secondary mb-1" name="submit">create coupon</button>
</form>
 
</div>
</div>
<!--// Update Password -->


</div>
</div>
<div class="col-lg-12 col-md-12 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title">All Coupon codes created</h5>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Tax code</th>
</tr>
</thead>
<tbody>
    <?php
    $stmt = $db_con->prepare("SELECT * FROM code ORDER BY id DESC");
    $stmt->execute();
    $allcoupon = $stmt->fetchAll(PDO::FETCH_ASSOC);
  $count = 0;
  foreach ($allcoupon as $key => $value) {
$count++;
    ?>
<tr>
<!-- <th scope="row"><?php echo $count ?></th> -->
<td><?php echo $value['id'] ?></td>
<td><?php echo $value["code"] ?></td>
</tr>
<?php
}
    ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Wrapper END -->
<?php include 'footer.php' ?>
<!-- Optional JavaScript -->
<script src="../plugins/jquery-3.1.1.min.js"></script>
<script src="../plugins/sweetalerts/sweetalert2.min.js"></script>
<script src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.js"></script>

<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<!--<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>-->
<script src="js/bootstrap.min.js"></script>
<!-- Appear JavaScript -->
<script src="js/jquery.appear.js"></script>
<!-- Countdown JavaScript -->
<script src="js/countdown.min.js"></script>
<!-- Counterup JavaScript -->
<script src="js/waypoints.min.js"></script>
<script src="js/jquery.counterup.min.js"></script>
<!-- Wow JavaScript -->
<script src="js/wow.min.js"></script>
<!-- Apexcharts JavaScript -->
<script src="js/apexcharts.js"></script>
<!-- Slick JavaScript -->
<script src="js/slick.min.js"></script>
<!-- Select2 JavaScript -->
<script src="js/select2.min.js"></script>
<!-- Owl Carousel JavaScript -->
<script src="js/owl.carousel.min.js"></script>
<!-- Magnific Popup JavaScript -->
<script src="js/jquery.magnific-popup.min.js"></script>
<!-- Smooth Scrollbar JavaScript -->
<script src="js/smooth-scrollbar.js"></script>
<!-- lottie JavaScript -->
<script src="js/lottie.js"></script>
<!-- am core JavaScript -->
<script src="js/core.js"></script>
<!-- am charts JavaScript -->
<script src="js/charts.js"></script>
<!-- am animated JavaScript -->
<script src="js/animated.js"></script>
<!-- am kelly JavaScript -->
<script src="js/kelly.js"></script>
<!-- am maps JavaScript -->
<script src="js/maps.js"></script>
<!-- am worldLow JavaScript -->
<script src="js/worldLow.js"></script>
<!-- Style Customizer -->
<script src="js/style-customizer.js"></script>
<!-- Chart Custom JavaScript -->
<script src="js/chart-custom.js"></script>
<!-- Custom JavaScript -->
<script src="js/custom.js"></script>

<script>
function noticePop( value, type ){
swal({
html: '<span style="font-size:18px!important;">'+ `${value}` +'</span>',
type: `${type}`,
timer: 4000,
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
}).then(function(){
window.location.href = 'updatepas';
});
}
</script>
<script>
function randomNumber(len) {
var randomNumber;
var n = '';

for (var count = 0; count < len; count++) {
randomNumber = Math.floor(Math.random() * 10);
n += randomNumber.toString();
}
return n;
}

</script>
</body>
</html>