<?php if (USER_ROLE == 0) : ?>
  <?php if (isset($page_title) && $page_title == "Dashboard") : ?>
    <?php $check = $this->admin_m->get_last_unseen_notification(restaurant()->id); ?>

    <?php if (isset($check['check']) && $check['check'] == 1) : ?>
      <div class="custom_notification">
        <div class="alert alert-danger alert-dismissible">
          <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
          <a href="<?= base_url("admin/notify/my_notifications"); ?>">
            <div class="customNotify">
              <strong><i class="fa fa-bell"></i></strong>
              <div class="notifyBody">
                <h4><?= $check['result']->title; ?></h4>
                <p><?= full_date($check['result']->send_at); ?></p>
              </div>
            </div>
          </a>
        </div>
      </div>
    <?php endif; ?>
  <?php endif; ?>
<?php endif; ?>


<?php $setting = settings(); ?>
<?php $auth_info = get_user_info(); ?>
<header class="main-header">
  <!-- Logo -->
  <?php if (auth('user_role') == 1) : ?>
    <a href="<?php echo base_url() ?>" class="logo shopLogo">
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg">
        <?php if (!empty($setting['favicon'])) : ?>
          <img src="<?= __image($setting['favicon']); ?>" alt="">
        <?php endif; ?>
      </span>
    </a>
  <?php else : ?>
    <a href="<?= isset($page) && $page == "POS" ? base_url('dashboard') : base_url('dashboard'); ?>" class="logo shopLogo">
      <!-- logo for regular state and mobile devices -->
      <?php $getLogo = getLogo(auth('id')); ?>
      <span class="logo-lg">
        <?php if (!empty($getLogo['logo_light']) || !empty($getLogo['logo_dark'])) : ?>

          <img src="<?= __image($getLogo['logo_light']); ?>" alt="" class="admin_light_logo">

          <img src="<?= __image($getLogo['logo_dark']); ?>" alt="" class="admin_dark_logo">

        <?php else : ?>
          <img src="<?= __image(); ?>" alt="lo">
        <?php endif; ?>
      </span>
    </a>
  <?php endif; ?>
  <!-- Header Navbar: style can be found in header.less -->
  <nav class="navbar navbar-static-top">
    <div class="rightMenuBar">
      <!-- Sidebar toggle button-->
      <?php if (isset($page) && $page == "POS") : ?>
        <a href="<?= base_url("dashboard"); ?>" class="sidebar-toggle">
          <span class="sr-only">Toggle navigation</span>
        </a>
      <?php else : ?>
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
          <span class="sr-only">Toggle navigation</span>
        </a>
      <?php endif; ?>

      <?php if (auth('user_role') == 0) : ?>
        <a href="<?= url(html_escape($this->my_info['username'])); ?>" class="navLink" target='blank'>
          <i class="fa fa-eye"></i> <span class="hidden-xs"><?= !empty(lang('view_shop')) ? lang('view_shop') : "View Shop"; ?></span>
        </a>
      <?php endif; ?>
    </div>
    <div class="navbar-custom-menu">
      <ul class="nav navbar-nav">

        <?php if (auth('user_role') == 0) : ?>
          <!-- user role -->
          <li class="themeToggle adminThemeToggle"><?php $this->load->view("common_layouts/themeToggle.php", ['role' => 'user']) ?></li>
        <?php endif; ?>

        <?php if (auth('is_staff') == true) : ?>
          <li class="bg-success-soft">
            <a class="bg-success-soft"><i class="icofont-users-social fz-19"></i> &nbsp;<?= !empty(lang('staff')) ? lang('staff') : "Staff "; ?></a>
          </li>
        <?php endif; ?>
        <?php if (auth('user_role') == 0) : ?>
          <?php $glang = glang(auth('id')); ?>

          <?php if (isset($glang['is_glang']) && $glang['is_glang'] == 1) : ?>
            <li class="gLanguage p-r">
              <div class="gtranslate_wrapper gtranslator"></div>
            </li>
          <?php else : ?>
            <?php $shop_languages = shop_languages(auth('id')); ?>
            <?php if (count($shop_languages) > 1) : ?>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                  <i class="icofont-globe"></i>
                  <span class="hidden-xs"><?= lang_slug(!empty(site_lang()) ? site_lang() : $settings['language']); ?></span> &nbsp;<span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <?php foreach ($shop_languages as $key => $language) : ?>
                    <li>
                      <a class="dropdown-item" href="<?= base_url('home/lang_switch/' . $language->slug . '/auth'); ?>"> <?= $language->lang_name; ?></a>
                    </li>
                  <?php endforeach ?>

                </ul>
              </li>
            <?php endif; ?>
          <?php endif; ?>

        <?php else : ?> <!-- user_role -->
          <!-- Admin -->

          <?php if (auth('user_role') == 1) : ?>
            <li class="themeToggle adminThemeToggle"><?php $this->load->view("common_layouts/themeToggle.php", ['role' => 'admin']) ?></li>
          <?php endif; ?>
          <?php if (isset($settings['language_type']) && $settings['language_type'] == 'google') : ?>
            <li class="gLanguage p-r">
              <div class="admin_gtranslate_wrapper gtranslator"></div>
            </li>
          <?php else : ?>
            <?php $languages = $this->common_m->select_with_status('languages'); ?>
            <?php if (count($languages) > 1) : ?>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                  <i class="icofont-globe"></i>
                  <span class="hidden-xs"><?= lang_slug(!empty(site_lang()) ? site_lang() : $settings['language']); ?></span> &nbsp;<span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <?php foreach ($languages as $key => $language) : ?>
                    <li>
                      <a class="dropdown-item" href="<?= base_url('home/lang_switch/' . $language['slug'] . '/auth'); ?>"><?= $language['lang_name']; ?> </a>
                    </li>
                  <?php endforeach ?>
                </ul>
              </li>
            <?php endif; ?>
          <?php endif; ?>

        <?php endif ?><!-- user_role -->

        <?php if (USER_ROLE == 0 &&  can(['order-control', 'live_order'], ['access'])) : ?>
          <?php $pages = ['Dashboard', 'Auth Profile', 'Settings'] ?>
          <?php if (isset($page_title) && in_array($page_title, $pages) == 1) : ?>
            <?php $total_notify = $this->admin_m->get_last_total_unseen_notification(restaurant()->id); ?>
            <li class="p-r">
              <a href="<?= base_url("admin/notify/my_notifications"); ?>" class="fz-18"><i class="icofont-bell-alt"></i>
                <?php if ($total_notify > 0) : ?>
                  <span class="notifyBadge"><?= $total_notify; ?></span>
                <?php endif ?>
              </a>
              <!-- notification -->
            </li>
          <?php endif; ?>
        <?php endif; ?>


        <?php if (auth('user_role') == 0 && can(['pos', 'pos-order'], ['access']) && can('pos', ['feature', 'active'], true)) : ?>
          <?php if (file_exists(APPPATH . 'controllers/admin/Pos.php')) : ?>
            <li class="p-r table-ajax-notification">
              <?php include "ajax_table_notification.php"; ?>
              <!-- notification -->
            </li>
          <?php endif; ?>
        <?php endif; ?>






        <?php if (auth('user_role') == 0 && can(['order-control', 'live_order'], ['access'])) : ?>
          <!-- Notifications: style can be found in dropdown.less -->
          <li class="dropdown notifications-menu ajax-notification">
            <?php include "ajax_notification.php"; ?>
            <!-- notification -->
          </li>
        <?php endif; ?>

        <?php
        $uname = auth('user_staff') == true ? auth('name') : (isset($auth_info['name']) && !empty($auth_info['name']) ? $auth_info['name'] : $auth_info['username']);

        $pImage = auth('thumb') == true ? auth('thumb') : (isset($auth_info['thumb']) && !empty($auth_info['thumb']) ? $auth_info['thumb'] : '');

        ?>



        <!-- User Account: style can be found in dropdown.less -->
        <li class="dropdown user user-menu">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            <img src="<?= avatar(!empty($auth_info['thumb']) ? $auth_info['thumb'] : '', 'profile') ?>" class="user-image uploaded_img" alt="User Image">
            <span class="hidden-xs">
              <?= $uname; ?>

            </span>
          </a>
          <ul class="dropdown-menu">
            <!-- User image -->
            <li class="user-header">
              <img src="<?= avatar($pImage ?? '', 'profile') ?>" class="img-circle uploaded_img" alt="User Image">

              <p>
                <?= $uname; ?>

                <?php if (!auth('user_stafff')): ?>
                  <?php if (!empty($auth_info['designation'])) { ?>
                    <span><?= "- " . $auth_info['designation']; ?></span>
                  <?php } ?>
                  <small><?= lang('member_since'); ?> - <?= cl_format($auth_info['created_at']); ?></small>
                <?php endif; ?>
                <!-- <small id="time"></small> -->
              </p>
            </li>
            <div class="text-center">
              <small><?= lang('last_login'); ?> - <?= cl_format($auth_info['last_login']); ?></small>
            </div>
            <!-- Menu Body -->

            <!-- Menu Footer-->
            <li class="user-footer">
              <div class="pull-left">
                <?php if (auth('user_staff') == true) : ?>
                  <a href="<?= base_url('admin/restaurant/staff_profile') ?>" class="btn btn-default btn-flat"><?= !empty(lang('profile')) ? lang('profile') : "Profile"; ?></a>
                <?php elseif (auth('admin_staff') == true) : ?>
                  <a href="<?= base_url('admin/adminstaff/staff_profile') ?>" class="btn btn-default btn-flat"><?= !empty(lang('profile')) ? lang('profile') : "Profile"; ?></a>
                <?php else : ?>
                  <a href="<?= base_url('admin/auth/') ?>" class="btn btn-default btn-flat"><?= !empty(lang('profile')) ? lang('profile') : "Profile"; ?></a>
                <?php endif; ?>
              </div>
              <div class="pull-right">
                <a href="<?= base_url('logout') ?>" class="btn btn-default btn-flat"><?= !empty(lang('logout')) ? lang('logout') : "Logout"; ?></a>
              </div>
            </li>
          </ul>
        </li>
        <!-- Control Sidebar Toggle Button -->

      </ul>
    </div>
  </nav>
</header>


<?php if (LICENSE != MY_LICENSE) : ?>
  <script>
    $(document).ready(function() {
      $(".card.stripe_fpx, .mercado, .flutterwave, .paystack, .paytm, .cDomain").html('')
    })
  </script>
<?php endif ?>