<?php

if (isset($_SESSION['user'])) {
$user = mysqli_query($conn, "SELECT * FROM `tb_user` WHERE user = '" . $_SESSION['user'] . "'") or die(mysqli_error());
$u = mysqli_fetch_array($user);
$users = $u['user'];
$userid = $u['user'];
$id_user = $u['cuid'];
$userID = $u['cuid'];
$extplayer = $u['extplayer'];
$token_id = isset($u['token_id']) ? $u['token_id'] : false;
$level = isset($u['level']) ? $u['level'] : false;

$sql_balance = mysqli_query($conn, "SELECT * FROM `tb_balance` WHERE userID = $userID") or die(mysqli_error());
$sb = mysqli_fetch_array($sql_balance);


?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <header>
        <h1><?php echo $s0['instansi']; ?>: Kuasai Pasar dengan Permainan Simulasi Trading Saham Terbaik!</h1>
        <div class="navbar-fixed">
            <a href="/" class="brand-logo"><img src="<?php echo $urlweb; ?>/upload/<?php echo $s0['image']; ?>" class="logo-img" alt="<?php echo $s0['instansi']; ?>"></a>
            <ul>
                <li><a class="button-collapse"><i id="menu_icon">menu icon</i></a></li>
            </ul>
        </div>

        <nav class="side-nav" id="side_nav">
            <div class="user-view">
                <ol>
                    <li><a class="deposit-btn" href="/bank/deposit">Deposit</a></li>
                    <li><a class="withdraw-btn" href="/bank/withdraw">Withdraw</a></li>
                    <li class="float-R"><a class="close-btn"><i class="icon-close" id="icon_close"></i></a></li>
                </ol>
                <p>
                    Hai, <span><?php echo $u['user']; ?></span>
                </p>
                <ul class="member-info ">
                    <li>
                        <div class="balance">
                            <a href="#" class="btn-withdraw" data-event="NavWithdrawAll"><i class="icon-allwithdraw"></i></a>
                            <strong><span id="mainamt"><span>IDR <?php echo number_format($sb['active']); ?></span></strong>
                            <a id="ReloadBalance"><i class="icon-refresh" id="querymainwallet"></i></a>
                        </div>
                    </li>
                </ul>
                <ul class="member-info " style="margin-top:5px; background:transparent;">
                    <li>
                        <div class="balance">
                            <a href="#" class="btn-withdraw" data-event="NavWithdrawAll"><i class="bi bi-person-check-fill" style="color:#ebcf31;"></i></a>
                            <strong><b><span style="color:#ebcf31">
                            <?php
                            if ($u['pinTrx'] == 1) {
                                echo 'Standard';
                            }

                            if ($u['pinTrx'] == 2) {
                                echo 'Pro';
                            }

                            if ($u['pinTrx'] == 3) {
                                echo 'Vip';
                            }

                            if ($u['pinTrx'] == 4) {
                                echo 'Sultan';
                            }

                            ?>
                            </span></b></strong>
                        </div>
                    </li>
                </ul>
            </div>
            <ul class="menu-body">
                <li><a href="/"><i class="icon-home"></i>Beranda</a></li>
                <li><a href="/account/profile"><i class="icon-menu-user"></i>Profil</a></li>
                <li><a href="/promotion"><i class="fas fa-gift"></i>Promotion</a></li>
                <li><a href="/bank/history"><i class="fas fa-history"></i>Riwayat</a></li>
                <li class="referral"><a href="/referral"><i class="icon_referral"></i>Referral</a></li>
                <li><a href="/game/favorite"><i class="fas fa-star"></i>Favorite</a></li>
                <li><a href="<?php echo $s1a['livechat']; ?>"><i class="icon-phone"></i>Hubungi Kami</a></li>
                <li>
                    <div class="select-type lang-select">
                        <i class="icon-translate"></i>
                        <select id="CurrLanguage" class="language-list">
                            <option value="en">English</option>
                            <option value="id" selected="selected">Bahasa Indonesia</option>
                            <option value="cn">简体中文</option>
                        </select>
                    </div>
                </li>
                <li><a href="/download"><i class="fas fa-arrow-alt-circle-down"></i>Download</a></li>
                <li><a href="<?php echo $urlweb ?>/logout"><i class="fas fa-sign-out-alt"></i>Keluar</a></li>
            </ul>

        </nav>
        <div id="sidenav_overlay"></div>
    </header>
<?php } else { ?>
    <header>
        <h1><?php echo $s0['instansi']; ?>: Kuasai Pasar dengan Permainan Simulasi Trading Saham Terbaik!</h1>
        <div class="navbar-fixed">
            <a href="/" class="brand-logo"><img src="<?php echo $urlweb; ?>/upload/<?php echo $s0['image']; ?>" class="logo-img" alt="<?php echo $s0['instansi']; ?>"></a>
            <ul>
                <li><a class="button-collapse"><i id="menu_icon">menu icon</i></a></li>
            </ul>
        </div>

        <nav class="side-nav" id="side_nav">
            <div class="user-view">
                <ol>
                    <li><a href="#">Selamat datang</a></li>
                    <li class="float-R"><a class="close-btn"><i class="icon-close" id="icon_close"></i></a></li>
                </ol>
                <p>
                    Silahkan masuk atau daftar</p>
                <ul class="member-btn ">
                    <li><a class="btn btn-secondary-primary" href="<?php echo $urlweb ?>/login">Masuk</a></li>
                    <li><a class="btn btn-join" href="<?php echo $urlweb ?>/register">Daftar</a></li>
                </ul>
            </div>
            <ul class="menu-body">
                <li><a href="/"><i class="icon-home"></i>Beranda</a></li>
                <li><a href="<?php echo $s1a['livechat']; ?>"><i class="icon-phone"></i>Hubungi Kami</a></li>
                <li>
                    <div class="select-type lang-select">
                        <i class="icon-translate"></i>
                        <select id="CurrLanguage" class="language-list">
                            <option value="en">English</option>
                            <option value="id" selected="selected">Bahasa Indonesia</option>
                            <option value="cn">简体中文</option>
                        </select>
                    </div>
                </li>
                <li><a href="/download"><i class="fas fa-arrow-alt-circle-down"></i>Download</a></li>
            </ul>

        </nav>
        <div id="sidenav_overlay"></div>
    </header>
<?php } ?>