<?php
require_once "../koneksi/koneksi.php";
require_once "koneksi.php";
?>
<?php
// Ambil data situs dari tabel atur_web dengan ID 1
$qry_atur = mysqli_query($koneksi, "SELECT id, nama_pasaran, title, meta_desc, logo, favicon, custom_script FROM atur_web WHERE id = '1'");

// Periksa apakah data ditemukan
if ($qry_atur && mysqli_num_rows($qry_atur) > 0) {
  $data_situs = mysqli_fetch_assoc($qry_atur);

  $id = $data_situs["id"];
  $nama_pasaran = $data_situs["nama_pasaran"];
  $title = $data_situs["title"];
  $meta_desc = $data_situs["meta_desc"];
  $logo = $data_situs["logo"];
  $favicon = $data_situs["favicon"];
  $custom_script = $data_situs["custom_script"];
} else {
  // Handle jika data tidak ditemukan
  $id = 1;
  $nama_pasaran = $title = $meta_desc = $logo = $favicon = $custom_script = "";
}
?>

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Admin - <?php echo $nama_pasaran; ?></title>
  <link rel="shortcut icon" href="../<?php echo $favicon; ?>">

  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="assets/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="assets/bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="assets/dist/css/AdminLTE.min.css">
  <link rel="shortcut icon" href="../<?php echo $favicon; ?>">

  <link rel="stylesheet" href="assets/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">

  <link rel="stylesheet" href="assets/dist/css/skins/_all-skins.min.css">
  <link rel="stylesheet" href="assets/bower_components/morris.js/morris.css">
  <link rel="stylesheet" href="assets/bower_components/jvectormap/jquery-jvectormap.css">
  <link rel="stylesheet" href="assets/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
  <link rel="stylesheet" href="assets/bower_components/bootstrap-daterangepicker/daterangepicker.css">
  <link rel="stylesheet" href="assets/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
  <link rel="stylesheet"
    href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

  <?php
  include "../koneksi.php";
  session_start();
  if ($_SESSION["status"] != "administrator_logedin") {
    header("location:masuk.php?alert=belum_login");
  }
  ?>

</head>

<body class="hold-transition skin-blue sidebar-mini">

  <style>
    #table-datatable {
      width: 100% !important;
    }

    #table-datatable .sorting_disabled {
      border: 1px solid #f4f4f4;
    }
  </style>
  <div class="wrapper">

    <header class="main-header">
      <a href="index.php" class="logo">
        <span class="logo-mini"><b><i class="fa fa-money"></i></b> </span>
        <span class="logo-lg"><b><?php echo $nama_pasaran; ?></b>App</span>
      </a>
      <nav class="navbar navbar-static-top">
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
          <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">
          <ul class="nav navbar-nav">

            <li class="dropdown user user-menu">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                <?php
                $id_user = $_SESSION["id"];
                $profil = mysqli_query(
                  $koneksi,
                  "select * from user where user_id='$id_user'"
                );
                $profil = mysqli_fetch_assoc($profil);
                if ($profil["user_foto"] == "") { ?>
                  <img src="gacordev.png" class="user-image">
                <?php } else { ?>
                  <img src="gacordev.png" class="user-image">
                <?php }
                ?>
                <span class="hidden-xs"><?php echo $_SESSION[
                  "nama"
                ]; ?> - <?php echo $_SESSION["level"]; ?></span>
              </a>
            </li>
            <li>
              <a href="logout.php"><i class="fa fa-sign-out"></i> LOGOUT</a>
            </li>
          </ul>
        </div>
      </nav>
    </header>

    <aside class="main-sidebar">
      <section class="sidebar">
        <div class="user-panel">
          <div class="pull-left image">
            <?php
            $id_user = $_SESSION["id"];
            $profil = mysqli_query(
              $koneksi,
              "select * from user where user_id='$id_user'"
            );
            $profil = mysqli_fetch_assoc($profil);
            if ($profil["user_foto"] == "") { ?>
              <img src="gacordev.png" class="img-circle">
            <?php } else { ?>
              <img src="gacordev.png" class="img-circle" style="max-height:45px">
            <?php }
            ?>
          </div>
          <div class="pull-left info">
            <p><?php echo $_SESSION["nama"]; ?></p>
            <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
          </div>
        </div>

        <ul class="sidebar-menu" data-widget="tree">
          <li class="header">MAIN NAVIGATION</li>

          <li>
            <a href="index.php">
              <i class="fa fa-dashboard"></i> <span>DASHBOARD</span>
            </a>
          </li>

          <li>
            <a href="result.php">
              <i class="fa fa-bomb"></i> <span>RESULT</span>
            </a>
          </li>


          <li>
            <a href="situs.php">
              <i class="fa fa-bell"></i> <span>ATUR JAM KELUARAN</span>
            </a>
          </li>

          <li>
            <a href="atur.php">
              <i class="fa fa-gear"></i> <span>ATUR SITUS</span>
            </a>
          </li>

          <li>
            <a href="gantipassword.php">
              <i class="fa fa-lock"></i> <span>GANTI PASSWORD</span>
            </a>
          </li>

          <li>
            <a href="logout.php">
              <i class="fa fa-sign-out"></i> <span>LOGOUT</span>
            </a>
          </li>

        </ul>
      </section>
      <!-- /.sidebar -->
    </aside>