<!DOCTYPE html>
<?php

$query = $db->prepare("SELECT * FROM `tickets` WHERE user_id = ? ORDER BY ticket_id DESC");

$query->execute([session("user_id")]);

$tickets = $query->fetchAll(PDO::FETCH_ASSOC);
$duyurular = $db->from('duyuru')->orderby('id', 'DESC')->all();
foreach ($tickets as $ticket) {
    if ($ticket['client_read'] == 0 && $ticket['client_read'] != null) {
        $unread++;
    }
}
$date = time();
$query = $db->prepare("UPDATE `users` SET last_date = $date WHERE user_id = ?");
$query->execute([session("user_id")]);

/**require view('./1-tema-ayarlari');*/

?>
<!------------------------------------------------------------------------------------------------------------------------------->
<!DOCTYPE html>
<html lang="tr">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php if (@$meta) : ?>
        <title><?php if ($meta['title']) : ?><?= $meta['title'] ?><?php else : ?>{PAGE_TITLE} | {SITE_TITLE}<?php endif; ?></title>
        <meta name="description" content="<?php if ($meta['desc']) : ?><?= $meta['desc'] ?><?php else : ?>{SITE_DESC}<?php endif; ?>" />
        <meta name="keywords" content="<?php if ($meta['keyw']) : ?><?= $meta['keyw'] ?><?php else : ?>{SITE_KEYW}<?php endif; ?>" />
    <?php else : ?>
        <title>{PAGE_TITLE} | {SITE_TITLE}</title>
        <meta name="description" content="{SITE_DESC}" />
        <meta name="keywords" content="{SITE_KEYW}" />
    <?php endif; ?>

    <link rel="shortcut icon" type="image/ico" href="{SITE_FAVO}" />
   

    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/assets/knd/knd.controller.css"); ?>">
    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/css/018og2hqyh2tbzou.css"); ?>">
    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/css/x5oecbn4yp7q0uee.css"); ?>">
    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/css/bootstrap-datetimepicker.min.css"); ?>">
    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/css/font-awesome/css/all.min.css"); ?>">
    <link rel="stylesheet" type="text/css" href="<?= theme("assets/smmspot/css/smmspot.css"); ?>"></code>
    <link href="https://fonts.googleapis.com/css?family=Overpass+Mono:400,700" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    
   
    
     <script type="text/javascript" async="" src="https://www.gstatic.com/recaptcha/releases/UrRmT3mBwY326qQxUfVlHu1P/recaptcha__tr.js" crossorigin="anonymous" integrity="sha384-HA9z2v/0dMMqJDXItzwvu8utzPHPoW7PCuxrNC6Qi8Y72lDTtG600TlxIZ+SS6Wl"></script>
    <script src="https://www.google.com/recaptcha/api.js" async="" defer=""></script>
    
    
    
    <link rel="stylesheet" href="<?= public_url("system/css/alertify.css"); ?>">
</head>

<body>

    <!------------------------------------------------------------------------------------------------------------------------------->

    <?php if (!session('user_id')) : ?>


        <header id="smmspot-na-header" class="sticky-header">
            <div class="container">
                <div class="row align-items-center">
                    <div class="col-auto">
                        <a href="/">
                            <img src="{SITE_LOGO}" alt="{SITE_TITLE}" width="190" title="{SITE_TITLE}">
                        </a>
                    </div>
                    <div class="col-auto ms-auto justify-self-end col-menu">
                        <ul class="header-menu">

                            <?php foreach ($mainmenus as $row) : if ($row['menu_type'] == 2) : ?>

                                    <li>
                                        <a class="menu-link" href="<?= isset($siteLinks[$row['menu_link']]['url']) ? $siteLinks[$row['menu_link']]['url'] : $row['menu_link'] ?>"><?= $row['menu_title'] ?></a>
                                    </li>
                            <?php endif;
                            endforeach; ?>

                            <li class="ms-0 ms-lg-5">
                                <a href="#" data-bs-toggle="modal" data-bs-target="#login" class="menu-link">
                                    <div class="mb-text">Giriş Yap</div>
                                </a>
                            </li>

                            <li class="menu-item-btn">
                                <a href="/register" class="btn btn-primary btn-border">
                                    <div class="mb-text">Kayıt Ol</div>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div class="col-auto justify-self-end ms-auto col-menu-btn">
                        <button class="btn ahbtn bs-1 my-4 noAuthMenuBtn">
                            <i class="fas fa-bars"></i>
                        </button>
                    </div>
                </div>
            </div>
        </header><!-- smmspot-header -->

    <?php endif; ?>

    <?php if (session('user_id')) : ?>
        <div class="app">
            <div class="app-header">
                <div class="app-header-container">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-auto">
                                <button class="btn ahbtn bs-1" onclick="sidebarToggle()">
                                    <i class="fas fa-bars"></i>
                                </button>
                            </div>
                            <div class="col">
                                <div class="d-head">
                                    <div class="container-fluid" id="ptcReal">
                                        <div id="ptc" class="page-title-content">
                                            <h2 class="pg-titlte">{SITE_TITLE}'ye hoşgeldin, <span class="p-color">{USER_USERNAME}</span>!</h2>
                                            <div class="pg-text">Sana en iyi hizmeti vermek için buradayız.</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-auto">
                                <?php
                                if ($user['user_authority'] == 2) {
                                    echo '
                            <a href="/admin" class="btn ahbtn bs-2">
                                <i class="fas fa-crown"></i>';
                                }

                                ?>
                                </a>
                            </div>
                            <div class="col-auto">
                                <a href="/account" class="btn ahbtn bs-2">
                                    <i class="fas fa-user-circle"></i>
                                </a>
                            </div>
                            <div class="col-auto">
                                <button class="btn ahbtn bs-2" onclick="rightMenuToggle()">
                                    <i class="far fa-bell"></i>
                                </button>
                            </div>
                            <div class="col-auto">
                                <a href="/logout" class="btn ahbtn bs-3">
                                    <i class="fas fa-power-off"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                </div><!-- ./app-header-container -->
            </div><!-- ./app-header -->
            <div class="app-sidebar">
                <div class="sidebar-header">
                    <a class="sidebar-logo-cont" href="/">
                        <img src="{SITE_LOGO}" class="sidebar-big-logo" width="190" alt="{SITE_TITLE}" title="{SITE_TITLE}">
                    </a>
                </div>
                <div class="sidebar-content">
                    <div class="sidebar-body">
                        <button class="btn ahbtn bs-1 mb-4 btn-block btn-sb-close" onclick="javascript:sidebarToggle();">
                            <i class="fas fa-times"></i>
                        </button>
                        <ul class="sidebar-menu">

                            <?php foreach ($mainmenus as $row) : if ($row['menu_type'] == 1) : ?>
                                    <li class="menu-link">
                                        <a href="/<?= isset($siteLinks[$row['menu_link']]['url']) ? $siteLinks[$row['menu_link']]['url'] : $row['menu_link'] ?>" class="menu-link">
                                            <div class="menu-icon">
                                                <i class="<?= $row['menu_icon'] ?>"></i>
                                            </div>
                                            <span><?= $row['menu_title'] ?></span>
                                        </a>
                                    </li>
                            <?php endif;
                            endforeach; ?>
                        </ul>
                    </div>
                </div>
            </div>
        <?php endif; ?>