<?php 
$dashboardMenu = $this->ApiMenu()->getApiDocumentLink($user_type_id);
$ApiMenu=$this->mainMenu()->getMenu('Api Menu');
$api_cms_pages = $ApiMenu['responsedata'];
?>

<aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 203px;">

        <section class="sidebar">
            <!-- Sidebar user panel -->

            <!-- /.search form -->
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu">

                  <li>

                    <a href="<?php echo $this->url('api'); ?>">
                        <i class="fa fa-circle"></i> <span>Home</span>
                          <?php if(!empty($menu['submenu'])){ ?>
                         <i class="fa fa-angle-left pull-right"></i>
                          <?php } ?>

                    </a>
                  </li>   
                  
                    <li>
                    <a href="<?php echo $this->url('api'); ?>">
                        <i class="fa fa-circle"></i> <span>Term & Condition</span>                         
                         <i class="fa fa-angle-left pull-right"></i>
                    </a>
                       
                        <ul class="treeview-menu">
                            <?php if(count($api_cms_pages)>0){ 
                                foreach($api_cms_pages as $value){
                            
                            ?>
                            <li>
                                 <i class="fa fa-angle-left pull-right"></i>
                                
                                 <a href="<?php echo $this->url('api', array('action' => 'api-document'),array('query'=>array('id'=>$value['menu_id']))); ?>"><?php echo $value['menu_name'];?></a>
                            </li>
                            <?php }} ?>
                        </ul>
                    </li>
                
                <?php if(isset($dashboardMenu)){
                foreach($dashboardMenu as $menu){
                      $menuUrl     = isset($menu['url'])?$menu['url']:'';
                      $icon_class  = "fa fa-circle";
                      $moduleName = $menu['label_name'];
                      $href = $this->url('api', array('action' => 'api-detail'),array('query'=>array('id'=>$menu['id'])));
                      if(isset($menu['url']) && $menu['url']!='' && isset($menu['action']) && $menu['action']!=''){
                            $href = $this->url($menu['url'], array('action' => $menu['action']));
                        }
                    ?>
                 <li>

                    <a href="<?php echo $href; ?>">
                        <i class="<?php echo $icon_class; ?>"></i> <span><?php echo $moduleName; ?></span>
                          <?php if(!empty($menu['submenu'])){ ?>
                         <i class="fa fa-angle-left pull-right"></i>
                          <?php } ?>

                    </a>

                    <?php if(!empty($menu['submenu'])){ ?>
			<ul class="treeview-menu">
                            <?php foreach($menu['submenu'] as $submenu){
                                $submenu['icon_class'] = 'fa fa-circle';
                                 $href = '';
                                 $subiconClass = isset($submenu['icon_class'])?$submenu['icon_class']:'';
                                 $submoduleName = isset($submenu['label_name'])?$submenu['label_name']:'';
                                 $href = $this->url('api', array('action' => 'api-detail'),array('query'=>array('id'=>$submenu['id'])));
                                 if(isset($submenu['url']) && $submenu['url']!='' && isset($submenu['action']) &&  $submenu['action']!=''){
                                     $href = $this->url($submenu['url'], array('action' => $submenu['action']));
                                 }
                                 
                          ?>


                            <li><a href="<?php echo $href; ?>"><i class="<?php echo $subiconClass; ?>"></i> <span><?php echo $submoduleName; ?></span>
                                <?php if(!empty($submenu['submenu'])){ ?>
                                <i class="fa fa-angle-left pull-right"></i>
                                 <?php } ?>
                                </a>
                             
                                <?php if(!empty($submenu['submenu'])){ ?>
                                    <ul class="treeview-menu">
                                        <?php foreach($submenu['submenu'] as $subchildmenu){
                                         $href = '';
                                         $subiconClass = 'fa fa-circle';
                                         $submoduleName = $subchildmenu['module_name'];
                                         $href = $this->url('api', array('action' => 'api-detail'),array('query'=>array('id'=>$subchildmenu['id'])));
                                         if(isset($subchildmenu['url']) && $subchildmenu['url']!='' && isset($subchildmenu['action']) &&  $subchildmenu['action']!=''){                                         
                                             $href = $this->url($subchildmenu['url'], array('action' => $subchildmenu['action']));
                                          }
                                        ?>
                                    <li><a href="<?php echo $href; ?>"><i class="<?php echo $subiconClass; ?>"></i> <span><?php echo $submoduleName; ?></span></a></li>
                                        <?php } ?>
                                    </ul>   
                              <?php }?>
                                
                            </li>

                         
                          <?php }?>
			</ul>
		<?php } ?>

                </li>
                <?php }} ?>


            </ul>
        </section>

    </div>
    <!-- /.sidebar -->
</aside>