<?php 
if (basename($_SERVER['PHP_SELF'])==basename(__FILE__)) {
  exit(); 
}
$queryowner=$db->prepare("SELECT * FROM owner where username=:username");
$queryowner->execute(array(
  'username' => $_SESSION['username']
));
$say=$queryowner->rowCount();
$rowowner=$queryowner->fetch(PDO::FETCH_ASSOC);
if ($say==0) {
  header('Location:' . admin_url('giris'));
  exit;
} ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Radyo Yönetim Paneli</title>
  <meta name="author" content="Harun EFE">
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <!-- Font Awesome -->
  <link rel="stylesheet" href="<?= admin_public_url(); ?>plugins/fontawesome-free/css/all.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="<?= admin_public_url(); ?>dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">

</head>
<body class="hold-transition sidebar-mini">
  <!-- Site wrapper -->
  <div class="wrapper">
    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">
      <!-- Left navbar links -->
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
        </li>
        <li class="nav-item d-none d-sm-inline-block">
          <a href="../" target="_blank" class="nav-link"><i class="fas fa-desktop"></i> Site</a>
        </li>
        <li class="nav-item d-none d-sm-inline-block">
          <a href="<?= admin_url(); ?>hesabim" class="nav-link"><i class="fas fa-user"></i> Hesabım</a>
        </li>
      </ul>  
    </nav>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
      <!-- Brand Logo -->
      <a href="index" class="brand-link">
        <img src="<?= admin_public_url(); ?>dist/img/AdminLTELogo.png"
        alt="Logo"
        class="brand-image img-circle elevation-3"
        style="opacity: .8">
        <span class="brand-text font-weight-light">YÖNETİM PANELİ</span>
      </a>

      <!-- Sidebar -->
      <div class="sidebar">
        <!-- Sidebar user (optional) -->
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
          <div class="image">
            <img src="<?= admin_public_url(); ?>dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
          </div>
          <div class="info">
            <a href="hesabim" class="d-block"><?= $rowowner['name']. " ". $rowowner['surname']; ?></a>
          </div>
        </div>

        <!-- Sidebar Menu -->
        <nav class="mt-2">

          <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
            <?php foreach ($menus as $mainUrl => $menu) { ?>
              <li class="nav-item has-treeview <?php if ($menu['url']==route(1) || isset($menu['menu']) && array_search(route(1), array_column($menu['menu'], 'url')) !== false) {echo "active";} ?>">

                <a href="<?= admin_url()."".$menu['url'] ?>" class="nav-link <?php if ($menu['url']==route(1) || isset($menu['menu']) && array_search(route(1), array_column($menu['menu'], 'url')) !== false) {echo "active";} ?>">
                  <i class="<?= $menu['icon'] ?>"></i>
                  <p><?= $menu['title'] ?></p>
                  <p>
                    <?php if (isset($menu['menu'])) { ?>
                      <i class="fas fa-angle-left right"></i> 
                    <?php } ?>
                  </p>
                   <?php if (isset($menu['right'])) { ?> 
                    <small class="right badge badge-<?= $menu['bck'] ?>"><?= $menu['right'] ?></small>
                
                <?php } ?>
                </a>



                <?php if (isset($menu['menu'])) { ?>
                  <ul class="nav nav-treeview">
                   <?php foreach ($menu['menu'] as $k => $menu) { ?>
                    <li class="nav-item <?php if ($menu['url']==route(1)) {echo "active";} ?>">
                      <a href="<?= admin_url()."".$menu['url'] ?>" class="nav-link <?php if ($menu['url']==route(1)) {echo "active";} ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p><?= $menu['title'] ?></p>
                      </a>
                    </li> 
                  <?php } ?>  
                </ul>
              <?php } ?>
            </li>
          <?php } ?>
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>