<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ระบบจัดการโรงเรียนสอนขับรถตะกั่วป่าพังงา</title> <!-- หัวเว็บ -->
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="icon" href="{{ asset('imgs/logo.png') }}">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
    <link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@200&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@300&display=swap" rel="stylesheet">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap" rel="stylesheet">

    @yield('css')

    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
    <link rel="stylesheet" href="{{ asset('css/style.css') }}">

</head>

<body class="hold-transition">
    <div class="wrapper" id="app">
        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand bg-white navbar-light">
            <!-- Left navbar links -->
            <ul class="navbar-nav mr-auto">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i></a>
                </li>
                <li class="nav-item ml-3 pt-1">
                    <h4>{{ $page_title }}</h4>
                </li>
            </ul>
            <!-- Right navbar links -->
            <ul class="navbar-nav ml-auto mt-auto">
                <li class="nav-item dropdown mr-3">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                      <span>{{ auth()->user()->firstname." ".auth()->user()->lastname  }} <i class="fas fa-angle-down"></i></span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <form action="{{ route('user.change_password')}}" method="post">
                        @csrf
                            <input type="hidden" name="uid" value="{{auth()->user()->id}}">
                            <button class="dropdown-item button-dropdown-item" type="submit"><i class="fas fa-key mr-2"></i> เปลี่ยนรหัสผ่าน</button>
                        </form>
                        <div class="dropdown-divider"></div>
                        <a href="{{ route('user.info') }}" class="dropdown-item">
                            <i class="fas fa-address-card mr-2"></i> ข้อมูลส่วนตัว
                        </a>
                    </div>
                  </li>
                <li class="nav-item d-sm-inline-block">
                    <form id="logout-form" action="{{ route('logout') }}" method="POST">
                        <button type=submit class="btn btn-sm btn-outline-danger mt-1">
                            <span><i class="fas fa-sign-out-alt "></i> Logout</span>
                        </button>
                    @csrf
                    </form>
                </li>
            </ul>
        </nav>
        <!-- /.navbar -->

        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-dark-primary elevation-4">
            <!-- Brand Logo -->
            <div class="brand-link" style="border: none; background-color:#4F7957; height:3.1em;">
                <img src="{{ asset('imgs/logo.png') }}" alt="Logo" class="brand-image ">
                <span class="brand-text" style="font-size: 0.85em;">โรงเรียนสอนขับรถตะกั่วป่า</span><!-- หัวเว็บ -->
            </div>

            <!-- Sidebar -->
            <div class="sidebar">
                <!-- Sidebar Menu -->
                <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 text-center">
                            <button type="button" class="btn btn-light btn-block" onclick="window.location.href='{{ route('student.create') }}';">ลงทะเบียนนักเรียนใหม่</button>
                            <hr />
                        </li>

                        <li class="nav-item has-treeview">
                            <a href="{{ route('home.index') }}" class="nav-link
                            {{ request()->routeIs('home.index') ? 'active' : '' }}
                            {{ request()->routeIs('home.showExam') ? 'active' : '' }}
                            {{ request()->routeIs('home.showTomorrow') ? 'active' : '' }}
                            ">
                                <i class="fas fa-tachometer-alt mr-2"></i> หน้าแรก
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('teacher_scan.index') }}" class="nav-link
                            {{ request()->routeIs('teacher_scan.index') ? 'active' : '' }}
                            ">
                                <i class="fas fa-user-tie mr-2"></i> ครูสแกนว่าง
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('calendar.index_day') }}" class="nav-link
                                {{ request()->routeIs('calendar.index_day') ? 'active' : '' }}
                                {{ request()->routeIs('calendar.submit_day') ? 'active' : '' }}
                                ">
                                <i class="fas fa-calendar-alt mr-2"></i> ตารางเรียน (รายวัน)
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('calendar') }}" class="nav-link
                                {{ request()->routeIs('calendar') ? 'active' : '' }}
                                {{ request()->routeIs('calendar.submit') ? 'active' : '' }}
                                ">
                                <i class="fas fa-calendar-alt mr-2"></i> ตารางเรียน (รายสัปดาห์)
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('student.index') }}" class="nav-link
                            {{ request()->routeIs('student.index') ? 'active' : '' }}
                            {{ request()->routeIs('student.create') ? 'active' : '' }}
                            @if(isset($student->id) && $student->is_active=='1')
                            {{ request()->routeIs('student.edit') ? 'active' : '' }}
                            @endif
                            {{ request()->routeIs('student.show') ? 'active' : '' }} ">
                                <i class="fas fa-user mr-2"></i> การจัดการนักเรียน
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('course.index') }}" class="nav-link
                            {{ request()->routeIs('course.index') ? 'active' : '' }}
                            {{ request()->routeIs('course.create') ? 'active' : '' }}
                            {{ request()->routeIs('course.edit') ? 'active' : '' }}
                            {{ request()->routeIs('course.show') ? 'active' : '' }} ">
                                <i class="fas fa-book mr-2"></i> การจัดการคอร์สเรียน
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('teacher.index') }}" class="nav-link
                            {{ request()->routeIs('teacher.index') ? 'active' : '' }}
                            {{ request()->routeIs('teacher.create') ? 'active' : '' }}
                            {{ request()->routeIs('teacher.edit') ? 'active' : '' }}
                            {{ request()->routeIs('teacher.show') ? 'active' : '' }} ">
                                <i class="fas fa-user-tie mr-2"></i> <p>การจัดการผู้สอน </p>
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('vehicle.index') }}" class="nav-link
                            {{ request()->routeIs('vehicle.index') ? 'active' : '' }}
                            {{ request()->routeIs('vehicle.create') ? 'active' : '' }}
                            {{ request()->routeIs('vehicle.edit') ? 'active' : '' }}
                            ">
                                <i class="fas fa-car mr-2"></i> การจัดการยานพาหนะ
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('branch.index') }}" class="nav-link
                            {{ request()->routeIs('branch.index') ? 'active' : '' }}
                            {{ request()->routeIs('branch.create') ? 'active' : '' }}
                            {{ request()->routeIs('branch.edit') ? 'active' : '' }}
                            {{ request()->routeIs('branch.show') ? 'active' : '' }}
                            ">
                            <i class="fas fa-university mr-2"></i> การจัดการสาขา
                            </a>
                        </li>

                        @can('isSuperadmin')
                        <li class="nav-item has-treeview">
                            <a href="{{ route('payment.index') }}" class="nav-link
                            {{ request()->routeIs('payment.index') ? 'active' : '' }}
                            {{ request()->routeIs('payment.create') ? 'active' : '' }}
                            {{ request()->routeIs('payment.edit') ? 'active' : '' }}
                            ">
                                <i class="fas fa-money-bill-alt mr-2"></i> การจัดการค่าจ้าง
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('user.index') }}" class="nav-link
                            {{ request()->routeIs('user.index') ? 'active' : '' }}
                            {{ request()->routeIs('user.create') ? 'active' : '' }}
                            {{ request()->routeIs('user.edit') ? 'active' : '' }}
                            {{ request()->routeIs('user.show') ? 'active' : '' }}
                            {{ request()->routeIs('user.admin_change_password') ? 'active' : '' }}
                            ">
                                <i class="fas fa-user-cog mr-2"></i> การจัดการผู้ใช้ระบบ
                            </a>
                        </li>
                        @endcan
                        <li class="nav-item has-treeview">
                            <a href="{{ route('income.index') }}" class="nav-link
                            {{ request()->routeIs('income.index') ? 'active' : '' }}
                            {{ request()->routeIs('income.create') ? 'active' : '' }}
                            {{ request()->routeIs('income.edit') ? 'active' : '' }}
                            {{ request()->routeIs('income.show') ? 'active' : '' }}
                            {{ request()->routeIs('income.submit') ? 'active' : '' }}
                            ">
                            <i class="fas fa-hand-holding-usd mr-2"></i> รายรับอื่นๆ
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a href="{{ route('withdraw.index') }}" class="nav-link
                            {{ request()->routeIs('withdraw.index') ? 'active' : '' }}
                            {{ request()->routeIs('withdraw.create') ? 'active' : '' }}
                            {{ request()->routeIs('withdraw.edit') ? 'active' : '' }}
                            {{ request()->routeIs('withdraw.show') ? 'active' : '' }}
                            {{ request()->routeIs('withdraw.submit') ? 'active' : '' }}
                            ">
                            <i class="fas fa-hand-holding-usd mr-2"></i> รายการเบิกเงิน
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('finance') }}" class="nav-link
                            {{ request()->routeIs('finance') ? 'active' : '' }}
                            {{ request()->routeIs('finance.submit') ? 'active' : '' }}
                            ">
                                <i class="fas fa-coins mr-2"></i> การเงิน
                            </a>
                        </li>


                        {{-- <li class="nav-item has-treeview">
                            <a href="#" class="nav-link">
                                <i class="fas fa-chart-pie mr-2"></i> รายงาน
                            </a>
                        </li> --}}

                        @can('isSuperadmin')
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('report') }}" class="nav-link
                            {{ request()->routeIs('report') ? 'active' : '' }}
                            {{ request()->routeIs('report.submit') ? 'active' : '' }}
                            ">
                            <i class="fas fa-chart-bar mr-2"></i> กราฟรายงาน
                            </a>
                        </li>
                        <li><hr /></li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('student.graduated') }}" class="nav-link
                            {{ request()->routeIs('student.graduated') ? 'active' : '' }}
                            {{ request()->routeIs('student.show_graduated') ? 'active' : '' }}
                            @if(isset($student->id) && $student->is_active=='0')
                            {{ request()->routeIs('student.edit') ? 'active' : '' }}
                            @endif
                            ">
                                <i class="fas fa-user mr-2"></i> นักเรียนที่เรียนจบแล้ว
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('log.access') }}" class="nav-link
                            {{ request()->routeIs('log.access') ? 'active' : '' }}
                            {{ request()->routeIs('log.access_post') ? 'active' : '' }}
                            ">
                            <i class="fas fa-clock mr-2"></i> บันทึกการเข้าระบบ
                            </a>
                        </li>
                        <li class="nav-item has-treeview">
                            <a  href="{{ route('log.event') }}" class="nav-link
                            {{ request()->routeIs('log.event') ? 'active' : '' }}
                            {{ request()->routeIs('log.event_post') ? 'active' : '' }}
                            ">
                            <i class="fas fa-clock mr-2"></i> บันทึกการใช้งานระบบ
                            </a>
                        </li>
                        @endcan

                    </ul>
                </nav>
                <!-- /.sidebar-menu -->
            </div>
            <!-- /.sidebar -->
        </aside>

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">

            @yield('content')

        </div>

    </div>
    <!-- ./wrapper -->

    <script src="{{ asset('js/app.js') }}"></script>

    @yield('footerscript')

</body>

</html>
