<?php
    $rank_check = mysqli_query($con,"select user_rank from users where user_id='$userid'");
    $myrank = mysqli_fetch_array($rank_check);
    $user_rank = $myrank['user_rank'];
?>
<!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="dashboard" class="brand-link">
      <img src="<?php include('extension/logo.php'); ?>" alt="Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
      <span class="brand-text font-weight-bold"><?php include('extension/title.php'); ?></span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
          <li class="nav-header mt-2">Main Navigation</li>
          <li class="nav-item">
            <a href="dashboard" class="nav-link <?php if($active=='dashboard'){ echo "active"; }else{}?>" <?php if($active=='dashboard'){ ?> style="background-color: <?php include('extension/theme.php'); ?>;" <?php } ?>>
              <i class="nav-icon fas fa-chart-pie"></i>
              <p>
                Dashboard
              </p>
            </a>
          </li>
          <li class="nav-item <?php if($active=='create_user' || $active=='view_user' || $active=='view_bulk' || $active=='download_bulk' || $active=='create_reseller' || $active=='view_reseller'){ echo "menu-open"; }else{}?>">
            <a href="#" class="nav-link <?php if($active=='create_user' || $active=='view_user' || $active=='view_bulk' || $active=='download_bulk' || $active=='create_reseller' || $active=='view_reseller'){ echo "active"; }else{}?>" <?php if($active=='create_user' || $active=='view_user' || $active=='view_bulk' || $active=='download_bulk' || $active=='create_reseller' || $active=='view_reseller'){ ?>style="background-color: <?php include('extension/theme.php'); ?>;" <?php } ?>>
              <i class="nav-icon fas fa-user"></i>
              <p>
                Client Tools
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item <?php if($active=='create_user' || $active=='view_user' || $active=='view_bulk' || $active=='download_bulk'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-user nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    Users
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="create_user" class="nav-link <?php if($active=='create_user'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Create User</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_user" class="nav-link <?php if($active=='view_user'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View Users</p>
                    </a>
                  </li>
                  <!--li class="nav-item">
                    <a href="view_bulk" class="nav-link <?php if($active=='view_bulk'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View Bulk</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="download_bulk" class="nav-link <?php if($active=='download_bulk'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Download Bulk</p>
                    </a>
                  </li-->
                </ul>
              </li>
              <li class="nav-item <?php if($active=='create_reseller' || $active=='view_reseller'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-user nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    Resellers
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="create_reseller" class="nav-link <?php if($active=='create_reseller'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Create Reseller</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_reseller" class="nav-link <?php if($active=='view_reseller'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View Resellers</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="transfer" class="nav-link <?php if($active=='transfer'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Transfer Credit</p>
                    </a>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
          <?php if($user_rank == 'superadmin'){ ?>
          <li class="nav-header mt-2">System Management</li>
          <li class="nav-item <?php if($active=='create_update' || $active=='view_update' || $active=='create_dns' || $active=='view_dns' || $active=='add_server' || $active=='view_server' || $active=='site_settings' || $active=='add_domain' || $active=='view_domain'){ echo "menu-open"; }else{}?>">
            <a href="#" class="nav-link <?php if($active=='create_update' || $active=='view_update' || $active=='create_dns' || $active=='view_dns' || $active=='add_server' || $active=='view_server' || $active=='site_settings' || $active=='add_domain' || $active=='view_domain'){ echo "active"; }else{}?>" <?php if($active=='create_update' || $active=='view_update' || $active=='create_dns' || $active=='view_dns' || $active=='add_server' || $active=='view_server' || $active=='site_settings' || $active=='add_domain' || $active=='view_domain'){?>style="background-color: <?php include('extension/theme.php'); ?>;" <?php } ?>>
              <i class="nav-icon fas fa-user"></i>
              <p>
                Panel Tools
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item <?php if($active=='create_update' || $active=='view_update'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-circle nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    Updater
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="create_update" class="nav-link <?php if($active=='create_update'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Create Update</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_update" class="nav-link <?php if($active=='view_update'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View Update</p>
                    </a>
                  </li>
                </ul>
              </li>
              <li class="nav-item <?php if($active=='create_dns' || $active=='view_dns'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-circle nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    DNS
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="create_dns" class="nav-link <?php if($active=='create_dns'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Create DNS</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_dns" class="nav-link <?php if($active=='view_dns'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View DNS</p>
                    </a>
                  </li>
                </ul>
              </li>
              <li class="nav-item <?php if($active=='add_server' || $active=='view_server'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-circle nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    Servers
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="add_server" class="nav-link <?php if($active=='add_server'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Add Server</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_server" class="nav-link <?php if($active=='view_server'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>View Server</p>
                    </a>
                  </li>
                </ul>
              </li>
              <li class="nav-item <?php if($active=='site_settings' || $active=='add_domain' || $active=='view_domain'){ echo "menu-open"; }else{}?>">
                <a href="#" class="nav-link">
                  <i class="far fa-circle nav-icon" style="color: <?php include('extension/theme.php'); ?>;"></i>
                  <p>
                    Settings
                    <i class="right fas fa-angle-left"></i>
                  </p>
                </a>
                <ul class="nav nav-treeview">
                  <li class="nav-item">
                    <a href="site_settings" class="nav-link <?php if($active=='site_settings'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Site Settings</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="add_domain" class="nav-link <?php if($active=='add_domain'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>Add DNS Domain</p>
                    </a>
                  </li>
                  <li class="nav-item">
                    <a href="view_domain" class="nav-link <?php if($active=='view_domain'){ echo "active"; }else{}?>">
                      <i class="fas fa-angle-right nav-icon"></i>
                      <p>DNS Domain List</p>
                    </a>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
          <?php } ?>
          <li class="nav-item">
            <a href="history" class="nav-link <?php if($active=='history'){ echo "active"; }else{}?>" <?php if($active=='history'){ ?> style="background-color: <?php include('extension/theme.php'); ?>;" <?php } ?>>
              <i class="nav-icon fas fa-history"></i>
              <p>
                History
              </p>
            </a>
          </li>

        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>