<div class="wrapper">
    <?php
    $menus= Helper::nav();
        ?>
    <div class="sidebar" data-color="blue">
        <!--

            Tip 1: you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple"
            Tip 2: you can also add an image using data-image tag

        -->

        <div class="logo">
            <a href="{{URL::to('dashboard')}}" class="logo-text">
                {{\Illuminate\Support\Facades\Auth::user()->client->company_name}}
            </a>
        </div>
        <div class="logo logo-mini">
            <a href="{{URL::to('dashboard')}}" class="logo-text">
                {{\Illuminate\Support\Facades\Auth::user()->client->company_name}}
            </a>
        </div>
        <div class="sidebar-wrapper">

            <div class="user">
                <div class="photo">
                    @if(empty($loggedIn->image))
                        <img src="{{asset("public/img/users/default-avatar.png")}}">
                    @else
                        <img src="{{asset("public/img/users/$loggedIn->image")}}">
                    @endif
                </div>

                <div class="info">
                    <a  href="{{URL::to('my-profile')}}" title="My Profile" style="text-transform: uppercase;">
                        {{$loggedIn->first_name." ".$loggedIn->last_name}}
                    </a>

                </div>
            </div>
            <ul class="nav">
                @if(count($menus)>0)
                    @foreach($menus as $key => $menu)
                        @if(is_array($menu))
                            <?php
                                $explode= explode("#",$key);
                                $menuName=$explode[0];
                                $url=$explode[1];
                                $icon=$explode[2];

                            ?>
                            <li>
                                <a data-toggle="collapse" href="#{{$menuName}}">
                                    <i class="{{$icon}}"></i>
                                    <p>{{ Lang::get("nav.$menuName") }}
                                        <b class="caret"></b>
                                    </p>
                                </a>
                                <div class="collapse" id="{{$menuName}}">
                                    <ul class="nav">
                                        @foreach($menu as $subMenu=>$subUrl)
                                            <li><a href="{{Url::route($subUrl)}}">{{Lang::get("nav.$subMenu")}}</a></li>
                                        @endforeach
                                    </ul>
                                </div>
                            </li>
                            @else
                            <?php
                            $explode= explode("#",$key);
                            $menuName=$explode[0];
                            $url=$explode[1];
                            $icon=$explode[2];

                            ?>
                            <li>
                                <a href="{{URL::to($url)}}">
                                    <i class="{{$icon}}"></i>
                                    <p>{{ Lang::get("nav.$menuName") }}</p>
                                </a>
                            </li>
                        @endif

                    @endforeach
                @endif

            </ul>
        </div>
    </div>
        <script type="text/javascript">
            /* Selected Active menu code*/
            var url = window.location.href;
            if ($('ul li a[href="' + url + '"]').parent().parent().parent().parent().find('div').attr('class')=='collapse'){
                    $('ul li a[href="' + url + '"]').parent().parent().parent().parent().addClass('active'); //parent menu
                    $('ul li a[href="' + url + '"]').parent().parent().parent().parent().find('div').attr('class','collapse in'); //expand menu div
                    $('ul li a[href="' + url + '"]').parent().addClass('active'); //current menu
            }else{
                $('ul li a[href="' + url + '"]').parent().addClass('active');
            }
            /* Selected Active menu code end*/
        </script>

    <div class="main-panel">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-minimize">
                    <button id="minimizeSidebar" class="btn btn-primary btn-fill btn-round btn-icon">
                        <i class="fa fa-ellipsis-v visible-on-sidebar-regular"></i>
                        <i class="fa fa-navicon visible-on-sidebar-mini"></i>
                    </button>
                </div>
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <span class="navbar-brand">Welcome, Last Login at {{Helper::stringDate($loggedIn->last_login_time)}} from {{$loggedIn->last_login_ip}}</span>
                </div>
                <div class="collapse navbar-collapse">


                    <?php $notification=Helper::notification();  $services=[];
                    ?>
                    <ul class="nav navbar-nav navbar-right">

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-bell-o"></i>
                                @if(count($notification)>0)
                                <span class="notification">{{count($notification)}}</span>
                                @endif
                                <p class="hidden-md hidden-lg">
                                    Notifications
                                    <b class="caret"></b>
                                </p>
                            </a>
                            <ul class="dropdown-menu">
                                @if(count($notification)>0)
                                    @foreach($notification as $notify)
                                        <li><a href="{{$notify['url']}}">{{$notify['text']}}</a></li>
                                    @endforeach
                                @else
                                    <li><a>No notification</a></li>
                                @endif
                            </ul>
                        </li>


                        <li class="dropdown dropdown-with-icons">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                <i class="fa fa-list"></i>
                                <p class="hidden-md hidden-lg">
                                    More
                                    <b class="caret"></b>
                                </p>
                            </a>
                            <ul class="dropdown-menu dropdown-with-icons">
                               {{-- <li>
                                    <a href="#">
                                        <i class="pe-7s-mail"></i> Messages
                                    </a>
                                </li>--}}
                                <li>
                                    <a href="{{url('my-profile')}}">
                                        <i class="pe-7s-tools"></i> Settings
                                    </a>
                                </li>
                                <li class="divider"></li>

                                <li>
                                    <a href="{{URL::to('logout')}}" class="text-warning">
                                        <i class="pe-7s-close-circle"></i>
                                        Log out
                                    </a>
                                </li>
                            </ul>
                        </li>

                    </ul>
                </div>
            </div>
        </nav>