<!-- BEGIN MENUBAR-->
<?php 
	use App\Models\Adminmenumanage;
	use App\Models\Option;
	use App\Models\Usergroup;
	use App\Models\Usergroupmeta;
	$menus = Adminmenumanage::where('parentId',0)->where('status','active')->get();
	$portalName = Option::getvalue("portalName");
?>
<div id="menubar" class="menubar-inverse ">
	<div class="menubar-fixed-panel">
		<div>
			<a class="btn btn-icon-toggle btn-default menubar-toggle" data-toggle="menubar" href="javascript:void(0);">
				<i class="fa fa-bars"></i>
			</a>
		</div>
		<div class="expanded">
			<a href="{!! URL::to('admin') !!}">
				<span class="text-lg text-bold text-primary" style="color: #fff;">{!! $portalName !!}&nbsp;ADMIN</span>
			</a>
		</div>
	</div>
	<div class="menubar-scroll-panel">

		<!-- BEGIN MAIN MENU -->
		<ul id="main-menu" class="gui-controls">		
			@foreach($menus as $first)
				
				@if(Usergroup::getviewulpermission(Auth::user()->userGroup,$first->menuId) == true || Auth::User()->userGroup == 1)
					@if(Adminmenumanage::hasSubmenu($first->menuId) != 0)
						<li class="gui-folder">
					@else
						<li>
					@endif

					<?php
						$details = Adminmenumanage::getmenudetails($first->menuId);
					?>

					@if($details)

						<?php
							if($details->url != ''){
								$url = URL::to($details->url);
							}else{
								$url = "javascript:void(0)";
							}
						?>
						
						<a href="{!! $url !!}">
							<div class="gui-icon">{!! $details->menuicon !!}</div>
							<span class="title">{!! ucwords($details->menuname) !!}</span>
						</a>
					@endif
					
					<!--start submenu -->
					@if(Adminmenumanage::hasSubmenu($first->menuId) != 0)
						<ul>
							@foreach(Adminmenumanage::getSubmenu($first->menuId) as $second)
								@if(Adminmenumanage::hasSubmenu($second->menuId) != 0)
									<li class="gui-folder">
								@else
									<li>
								@endif

								<?php
									$details = Adminmenumanage::getmenudetails($second->menuId);
								?>
								
								@if($details)
									<?php
										if($details->url != ''){
											$url = URL::to($details->url);
										}else{
											$url = "javascript:void(0)";
										}
									?>
									@if(Usergroup::getviewpermission(Auth::user()->userGroup, $second->menuId) == true || Auth::User()->userGroup == 1)
										<a href="{!! $url !!}">
											<span class="title">{!! ucwords($details->menuname) !!}</span>
										</a>
									@endif
								@endif

								<!--start submenu -->
								@if(Adminmenumanage::hasSubmenu($second->menuId) != 0)
									<ul>
										@foreach(Adminmenumanage::getSubmenu($second->menuId) as $third)
											<?php
												$details = Adminmenumanage::getmenudetails($third->menuId);
											?>

											@if($details)
												<?php
													$details = Adminmenumanage::getmenudetails($third->menuId);
													if($details->url!=''){
														$url = URL::to($details->url);
													}else{
														$url = "javascript:void(0)";
													}
												?>
												<li><a href="{!! $url !!}" ><span class="title">{!! ucwords($details->menuname) !!}</span></a></li>
											@endif
										@endforeach
									</ul><!--end /submenu -->
								@endif
								</li><!--end /menu-li -->
							@endforeach
						</ul><!--end /submenu -->
					@endif
					</li><!--end /menu-li -->
				@endif
			@endforeach
			</ul><!--end .main-menu -->
			<!-- END MAIN MENU -->

			<div class="menubar-foot-panel">
				<small class="no-linebreak hidden-folded">
					<span class="opacity-75">Copyright &copy; {!! date("Y") !!}</span> <strong>{!! $portalName !!}</strong>
				</small>
			</div>
	</div><!--end .menubar-scroll-panel-->
</div><!--end #menubar-->
<!-- END MENUBAR -->