<?php
session_start();

require('../includes/database.php');

if (isset($_SESSION['username']) && $_SESSION['password'] != "") {
} else {
    header("Location:index.php");
}
$username = $_SESSION['username'];


$username = $_SESSION['username'];
$password = $_SESSION['password'];

$query = "SELECT *
			FROM admin	
			WHERE username = '$username'
			&&   password = '$password'";

$result = mysqli_query($con, $query) or die(mysqli_connect_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
    while ($data = mysqli_fetch_assoc($result)) {

        extract($data);
        include('head.php');

?>

        <body class="theme-blush">

            <!-- Page Loader -->
            <?php
            # include('loader.php');
            ?>

            <!-- Overlay For Sidebars -->
            <div class="overlay"></div>

            <!-- Main Search -->
            <div id="search">
                <button id="close" type="button" class="close btn btn-primary btn-icon btn-icon-mini btn-round">x</button>
                <form>
                    <input type="search" value="" placeholder="Search..." />
                    <button type="submit" class="btn btn-primary">Search</button>
                </form>
            </div>

            <?php
            include('right-sidebar.php');
            include('left-side.php');
            ?>


            <!-- Right Sidebar -->
            <?php
            include('settings&pops.php');
            ?>

            <!-- Main Content -->

            <section class="content">
                <div class="">
                    <div class="block-header">
                        <div class="row">
                            <div class="col-lg-7 col-md-6 col-sm-12">
                                <h2>Admin Dashboard</h2>
                                <ul class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="index.php"><i class="zmdi zmdi-home"></i> Online Bank </a></li>
                                    <li class="breadcrumb-item active">Dashboard</li>
                                </ul>
                                <button style="background:red;" class="btn btn-icon mobile_menu" type="button"><i class="zmdi zmdi-sort-amount-desc"></i></button>
                            </div>
                            <div class="col-lg-5 col-md-6 col-sm-12">
                                <button style="background:red;" class="btn btn-icon float-right right_icon_toggle_btn" type="button"><i class="zmdi zmdi-arrow-right"></i></button>
                            </div>
                        </div>
                    </div>
                    <div class="container-fluid">

                        <?php include('admin-pan.php'); ?>


                        <div class="row clearfix">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <div style="margin-top: -20px;" class="card project_list">
                                    <div class="header">
                                        <h2>Recently Created Accounts</h2>
                                    </div>
                                    <div class="table-responsive">
                                        <table class="table table-hover c_table text-center">
                                            <thead>
                                                <tr>
                                                    <th>#</th>
                                                    <th>Number</th>
                                                    <th>Username</th>
                                                    <th>Email</th>
                                                    <th>Full Name</th>
                                                    <th>Balance</th>
                                                    <th>Date</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                require('../includes/database.php');
                                                $query = "SELECT * FROM accounts ORDER BY id DESC";
                                                $result = mysqli_query($con, $query) or die(mysqli_connect_error());
                                                $i = 0;
                                                while ($row = mysqli_fetch_assoc($result)) {
                                                    $i = $i + 1;
                                                ?>
                                                    <tr>
                                                        <td><strong><?php echo $i ?></strong></td>
                                                        <td><strong><?php echo $row['account_number']; ?></strong></td>
                                                        <td><strong><?php echo $row['username']; ?></strong></td>
                                                        <?php $user = ($row['email']); ?>
                                                        <td><a href="view-account.php?user=<?php echo $user ?>" title=""><?php echo $row['email']; ?></a></td>
                                                        <td><?php echo $row['fname'] . " " . $row['lname']; ?></td>
                                                        <td><strong><?php echo $row['currency'] . " " . number_format($row['balance'], 2); ?></strong></td>
                                                        <td><?php echo $row['date_created']; ?></td>
                                                    </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <ul class="pagination pagination-primary mt-4">
                                        <li class="page-item active"><a class="page-link" href="javascript:void(0);">1</a></li>
                                        <li class="page-item"><a class="page-link" href="javascript:void(0);">2</a></li>
                                        <li class="page-item"><a class="page-link" href="javascript:void(0);">3</a></li>
                                        <li class="page-item"><a class="page-link" href="javascript:void(0);">4</a></li>
                                        <li class="page-item"><a class="page-link" href="javascript:void(0);">5</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>

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

    <?php include('footer.php');
    }
} ?>