<?php

$currentpath = Route::getFacadeRoot()
    ->current()
    ->uri();

ob_start();

$cut = strpos($currentpath, '/');

if ($cut) {
    $pagename = substr($currentpath, 0, $cut);
} else {
    $pagename = $currentpath;
}
//   echo $pagename; die;

//dd(Auth::user()->getUser()->is_admin);
?>
<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <a href="#" class="brand-link">
        <img src="{{ asset('assets/dist/img/AdminLTELogo.png') }}" alt="Client"
            class="brand-image img-circle elevation-3" style="opacity: .8">
        <span class="brand-text font-weight-light">FrenzinCRM</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
        <div class="user-panel mt-3 pb-3 mb-3 d-flex">
            <!-- <div class="image">
                <img src="{{ asset('assets/dist/img/user2-160x160.jpg') }}" class="img-circle elevation-2"
                    alt="User Image">
            </div> -->
            <div class="info">
                <a href="#" class="d-block">{{ Auth::user()->name ?? '' }}</a>
                <a href="#" class="d-block">{{ Auth::user()->getUser()->Email ?? '' }}</a>
                <a href="#" class="d-block">{{ Auth::user()->getUser()->Phone && Auth::user()->getUser()->Phone != 'na'  ? Auth::user()->getUser()->Phone : '' }}</a>
            </div>
        </div>

        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                data-accordion="false">
                {{-- <li class="nav-item menu-open">
                    <a href="#" class="nav-link active">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>
                            Dashboard
                            <i class="right fas fa-angle-left"></i>
                        </p>
                    </a>
                    <ul class="nav nav-treeview">
                        <li class="nav-item">
                            <a href="./index.html" class="nav-link">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Dashboard v1</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="./index2.html" class="nav-link">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Dashboard v2</p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="./index3.html" class="nav-link active">
                                <i class="far fa-circle nav-icon"></i>
                                <p>Dashboard v3</p>
                            </a>
                        </li>
                    </ul>
                </li> --}}

                @if(Auth::user()->getUser() && Auth::user()->getUser()->is_admin == "true")
                <li class="nav-item">
                    <a href="{{route('dashboard')}}" class="nav-link {{ isset($pagename) && $pagename == 'dashboard' ? 'active' : '' }}">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>
                            Dashboard
                        </p>
                    </a>
                </li>

                    <li class="nav-item">
                        <a href="{{route('users.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'user' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-table"></i>
                            <p>
                                Team Members
                            </p>
                        </a>
                    </li>


                @endif
                <li class="nav-item">
                    <a href="{{route('event.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'event' ? 'active' : '' }}">
                        <i class="nav-icon far fa-calendar-alt"></i>
                        <p>
                            Event/Folder
                        </p>
                    </a>
                </li>

                @if(Auth::user()->getUser() && Auth::user()->getUser()->is_admin == "true")
                    <li class="nav-item">
                        <a href="{{route('visitor.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'visitor' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-table"></i>
                            <p>
                                Client
                            </p>
                        </a>
                    </li>

                  {{--  <li class="nav-item">
                        <a href="{{route('newvisitor.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'newvisitor' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-table"></i>
                            <p>
                                New Client
                            </p>
                        </a>
                    </li>--}}

                    <li class="nav-item">
                        <a href="{{route('client.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'client' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-table"></i>
                            <p>
                                Report
                            </p>
                        </a>
                    </li>
                    @if(Session::get('quotation') == 1)

                    <li class="nav-item">
                        <a href="{{route('quotations.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'quotations' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-table"></i>
                            <p>
                                Quotation List
                            </p>
                        </a>
                    </li>
                    @endif




                    {{-- <li class="nav-item">
                        <a href="{{route('sub_category.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'sub_category' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-list-alt"></i>
                            <p>
                                Sub Category
                            </p>
                        </a>
                    </li> --}}

                    <li class="nav-item {{ isset($pagename) && in_array($pagename, ['referred_by_master','action', 'category', 'source_of_lead', 'product']) ? 'active menu-open' : '' }}">
                        <a class="nav-link {{ isset($pagename) && in_array($pagename, ['referred_by_master','action', 'category', 'source_of_lead', 'product']) ? 'active' : '' }}">
                            <i class="nav-icon fas fa-chart-pie"></i>
                            <p>
                               Masters
                            </p>
                        </a>
                        <ul class="nav nav-treeview">
                            <li class="nav-item">
                                <a href="{{ route('action.list') }}"
                                   class="nav-link {{ isset($pagename) && $pagename == 'action' ? 'active' : '' }}">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Action</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ route('category.list') }}"
                                   class="nav-link {{ isset($pagename) && $pagename == 'category' ? 'active' : '' }}">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Category</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ route('source_of_lead.list') }}"
                                   class="nav-link {{ isset($pagename) && $pagename == 'source_of_lead' ? 'active' : '' }}">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p> Source of Lead</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ route('product.list') }}"
                                   class="nav-link {{ isset($pagename) && $pagename == 'product' ? 'active' : '' }}">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Product</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ route('referred_by_master.list') }}"
                                   class="nav-link {{ isset($pagename) && $pagename == 'referred_by_master' ? 'active' : '' }}">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Referred By</p>
                                </a>
                            </li>
                        </ul>
                    </li>

                    <li class="nav-item">
                        <a class="nav-link {{ isset($pagename) && $pagename == 'setting' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-chart-pie"></i>
                            <p>
                               Settings
                            </p>
                        </a>
                        <ul class="nav nav-treeview">
                            @if(auth()->user()->type == 'admin')
                                <li class="nav-item">
                                    <a href="{{ route('setting.subAdminList') }}"
                                       class="nav-link">
                                        <i class="far fa-circle nav-icon"></i>
                                        <p>Add Sub-Admin</p>
                                    </a>
                                </li>
                            @endif
                            <li class="nav-item">
                                <a href="{{route('setting.whatsapp_msg')}}" class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Whatsapp Settings</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ route('emails.index') }}" class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Email Drafts</p>
                                </a>
                            </li>
                            @if(auth()->user()->type == 'admin')
                                <li class="nav-item">
                                    <a href="{{ route('setting.martkey') }}"
                                       class="nav-link">
                                        <i class="far fa-circle nav-icon"></i>
                                        <p>Integrations</p>
                                    </a>
                                </li>
                            @endif
                            {{-- <li class="nav-item">
                                <a href="{{ route('setting.upload_image') }}"
                                class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Upload Image</p>
                                </a>
                            </li> --}}
                            <li class="nav-item">
                                <a href="{{ route('setting.region') }}"
                                class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Region</p>
                                </a>
                            </li>
                            @if(auth()->user()->type == 'admin')
                                <li class="nav-item">
                                    <a href="{{ route('setting.divisionList') }}"
                                       class="nav-link">
                                        <i class="far fa-circle nav-icon"></i>
                                        <p>Division</p>
                                    </a>
                                </li>
                            @endif
                            @if(Session::get('quotation') == 1)
                            <li class="nav-item">
                                <a href="{{ route('setting.quotation_config') }}"
                                class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>Quotation Configuration</p>
                                </a>
                            </li>
                            @endif
                        </ul>
                    </li>
                    @if(Auth::user()->getUser()->is_admin == "true")
                    @if(Session::get('checkin') == 1)
                    <li class="nav-item">
                        <a href="{{route('user_attendance.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'user_attendances' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-list-alt"></i>
                            <p>
                            Attendances
                            </p>
                        </a>
                    </li>
                    @endif
                    @endif
                    @if(Session::get('bulk_whatsapp') == 1)
                    <li class="nav-item">
                        <a href="{{route('template.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'template' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-list-alt"></i>
                            <p>
                                BulkWhatsApp Template
                            </p>
                        </a>
                    </li>
                    @endif
                    {{-- <li class="nav-item">
                        <a href="{{route('setting.change_password')}}" class="nav-link {{ isset($pagename) && $pagename == 'change_password' ? 'active' : '' }}">
                            <i class="nav-icon fas fa-chart-pie"></i>
                            <p>
                              Change Password
                            </p>
                        </a>
                    </li> --}}
                @endif


                <li class="nav-item">
                    <a href="{{route('batch.batch-list')}}" class="nav-link {{ isset($pagename) && $pagename == 'batch' ? 'active' : '' }}">
                        <i class="nav-icon fas fa-chart-pie"></i>
                        <p>
                            Scheduled Bulk Emails
                        </p>
                    </a>
                </li>
                @if(Auth::user()->getUser()->is_admin == "true")

                @if(Session::get('expense') == 1)

                <li class="nav-item">
                    <a href="{{route('expence.list')}}" class="nav-link {{ isset($pagename) && $pagename == 'expence' ? 'active' : '' }}">
                        <i class="nav-icon fas fa-list-alt"></i>
                        <p>
                            Expense
                        </p>
                    </a>
                </li>
                @endif
                @endif
                <li class="nav-item">
                    <a class="nav-link" href="{{ route('logout') }}"
                        onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                        <i class="nav-icon fas fa-power-off"></i>
                        <p>
                            {{ __('Logout') }}
                        </p>
                    </a>
                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                        @csrf
                    </form>
                </li>
            </ul>
        </nav>
    </div>
</aside>
