<!-- Main Sidebar Container -->
<aside class="main-sidebar elevation-4 sidebar-light-teal">
<!-- Brand Logo -->
    <a href="index3.html" class="brand-link">
        <img src="<?php echo base_url();?>theme/AdminLTE3/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8"/>
        <span class="brand-text font-weight-light">SatuRSSA</span>
    </a>
    <div class="sidebar">
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <div class="image">
                <img src="<?php echo base_url();?>theme/AdminLTE3/dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image"/>
            </div>
            <div class="info">
                <a href="#" class="d-block"><?php echo $this->session->userdata('s_UserName');?></a>
            </div>
        </div>
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column nav-compact" data-widget="treeview" role="menu" data-accordion="false">
                <?php
                    $linknow=$this->uri->segment(1, 0);
                    //--------------start lp_ppi 1 controller--------------//
                    if($linknow=="lp_ppi"){
                        $linknow=$this->uri->segment(1, 0)."/".$this->uri->segment(2, 0);
                        $linksearch = substr($this->uri->segment(2, 0), 0, 6);
                        // if($linksearch=="search"){
                        //     $linknow=$this->uri->segment(1, 0)."/".substr($this->uri->segment(2, 0), 6);
                        // }
                    }elseif($linknow=="lp_simrs_kemenkes"){
                        $linknow=$this->uri->segment(1, 0)."/".$this->uri->segment(2, 0);
                        $linksearch = substr($this->uri->segment(2, 0), 0, 6);
                        // if($linksearch=="search"){
                        //     $linknow=$this->uri->segment(1, 0)."/".substr($this->uri->segment(2, 0), 6);
                        // }
                    }elseif($linknow=="lp_simrs_report"){
                        $linknow=$this->uri->segment(1, 0)."/".$this->uri->segment(2, 0);
                        $linksearch = substr($this->uri->segment(2, 0), 0, 6);
                        // if($linksearch=="search"){
                        //     $linknow=$this->uri->segment(1, 0)."/".substr($this->uri->segment(2, 0), 6);
                        // }
                    }elseif($linknow=="lp_data_master"){
                        $linknow=$this->uri->segment(1, 0)."/".$this->uri->segment(2, 0);
                        $linksearch = substr($this->uri->segment(2, 0), 0, 6);
                    }
                    //--------------end lp_ppi 1 controller--------------//
                    $this->db->join('master_menu', 'mm_id = am_fk_menu_id', 'LEFT');
            		$this->db->where('mm_status', 1);
                    $this->db->where('am_fk_rolegroup_id', $this->session->userdata('s_IDRoleGroup'));
            		$query = $this->db->get('access_menu');
                    
                    foreach ($query->result() as $parent){
                        if($parent->mm_level==1){
                            $aktif= "";
                            $open = "";
                            foreach ($query->result() as $aktifcek){
                                if($aktifcek->mm_link===$linknow && $parent->mm_id==$aktifcek->mm_parent){
                                    $aktif= "active";
                                    $open = "menu-open";
                                }
                            }
                    ?>
                        <li class="nav-item <?php echo $open;?>">
                            <a href="<?php echo base_url()."index.php/".$parent->mm_link;?>" class="nav-link <?php if($parent->mm_link === $linknow){echo "active";} echo $aktif; if(0===$linknow && $parent->mm_name == "Dashboard"){echo "active";}?>">
                                <i class="<?php echo $parent->mm_icon;?>"> </i>
                                <p>&nbsp;&nbsp;<?php echo $parent->mm_name; if($parent->mm_link=="#"){?> <i class="right fas fa-angle-left"></i> <?php } ?>&nbsp;</p>
                            </a>
                            <?php
                            if($parent->mm_link=="#"){
                                foreach ($query->result() as $menuchild){
                                    if($parent->mm_id==$menuchild->mm_parent){
                                    ?>
                                        <ul class="nav nav-treeview">
                                            <li class="nav-item ">
                                                <a href="<?php echo base_url()."index.php/".$menuchild->mm_link;?>" class="nav-link <?php if($menuchild->mm_link === $linknow){echo "active";}?>">
                                                    <i class="fa fa-caret-right nav-icon"></i>
                                                    <p> <?php echo $menuchild->mm_name;?></p>
                                                </a>
                                            </li>
                                        </ul>
                                    <?php     
                                    }
                                }   
                            } ?>                        
                        </li>
                    <?php
                        }
                    }
                ?>
            </ul>
        </nav>
    </div>
</aside>