<?php
$session = \Config\Services::session();
$user_data = $session->get('user_data');
$realname = $user_data['realname'];
$nip = $user_data['nip'];
if($nip == '0') $nip = '';
if($user_data['role'] == 'admin') $realname = esc('Administrator');
?>

        <section class="sidebar">
          <!-- Sidebar user panel -->
          <div class="user-panel">
            <div class="pull-left image">
              <img src="<?php echo base_url(); ?>/assets/admin/dist/img/users.gif" class="img-circle" alt="User Image">
            </div>
            <div class="pull-left info" style="color:#000;">
              <p><?php echo strtoupper($realname); ?></p>
              <p><?php echo $nip; ?></p>
              <p><?php echo $user_data['role']; ?></p>

            </div>
          </div>

          <!-- sidebar menu: : style can be found in sidebar.less -->
          <ul class="sidebar-menu">
            <li class="header" style='text-transform:uppercase; border-bottom:0px solid #d39e23;border-top:3px solid #d39e23;background-color:#888;color:#fff'><center><b>MENU PEDA MATENG</b><br/>
          <?php echo hari_ini() . ", " . tgl_indoo(date('Y-m-d')); ?></center>

          
          </li>
            <!--
            <li><a href="<?php
//echo base_url();
?>
            -->
            <?php
            $menumodel = model('App\Models\MenuModel');
            $session = \Config\Services::session();
            $user_data = $session->get('user_data');
            $role = $user_data['role'];
            if (
                in_array($role, [
                    'admin',
                    'verifikator',
                    'pimpinan',
                  	'dishub'
                ])
            ) {
                if ($role == 'admin') {
                    $main = $menumodel->mainmenu_admin();
                } elseif ($role == 'verifikator') {
                    $main = $menumodel->mainmenu_verifikator();
                } elseif ($role == 'pimpinan') {
                    $main = $menumodel->mainmenu_pimpinan();
                } elseif ($role == 'dishub') {
                    $main = $menumodel->mainmenu_dishub();
            }

                foreach ($main->getResultArray() as $row) {
                    if (
                        $menumodel->submenu_admin($row['id_main'])->getNumRows() == 0
                    ) {
                        echo "<li><a href='" .
                            base_url() .
                            "$row[link]'><i class='fa fa-folder'></i> <span>$row[nama_menu]</span></a></li>";
                    } else {
                        echo "<li class='treeview'>
                                <a href='" .
                            base_url() .
                            "$row[link]'><i class='fa fa-folder'></i> <span>$row[nama_menu]</span><i class='fa fa-angle-left pull-right'></i></a>
                                <ul class='treeview-menu'>";
                        $sub = $menumodel->submenu_admin($row['id_main']);
                        foreach ($sub->getResultArray() as $rows) {
                                echo "<li><a href='" .base_url() ."$rows[link_sub]'><i class='fa fa-circle'></i> $rows[nama_sub]</a></li>";
                        }
                        echo "</ul>
                              </li>";
                    }
                }
            }

?>

<style>
  .fa-folder {
    color:#ddd;
  }

 .fa-circle {
   color:#FFF3E0;
   opacity:0.5;
 } 
  </style>