<?php
require 'RGShenn.php';

if (!isset($_SESSION['user']) && !isset($_COOKIE['token']) && !isset($_COOKIE['ssid'])) {
    $ShennID = $_COOKIE['ssid'];
    $ShennUID = str_replace(['SHENN-A', 'AIY'], '', $ShennID) + 0;
    $ShennKey = $_COOKIE['token'];
    $ShennUser = $call->query("SELECT * FROM users WHERE id = '$ShennUID'")->fetch_assoc();

    $ShennCheck = $call->query("SELECT * FROM users_cookie WHERE cookie = '$ShennKey' AND username = '" . $ShennUser['username'] . "'");
    
    if ($ShennCheck->num_rows == 1) {
        $_SESSION['user'] = $ShennUser;
        redirect(0, visited());
        $call->query("UPDATE users_cookie SET active = '$date $time' WHERE cookie = '$ShennKey'");
    } else {
        redirect(0, base_url('auth/login'));
    }
} else {
    if ((time() - $_SESSION['last_login_time']) > 3600) {
        redirect(0, base_url('auth/logout'));
    } else {
        $_SESSION['last_login_time'] = time();
        require _DIR_('library/session/user');
        $page = 'Dashboard';
        require _DIR_('library/header/user');
?>

<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $_CONFIG['title'] ?></title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
    
    <style>
        /* Tambahkan padding atas agar header tidak tertutup */
        body {
            padding-top: 65px; /* Sesuaikan dengan tinggi navbar */
        }
        
        .top-left {
            font-size: 20px;
            color: black;
            font-weight: bold;
        }
        .top-balance {
            font-size: 16px;
            color: black;
            font-weight: bold;
        }
        .card-custom {
            border-radius: 10px;
            margin: 10px;
            padding: 10px;
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
        }
        .app-menu .col {
            font-size: 12px;
            font-weight: bold;
            color: #333;
        }
        .app-menu i {
            font-size: 30px;
            color: #5f33ba;
        }
    </style>
</head>
<body>

<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
    <div class="container">
        <a class="navbar-brand fw-bold" href="#">Dashboard</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav ms-auto">
                <li class="nav-item">
                    <a class="nav-link active" href="#"><i class="bi bi-house-door"></i> Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/deposit"><i class="bi bi-wallet2"></i> Deposit</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/premium/tarik-komisi.php"><i class="bi bi-cash"></i> Tarik Komisi</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/page/riwayat"><i class="bi bi-clock-history"></i> History</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link text-light fw-bold" href="/auth/logout"><i class="bi bi-box-arrow-right"></i> Logout</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

    <!-- Header -->
    <div class="text-center">
        <div class="top-left"><?= $_CONFIG['title'] ?></div>
        <div class="top-balance">Rp <span class="fs-4 text-primary"><?= currency($data_user['balance']) ?></span></div>
    </div>

    <!-- Card Menu -->
        <div class="card-body">
            <div class="row text-center">
                <div class="col-3">
                    <a href="/deposit" class="d-block text-decoration-none text-dark">
                        <i class="bi bi-wallet2"></i><br>Top Up
                    </a>
                </div>
                <div class="col-3">
                    <a href="/deposit/transfer" class="d-block text-decoration-none text-dark">
                        <i class="bi bi-arrow-left-right"></i><br>Transfer
                    </a>
                </div>
                <div class="col-3">
                    <a href="/premium/tarik-komisi.php" class="d-block text-decoration-none text-dark">
                        <i class="bi bi-cash"></i><br>Tarik Komisi
                    </a>
                </div>
                <div class="col-3">
                    <a href="/page/riwayat" class="d-block text-decoration-none text-dark">
                        <i class="bi bi-clock-history"></i><br>History
                    </a>
                </div>
            </div>
        </div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

    <!-- App Capsule -->
        <div id="appCapsule" class="pb-0">
        <div class="section service">
        <div class="wide-block-service">
            <div class="p-2 pb-2">
                <div class="title">Isi Ulang Sehari-hari</div>
            </div>
            <div class="app-menu mt-0">
                <a href="<?= base_url('order/pulsa-reguler') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/pulsa-reg.png') ?>" width="55px" height="55px">
                        <strong>Pulsa Reguler</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/pulsa-transfer') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/pulsa-transfer.png') ?>" width="55px" height="55px">
                        <strong>Pulsa Transfer</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/paket-internet') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/paket-data.png') ?>" width="55px" height="55px">
                        <strong>Paket Data</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/paket-telp') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/telpon-sms.png') ?>" width="55px" height="55px">
                        <strong>SMS & Telepon</strong>
                    </div>
                </a>
            </div>
            <div class="app-menu mt-3">
                <a href="<?= base_url('order/token-pln') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/token-pln.png') ?>" width="55px" height="55px">
                        <strong>Token PLN</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/pulsa-international') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/pulsa-internasional.png') ?>" width="55px" height="55px">
                        <strong>Pulsa Inter</strong>
                    </div>
                </a> 
                <a href="<?= base_url('order/e-money') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/money.png') ?>" width="55px" height="55px">
                        <strong>E-Money</strong>
                    </div>
                </a>
                
                <a href="#" class="item"></a>
            </div>
        </div>
            </div>
        <div class="section full bg-white pl-1 pr-1 pb-3 mb-1"> 
        </div>
        <!--
            <div class="p-2 pb-2">
                <div class="title">Uang Elektronik</div>
                <div style="font-size: 12px; opacity: .576">Beli semua kebutuhan Uang Elektronik, hanya di <?= $_CONFIG['title']; ?></div>
            </div>
            <div class="app-menu mt-0">
                    <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('BRI BRIZZI') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                    <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('MANDIRI E TOLL') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('TAPCASH BNI') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <a href="#" class="item"></a>
            </div>
        </div>
        <div class="section full bg-white pl-1 pr-1 pb-3 mb-1">
            <div class="p-2 pb-2">
                <div class="title">Dompet Digital</div>
                <div style="font-size: 12px; opacity: .576">Solusi semua pembayaran Elektronik, hanya di <?= $_CONFIG['title']; ?></div>
            </div>
            <div class="app-menu mt-0">
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('SHOPEE PAY') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('MITRA SHOPEE') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('GO PAY') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('GO PAY DRIVER') AND kategori = 'Driver' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                </div>
                <div class="app-menu mt-3">
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('GRAB') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('GRAB DRIVER') AND kategori = 'Driver' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('OVO') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('DANA') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
            </div>
            <div class="app-menu mt-3">
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('SAKUKU') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('LINKAJA') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('I.SAKU') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'e-money' AND brand IN ('MAXIM DRIVER') AND kategori = 'Driver' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/emoney/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/emoney-icon/'.$code.'.jpg').'?'.time() ?>" alt="<?= $code ?>" width="50px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                    <?php } ?>
            </div>
            <div class="app-menu mt-4">
                <a href="<?= base_url('order/paypal') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/img/home/paypal.png') ?>" alt="Paypal" width="50px">
                        <strong>PAYPAL</strong>
                    </div>
                </a>
                <a href="#" class="item"></a>
                <a href="#" class="item"></a>
                <a href="#" class="item"></a>
            </div>
        </div>
        -->
        <div class="section full bg-white pl-1 pr-1 pb-3 mb-1">
            <div class="p-2 pb-2">
                <div class="title">Tagihan</div>
            </div>
            <div class="app-menu mt-0">
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('PLN Pascabayar') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('PDAM') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('GAS Negara') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('PBB') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
            </div>
            <div class="app-menu mt-3">
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('BPJS Kesehatan') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('INTERNET PASCABAYAR') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('MULTIFINANCE') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
                <?php 
                    $search = $call->query("SELECT * FROM srv WHERE type = 'pascabayar' AND brand IN ('HP PASCABAYAR') AND kategori = 'Umum' GROUP BY brand ORDER BY name ASC");
                    if($search->num_rows == FALSE) { 
                        print '<div class="alert alert-danger text-left fade show mr-2 ml-2 mt-2" role="alert">Tidak Ada Layanan Yang Tersedia!</div>';
                    }
                    while($row = $search->fetch_assoc()) { 
                    $code = str_replace('.', '=', str_replace(' ', '-', strtolower($row['brand'])));
                    ?>
                <a href="<?= base_url('order/pascabayars/'.$code) ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('images/pascabayar/'.$code.'.png').'?'.time() ?>" alt="<?= $code ?>" width="55px" height="55px">
                        <strong><?= $row['brand'] ?></strong>
                    </div>
                </a>
                <?php } ?>
        </div>
        </div>
        
        <div class="section full bg-white pl-1 pr-1 pb-3 mb-1">
            <div class="p-2 pb-2">
                <div class="title">Voucher & Kartu Perdana</div>
            </div>
            <div class="app-menu"> 
                <a href="<?= base_url('order/games') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/voucher-game.png') ?>" width="55px" height="55px">
                        <strong>Voucher Games</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/voucher') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/voucher-digital.png') ?>" width="55px" height="55px">
                        <strong>Voucher Lainnya</strong>
                    </div>
                </a>
                <a href="<?= base_url('order/aktivasi-voucher') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/voucher-data.png') ?>" width="55px" height="55px">
                        <strong>Inject Voucher</strong>
                    </div>
                     </a>
                <a href="<?= base_url('order/aktivasi-perdana') ?>" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/act-perdana.png') ?>" width="55px" height="55px">
                        <strong>Aktivasi Perdana</strong>
                    </div>
                </a>
                <a href="#" class="item"></a>
            </div>
        </div> 
        <div class="section full bg-white pl-1 pr-1 pb-3 mb-1">
            <div class="p-2 pb-2">
                <div class="title">Produk Lainnya</div>
            </div>
            <div class="app-menu">
                <a href="#"  class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/voucher-tv.png') ?>" width="55px" height="55px">
                        <strong>Voucher Tv</strong>
                    </div>
                </a>
                 <a href="/donasi" class="item">
                    <div class="col">
                        <img src="<?= assets('mobile/icon/png/donasi.png') ?>" width="55px" height="55px">
                        <strong>Donasi</strong>
                    </div>
                </a>
                 <a href="#" onclick="toastbox('toastComingSoon', 2500)" class="item">
                    <div class="col">
                     <img src="<?= assets('mobile/icon/png/withdraw.png') ?>" width="55px" height="55px">
                        <strong>Tarik Tunai</strong>
                    </div>
                </a>   
                <a href="#" class="item"></a>
                <a href="#" class="item"></a>
            </div>
        </div>
        
        <div class="section full mb-1 bg-white mt-1 pt-1 pb-2" style="padding-left: 10px;padding-right: 10px;">
        <div class="d-flex justify-content-between align-items-center">
            <div class="section-title" style="padding:6px;">Informasi</div>
            <a href="<?= base_url('page/info') ?>" class="text-primary" style="font-weight:600;padding:6px;">Lihat Semua</a>
            <!-- <a href="<?= base_url('page/news') ?>" class="text-primary" style="font-weight:600;padding:6px;">Lihat Semua</a> -->
        <?php 
        $slider = $call->query("SELECT * FROM news_promo ORDER BY id ASC LIMIT 5");
        if($slider->num_rows !== 0):
        ?>
            <!--<div class="carousel-single owl-carousel owl-theme">-->
            <div class="carousel-full owl-carousel owl-theme">
                <?php while($slide = $slider->fetch_assoc()): ?>
                <div class="item" style="margin-left: 6px;margin-right: 6px;">
                    <img src="<?= assets('images/news/'.$slide['banner']) ?>" alt="Mauaja Image" class="imaged w-70">
                </div>
                <?php endwhile; ?>
            </div>
        <?php endif; ?>
        </div>
        <?php $rewards = $call->query("SELECT * FROM modules_point_rewards WHERE available = '1' ORDER by point ASC LIMIT 10"); ?>
        <?php if($rewards->num_rows > 0): ?>
        <div class="section full bg-white mt-1 pb-1">
            <div class="d-flex justify-content-between align-items-center pr-2">
            
                <a href="<?= base_url('premium/tukar-poin') ?>" class="text-primary" style="font-weight: 600;"> </a></a>
            </div>
            <div class="card mt-1 rewards-bg bg-primary">
                <div class="card-body p-2 pb-0">
                    <div class="card-title text-white" style="font-size: 14px; display: inline-flex;">
                        <div style="text-transform: uppercase;">Poin Anda</div>
                        <div class="ml-1" style="background: var(--color-theme-secondary); padding: 0px 7px; border-radius: 30px;">
                            <?= currency($data_user['point']) ?>
                        </div>
                    </div>
                    <div class="card-subtitle text-white" style="text-transform: none; line-height: 16px">
                        Tukarkan poin anda dengan Hadiah Menarik berikut.
                    </div>
                </div>
                <div class="infinite-menu p-2 pt-0 pl-0 ml-2 mt-1">
                    <?php while($data_rewards = $rewards->fetch_assoc()): ?>
                    <a href="<?= base_url('premium/tukar-poin') ?>" class="card reward-poin bg-transparent no-border m-0" style="color: #FFF !important">
                        <div class="card-body p-0" style="max-width: 100px">
                            <div>
                                <img src="<?= assets('images/rewards-icon/'.$data_rewards['photo']); ?>" alt="Rewards Icon" style="min-height: 70px; max-height: 70px; max-width: 100px; width: 100px; border-radius: 6px">
                            </div>
                            <div style="padding-top: 4px">
                                <div style="font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"><?= $data_rewards['name']; ?></div>
                                <div style="background: var(--color-theme-secondary); border-radius: 80px; margin-top: 4px; padding: 0px 7px; width: max-content; font-size: 12px;"><?= currency($data_rewards['point']); ?> Poin</div>
                            </div>
                        </div>
                    </a>
                    <?php endwhile; ?>
                </div>
            </div>
        </div>
        <?php endif; ?>
        
        <div class="section full rgs-info bg-white" style="padding-bottom: 80px; margin-top: 29px"></div>
            <!--
            <div class="section-title">Informasi Terbaru</div>
            <?php
            $search = $call->query("SELECT * FROM information ORDER BY id DESC LIMIT 5");
            if($search->num_rows == false) {
                print '<div class="alert alert-primary text-left fade show mt-2 mb-2 mr-2 ml-2" role="alert">Belum Ada Informasi Terbaru</div>';
            } else {
            while($row = $search->fetch_assoc()) {
            ?>
            <div class="card">
                <div class="card-body">
                    <ion-icon name="megaphone-outline" class="text-warning"></ion-icon>
                    <span class="title"><?= $row['title'] ?></span>
                    <span class="date"><?= format_date('en',$row['date']) ?></span>
                    <span class="content"><?= nl2br(substr($row['content'],0,+100).'.') ?> <a href="<?= base_url('page/news-detail/'.$row['id']) ?>">Selengkapnya.</a> </span>
                </div>
            </div>
            <? } ?>

            <div class="text-center">
                <a href="<?= base_url('page/info') ?>" class="btn btn-primary">Lihat Semua Informasi</a>
            </div>
            <? } ?>

        </div>
        -->

    </div>
    <div class="modal fade action-sheet inset" id="komisiModal" tabindex="-1" style="display: none;" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Total Komisi</h5>
                </div>
                <div class="modal-body">
                    <div style="padding: 1rem; text-align: center;">
                        <div class="alert alert-outline-primary" role="alert">
                            <div style="font-weight: 500; padding-bottom: 6px;">Komisi Anda</div>
                            <div style="font-size: 18px; font-weight: 600;">Rp <?= currency($data_user['komisi']) ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- * App Capsule -->

    <script>
        $(document).ready(function() {
            $('.urgent-alert').addClass('show');
        });
    </script>
<?php } } require _DIR_('library/footer/user') ?>