<?php include "../main_includes/init.php";

if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != '') {
    $user = User::find_by_id($_SESSION['user_id']);

    // print_r($user);

    // return false;
    if ($user) {
        if ($user->role == 0) {

            redirect("../user");
        } else {
            define('BASE_URL', ROOT_URL.'/admin');

            $wallet = Wallet::find_by_query("SELECT * FROM wallet WHERE user_id=$user->id LIMIT 1");
            $wallet = array_shift($wallet);

            if (!$wallet) {
                redirect("../sign-out");
            }
        }
    } else {

        redirect("../sign-out");
    }
} else {
    redirect("../sign-out");
}

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png" />
    <link rel="icon" type="image/png" href="<?=ROOT_URL?>/assets/img/favicon.png" />
    <html lang="en" class="light">

    <title>ConfirmID</title>
    <!--     Fonts and icons     -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
    <!-- Font Awesome Icons -->
    <script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
    <!-- Nucleo Icons -->
    <link href="<?=ROOT_URL?>/assets/css/nucleo-icons.css" rel="stylesheet" />
    <link href="<?=ROOT_URL?>/assets/css/nucleo-svg.css" rel="stylesheet" />
    <link href="<?=ROOT_URL?>/assets/iziToast-master/dist/css/iziToast.css" rel="stylesheet" />
    <!-- Popper -->
    <script src="https://unpkg.com/@popperjs/core@2"></script>
    <!-- Main Styling -->
    <link href="<?=ROOT_URL?>/assets/bootstrap-5.2.3-dist/css/bootstrap.css" rel="stylesheet" />
    <!-- <link href="<?=ROOT_URL?>/assets/css/soft-ui-dashboard-tailwind.css?v=1.0.4" rel="stylesheet" /> -->
    <link href="<?=ROOT_URL?>/assets/DataTables-1.13.2/css/jquery.dataTables.css" rel="stylesheet" />
    <!-- <link href="<?=ROOT_URL?>/assets/js/jquery-3.6.3.min.js" rel="stylesheet" /> -->
    <script src="<?=ROOT_URL?>/assets/js/jquery-3.6.3.min.js"></script>
    <script src="<?=ROOT_URL?>/assets/iziToast-master/dist/js/iziToast.js"></script>
    <script src="<?=ROOT_URL?>/assets/DataTables-1.13.2/js/jquery.dataTables.js"></script>


    <link href="<?=ROOT_URL?>/assets/fontawesome-free-6.3.0-web/css/all.css" rel="stylesheet" />
    <script src="<?=ROOT_URL?>/assets/fontawesome-free-6.3.0-web/js/all.js"></script>

    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.8.1/flowbite.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.8.1/flowbite.min.js"></script>


</head>