<!-- LEFT SIDEBAR -->
<div id="left-sidebar" class="left-sidebar ">
    <!-- main-nav -->
    <div class="sidebar-scroll">
        <nav class="main-nav">
            <ul class="main-menu">
				<li><a href="home"><i class="fa fa-briefcase"></i><span class="text">Dashboard</span></a></li>
				<li><?php 
				foreach($side['modules'] as $mod)
					{
						if($mod->Mstatus=="True")
						{
							foreach($side['permission'] as $perms)
							{
								
								if($perms->Mid==$mod->Mid && $perms->View==1) 								
								{
									
									$r=explode('>',$mod->Modulename);
									
									$sidebar['main']['temp'][]=$r[0];
									
									foreach ($sidebar['main']['temp'] as $side_tsingle)
									{
										if(!empty($sidebar['main']['outer']))
										foreach ($sidebar['main']['outer'] as $side_osingle)
										{
											if(empty($sidebar['main']['outer']))
											$sidebar['main']['outer'][]=$r[0];
											if($side_tsingle!=$side_osingle)
											if($side_osingle!=$r[0])
											$sidebar['main']['outer'][]=$r[0];
										}
										else
										$sidebar['main']['outer'][]=$r[0];
									}
									$sidebar['main']['outer']=array_unique ( $sidebar['main']['outer']);
									$sidebar['main'][$r[0]]['inner'][]=$r[1];
									$sidebar['main'][$r[0]][$r[1]]['href']=$mod->mUrl;
									$sidebar['main'][$r[0]][$r[1]]['mname']=$mod->Modulename;
									$sidebar['main'][$r[0]][$r[1]]['icon']=$mod->Micon;
								}
							}
						}					
					}
					$i=0;
					foreach ($sidebar['main']['outer'] as $side_single)
					{
						echo '<li><a href="#" class="js-sub-menu-toggle"><i class="fa fa-users"></i><span class="text">'.$side_single.'</span><i class="toggle-icon fa fa-angle-left"></i></a>';
						
						foreach ($sidebar['main'][$side_single]['inner'] as $side_single_inner)
						{
						echo ' <ul class="sub-menu "><li><a href="'.$sidebar['main'][$side_single][$side_single_inner]['href'].'" class="sideClick"><span class="text">'.$side_single_inner.'</span></a></li></ul>';
						}
					}
				
				?>
				</li>
               
				<li><a href="logout"><i class="fa fa-sign-out"></i><span class="text">Logout</span></a></li>
                
            </ul>
        </nav>
        <!-- /main-nav -->
    </div>
</div>
<!-- END LEFT SIDEBAR -->
<script>
$('.sideClick').click(function(e)
{
	e.preventDefault();
	//alert($(this).attr('href'));
	$('#sideMenu').load($(this).attr('href'));
});
</script>