@include('layout/loading')
<nav class="sidebar sidebar-offcanvas" id="sidebar">
    <ul class="nav">

        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['view_dashboard']))
            <li class="nav-item {{ request()->is('dashboard') ? 'active' : '' }}">
                <a class="nav-link" href="{{ route('homepage') }}">
                    <i class="mdi mdi-ballot menu-icon"></i>
                    <span class="menu-title text-uppercase">{{ __('sidebar.dashboard') }}</span>
                </a>
            </li>
        @endif
        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['view_patient']))
            <li class="nav-item {{ request()->segment(1) == 'patient' ? 'active' : '' }}">
                <a class="nav-link" href="{{ route('patient') }}">
                    <i class="mdi mdi-clipboard-account menu-icon"></i>
                    <span class="menu-title text-uppercase">{{ __('sidebar.patients') }}</span>
                </a>
            </li>
        @endif

        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['view_sample','create_sample']))
            <li class="nav-item {{ request()->segment(1) == 'sample' ? 'active' : '' }}">
                <a class="nav-link" data-toggle="collapse" href="#samples" aria-expanded="false" aria-controls="laboratory">
                    <i class="mdi mdi-account-child-circle menu-icon"></i>
                    <span class="menu-title text-uppercase">គ្រប់គ្រង Aliquots</span>
                    <i class="menu-arrow"></i>
                </a>
                <div class="collapse {{ in_array(request()->segment(1), ['sample']) ? 'show' : '' }}" id="samples">
                    <ul class="nav flex-column sub-menu">
                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_sample']))
                            <li class="nav-item"> <a class="nav-link {{ (request()->segment(1) == 'sample' && request()->segment(2)=='new') ? 'active' : '' }}" href="{{url('sample/new')}}">{{ __('sidebar.new_sample') }}</a></li>
                        @endif
                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['view_sample']))
                            <li class="nav-item"> <a class="nav-link {{ (request()->segment(1) == 'sample' && (request()->segment(2)=='search' || request()->segment(2)=='')) ? 'active' : '' }}" href="{{url('sample/search?kword=&sample_date=today')}}">{{ __('sidebar.view_sample') }}</a></li>
                        @endif

                    </ul>
                </div>
            </li>
        @endif

        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['generate_doctor_report','generate_summary_report', 'generate_financial_report']))
            <li class="nav-item {{ request()->segment(1) == 'report' ? 'active' : '' }}">
                <a class="nav-link" data-toggle="collapse" href="#reports" aria-expanded="false" aria-controls="reports">
                    <i class="mdi mdi-chart-bar-stacked menu-icon"></i>
                    <span class="menu-title text-uppercase">{{ __('sidebar.report') }}</span>
                    <i class="menu-arrow"></i>
                </a>
                <div class="collapse {{ in_array(request()->segment(1), ['report']) ? 'show' : '' }}" id="reports">
                    <ul class="nav flex-column sub-menu">
                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['generate_summary_report']))
                            <li class="nav-item"> <a class="nav-link {{ (request()->segment(2) == 'summary-report') ? 'active' : '' }}" href="{{ url('report/summary-report') }}">{{ __('sidebar.aggregate_report') }}</a></li>
                        @endif
                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['generate_doctor_report']))
                            <li class="nav-item"> <a class="nav-link {{ (request()->segment(2) == 'doctor-report') ? 'active' : '' }}" href="{{ url('report/doctor-report') }}">{{ __('sidebar.doctor_report') }}</a></li>
                        @endif
                        @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['generate_financial_report']))
                        <li class="nav-item"> <a class="nav-link {{ (request()->segment(2) == 'financial-report') ? 'active' : '' }}" href="{{ url('report/financial-report') }}">{{ __('sidebar.financial_report') }}</a></li>
                        @endif
                    </ul>
                </div>
            </li>
        @endif

        <li class="nav-item {{ in_array(request()->segment(1), ['laboratory-profile', 'department', 'sample-type', 'test', 'comment', 'organism', 'antibiotic', 'quantity', 'sample-source', 'patient-type', 'physician', 'lab-users']) ? 'active' : '' }}">
            <a class="nav-link" data-toggle="collapse" href="#lab-manager" aria-expanded="false" aria-controls="lab_manager">
                <i class="fa fa-folder-open-o menu-icon"></i>
                <span class="menu-title text-uppercase">គ្រប់គ្រងសម្ភារៈ</span>
                <i class="menu-arrow"></i>
            </a>
            <div class="collapse {{ in_array(request()->segment(1), ['laboratory-profile', 'department', 'sample-type', 'test', 'comment', 'organism', 'antibiotic', 'quantity', 'sample-source', 'patient-type', 'physician', 'lab-users']) ? 'show' : '' }}" id="lab-manager">
                <ul class="nav flex-column sub-menu">
                    <li class="nav-item"> <a class="nav-link" href="">បន្ទប់</a></li>
                    <li class="nav-item"> <a class="nav-link" href="">ទូរបង្កក</a></li>
                    <li class="nav-item"> <a class="nav-link" href="">ប្រភេទសារពាង្គកាយ/មេរោគ</a></li>
                    <li class="nav-item"> <a class="nav-link" href="">ប្រភេទសំណាក</a></li>
                    <li class="nav-item"> <a class="nav-link" href="">ប្រភពសំណាក</a></li>
                </ul>
            </div>
        </li>

        <li class="nav-item {{ request()->is('my-profile') ? 'active' : '' }}">
            <a class="nav-link" href="{{ url('my-profile') }}">
                <i class="mdi mdi-account-circle menu-icon"></i>
                <span class="menu-title text-uppercase">{{ __('general.profile') }}</span>
            </a>
        </li>

    </ul>
</nav>
