<?php 

$is_logged_in = $this->session->userdata('logged_in');
if(!isset($is_logged_in) || $is_logged_in!==TRUE)
{
    redirect(base_url());
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title><?= get_setting()['title'].' | '.$title; ?></title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link href="website_assets/img/logo.png" rel="icon">
  <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">

  <!-- Google Fonts -->
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="<?= base_url('assets/vendor/bootstrap/css/bootstrap.min.css'); ?>" rel="stylesheet">
  <link href="<?= base_url('assets/vendor/bootstrap-icons/bootstrap-icons.css'); ?>" rel="stylesheet">
  <link href="<?= base_url('assets/vendor/boxicons/css/boxicons.min.css'); ?>" rel="stylesheet">
  <link href="<?= base_url('assets/vendor/quill/quill.snow.css'); ?>" rel="stylesheet">
  <link href="<?= base_url('assets/vendor/quill/quill.bubble.css'); ?>" rel="stylesheet">
  <link href="<?= base_url('assets/vendor/remixicon/remixicon.css'); ?>" rel="stylesheet">
  <!--<link href="<?= base_url('assets/vendor/simple-datatables/style.css'); ?>" rel="stylesheet">-->
    <link rel="stylesheet" type="text/css" href="<?= base_url('vendor/datatables.css');?>">
    <link href="<?= base_url() ?>assets/plugins/jq-toast/jquery.toast.css" rel="stylesheet" />
  

  <!-- Template Main CSS File -->
  <link href="<?= base_url('assets/css/style.css'); ?>" rel="stylesheet">
  
  <link href="<?= base_url('assets/plugins/jq-toast/jquery.toast.css'); ?>" rel="stylesheet" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js"></script>  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/additional-methods.min.js"></script>

  <!-- ======= CK editor ======= -->
  <script src="https://cdn.ckeditor.com/4.20.2/standard/ckeditor.js"></script>

</head>

<body>

  <!-- ======= Header ======= -->
  <header id="header" class="header fixed-top d-flex align-items-center">

    <div class="d-flex align-items-center justify-content-between">
      <a href="<?= base_url('dashboard');?>" class="logo d-flex align-items-center">
        <img src="website_assets/img/logo.png" alt="">
        <span class="d-none d-lg-block"><?= get_setting()['title']; ?></span>
      </a>
      <i class="bi bi-list toggle-sidebar-btn"></i>
    </div><!-- End Logo -->
    <?php 
    if($this->session->userdata('usertype') == 'admin')
    {
      $user_detail = $this->model->getRowData('users',['id'=>$this->session->userdata('id')]);
      $user_name = $user_detail['firstname'];
      
    }
    else if($this->session->userdata('usertype') == 'staff')
    {
      $user_detail = $this->model->getRowData('staff',['id'=>$this->session->userdata('id')]);
      $user_name = $user_detail['fullname'];
    }
    else if($this->session->userdata('usertype') == 'turf_owner')
    {
      $user_detail = $this->model->getRowData('turf_owner',['id'=>$this->session->userdata('id')]);
      $user_name = $user_detail['fullname'];
    }
    ?>

    <nav class="header-nav ms-auto">
      <ul class="d-flex align-items-center">

        <li class="nav-item d-block d-lg-none">
          <a class="nav-link nav-icon search-bar-toggle " href="#">
            <i class="bi bi-search"></i>
          </a>
        </li><!-- End Search Icon-->

        <li class="nav-item dropdown pe-3">

          <a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
            <i class="bi bi-person"></i>
              <span>Profile</span>
          </a><!-- End Profile Iamge Icon -->

          <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile">
            <li class="dropdown-header">
              <h6><span><?= $user_name; ?></span></h6>
              <span><?= ucfirst($this->session->userdata('usertype')); ?></span>
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <li>
            <?php if($this->session->userdata('usertype') == 'admin'){ ?>
              <a class="dropdown-item d-flex align-items-center" href="<?= base_url('change-password'); ?>">
                <i class="bi bi-lock-fill"></i>
                <span>Change Password</span>
              </a>
              <?php } ?>
            </li>
              <hr class="dropdown-divider">
            </li>
            <li>
              <hr class="dropdown-divider">
            </li>
            <?php if($this->session->userdata('usertype') == 'admin'){
              $base_url = 'change-password';
            }else{
              $base_url = 'staff-change-password';
            }
              ?>
            <?php if($this->session->userdata('logged_in')){ ?>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="<?= base_url($base_url); ?>"><i class="bi bi-key"></i>
                <span>Change Password</span>
              </a>
            </li>
            <li>
              <a class="dropdown-item d-flex align-items-center" href="<?= base_url('logout'); ?>"><i class="bi bi-box-arrow-right"></i>
                <span>Logout</span>
              </a>
            </li>
            <?php } ?>

          </ul><!-- End Profile Dropdown Items -->
        </li><!-- End Profile Nav -->

      </ul>
    </nav><!-- End Icons Navigation -->

  </header><!-- End Header -->