<!DOCTYPE html>
<!--
**********************************************************************************************************
    Copyright (c) 2026.
**********************************************************************************************************  -->
<!--
Template Name: Quick Quiz – Quiz and Exam System Web and Mobile App
Version: 5.0
Author: Media City
-->
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]> -->
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="theme-color" content="#6777EF">
    <link rel="apple-touch-icon" href="{{ asset('logo.png') }}">
    <link rel="manifest" href="{{ asset('/manifest.json') }}">
    <?php
    $setting = App\Models\Setting::first();
    $auth = Auth::user();
    ?>

    <link rel="icon" type="image/ico" href="{{ asset('/images/logo/' . $setting->favicon) }}">
    <!--[if IE]>
  <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon">
  <![endif]-->
    <title>{{ $setting->welcome_txt }} Admin Panel</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{{ asset('css/font-awesome.min.css') }}">
    <!-- Ionicons -->
    <link rel="stylesheet" href="{{ asset('css/ionicons.min.css') }}">
    <!-- Admin Theme style -->
    <link rel="stylesheet" href="{{ asset('css/AdminLTE.css') }}">
    <link rel="stylesheet" href="{{ asset('css/skin-black.css') }}">
    <!-- Select 2 -->
    <link rel="stylesheet" href="{{ asset('css/select2.min.css') }}">
    <!-- DataTable -->
    <link rel="stylesheet" href="{{ asset('css/datatables.min.css') }}">
    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>

<body class="hold-transition skin-black sidebar-mini">
    <a href="#main-content" class="sr-only sr-only-focusable" style="position:absolute;top:0;left:0;z-index:99999;padding:10px;background:#fff;">Skip to main content</a>
    @if ($auth)
        <div class="wrapper">
            <!-- Main Header -->
            <header class="main-header">
                <!-- Logo -->
                <a href="{{ url('/') }}" class="logo" title="{{ $setting->welcome_txt }}">
                    <!-- logo for regular state and mobile devices -->
                    <span class="logo-lg">
                        @if ($setting)
                            <img src="{{ asset('/images/logo/' . $setting->logo) }}" class="ad-logo img-responsive"
                                alt="{{ $setting->welcome_txt }}">
                        @endif
                    </span>
                </a>
                <!-- Header Navbar -->
                <nav class="navbar navbar-static-top" role="navigation">
                    <!-- Sidebar toggle button-->
                    <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                        <span class="sr-only">Toggle navigation</span>
                    </a>
                    <a href="{{ url('/') }}" class="btn visit-btn" target="_blank" title="Visit Site">Visit Site
                        <i class="fa fa-arrow-circle-o-right"></i></a>
                    <!-- Navbar Right Menu -->
                    <div class="navbar-custom-menu">
                        <ul class="nav navbar-nav">
                            <!-- User Account Menu -->
                            <li class="dropdown">
                                <!-- Menu Toggle Button -->
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <!-- hidden-xs hides the username on small devices so only the image appears. -->
                                    <span class="hidden-xs">{{ $auth->name }}</span>
                                    <i class="fa fa-user hidden-lg hidden-md hidden-sm"></i>
                                </a>
                                <ul class="dropdown-menu">
                                    <!-- Menu Body -->
                                    <li><a href="{{ url('/admin/profile') }}" title="Profile">Profile</a></li>
                                    <li>
                                        <a href="{{ route('logout') }}" title="Logout"
                                            onclick="event.preventDefault();
                             document.getElementById('logout-form').submit();">
                                            Logout
                                        </a>
                                        <form id="logout-form" action="{{ route('logout') }}" method="POST"
                                            style="display: none;">
                                            {{ csrf_field() }}
                                        </form>
                                    </li>

                                    <li>
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                            data-target="#exampleModal">
                                            Delete Account Request
                                        </button>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </nav>
            </header>

            <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Delete Account Request</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <form action="{{ route('delete.user.account') }}" method="POST">
                            @csrf

                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="deleteReason">Reason for Account Deletion:</label>
                                    <textarea class="form-control" id="deleteReason" name="deleteReason" rows="4"></textarea>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="submit" class="btn btn-danger request">Submit</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!-- Left side column. contains the logo and sidebar -->
            <aside class="main-sidebar">
                <!-- sidebar: style can be found in sidebar.less -->
                <section class="sidebar">
                    <!-- Sidebar user panel (optional) -->
                    <div class="user-panel">
                        <div class="pull-left info">
                            <h4>{{ $auth->name }}</h4>
                        </div>
                    </div>
                    <!-- Sidebar Menu -->
                    <ul class="sidebar-menu" data-widget="tree" role="navigation" aria-label="Admin sidebar navigation">
                        <li class="header">Main Sections</li>
                        @php
                            $dash = '';
                            $users = '';
                            $quiz = '';
                            $questions = '';
                            $all_re = '';
                            $top_re = '';
                            $sett = '';
                            $delete = '';
                            $page_header = '';
                            $password = '';
                        @endphp
                        @if ($auth->role == 'A')
                            <!-- Optionally, you can add icons to the links -->
                            <li class="{{ $dash }}"><a href="{{ url('/admin') }}" title="Dashboard"><i
                                        class="fa fa-dashboard"></i> <span>Dashboard</span></a></li>
                            <li class="{{ $users }}"><a href="{{ url('/admin/users') }}" title="Students"><i
                                        class="fa fa-users"></i> <span>Students</span></a></li>
                            <li class="{{ $quiz }}"><a href="{{ url('/admin/topics') }}" title="Quiz"><i
                                        class="fa fa-gears"></i> <span>Quiz</span></a></li>
                            <li class="{{ $questions }}"><a href="{{ url('views/admin/questions') }}"
                                    title="Questions"><i class="fa fa-question-circle-o"></i>
                                    <span>Questions</span></a>
                            </li>
                            <li class="{{ $all_re }}"><a href="{{ url('/admin/all_reports') }}"
                                    title="Student Report"><i class="fa fa-file-text-o"></i> <span>Student
                                        Report</span></a></li>
                            <li class="{{ $top_re }}"><a href="{{ url('/admin/top_report') }}"
                                    title="Top Student Report"><i class="fa fa-user"></i> <span>Top Student
                                        Report</span></a></li>
                            <li class="{{ $sett }}"><a href="{{ url('/admin/settings') }}"
                                    title="Settings"><i class="fa fa-gear"></i> <span>Settings</span></a></li>

                            <li class="{{ $delete }}"><a href="{{ url('/admin/user-requests') }}"
                                    title="User Delete Requests"><i class="fa fa-book"></i> <span>User Delete
                                        Requests</span></a></li>
                            <li class="{{ $password }}"><a href="{{ url('/admin/edit_profile') }}"
                                    title="Password Profile"><i class="fa fa-key"></i> <span>Password
                                        Profile</span></a></li>
                        @elseif ($auth->role == 'S')
                            <li><a href="{{ url('/admin/my_reports') }}" title=">My Reports"><i
                                        class="fa fa-file-text-o"></i> <span>My Reports</span></a></li>
                            <li><a href="{{ url('/admin/profile') }}" title="My Profile"><i
                                        class="fa fa-file-text-o"></i> <span>My Profile</span></a></li>
                        @endif
                    </ul>
                    <!-- /.sidebar-menu -->
                </section>
                <!-- /.sidebar -->
            </aside>
            <!-- Content Wrapper. Contains page content -->
            <div class="content-wrapper">
                @if (Session::has('added'))
                    <div class="alert alert-success sessionmodal">
                        {{ session('added') }}
                    </div>
                @elseif (Session::has('updated'))
                    <div class="alert alert-info sessionmodal">
                        {{ session('updated') }}
                    </div>
                @elseif (Session::has('deleted'))
                    <div class="alert alert-danger sessionmodal">
                        {{ session('deleted') }}
                    </div>
                @endif
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        {{ $page_header }}
                        {{-- <small>Optional description</small> --}}
                    </h1>
                </section>
                <!-- Main content -->
                <section class="content container-fluid" id="main-content" role="main">
                    @yield('content')
                </section>
                <!-- /.content -->
            </div>
            <!-- /.content-wrapper -->
            <!-- Main Footer -->
            {{-- <footer class="main-footer">    
    <!-- Default to the left -->
    <strong>Copyright &copy; 2024 <a href="{{url('/')}}" title="{{$setting->welcome_txt}}">{{$setting->welcome_txt}}</a>.</strong> All rights reserved.
  </footer> --}}
            <div class="main-footer">
                <footer class="footer">
                    <strong>Copyright &copy; 2024 <a href="{{ url('/') }}"
                            title="{{ $setting->welcome_txt }}">{{ $setting->welcome_txt }}</a>.</strong> All rights
                    reserved.
                    {{-- <p class="mb-0">{{ __('© :date | AFRIFARM - All Rights Reserved.',['date' => date('Y'),'company' => config('app.name')]) }} --}}

                    <span class="float-right">
                        {{ __('Version :version', ['version' => '4.0']) }}
                    </span>
                    </p>


                </footer>
            </div>
        </div>
    @endif
    <!-- ./wrapper -->
    <!-- REQUIRED JS SCRIPTS -->
    <!-- jQuery 3 -->
    <script src="{{ asset('js/jquery.min.js') }}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="{{ asset('js/bootstrap.min.js') }}"></script>
    <!-- DataTable -->
    <script src="{{ asset('js/datatables.min.js') }}"></script>
    <!-- Select2 -->
    <script src="{{ asset('js/select2.full.min.js') }}"></script>
    <!-- AdminLTE App -->
    <script src="{{ asset('js/adminlte.min.js') }}"></script>
    <script src="{{ asset('/sw.js') }}"></script>
    {{-- <script>
        if (!navigator.serviceWorker.controller) {
            navigator.serviceWorker.register("/sw.js").then(function(reg) {
                console.log("Service worker has been registered for scope: " + reg.scope);
            });
        }
    </script> --}}
    <script>
        $(function() {
            $(document).ready(function() {
                $('.sessionmodal').addClass("active");
                setTimeout(function() {
                    $('.sessionmodal').removeClass("active");
                }, 4500);
            });

            $('#example1').DataTable({
                "sDom": "<'row'><'row'<'col-md-4'l><'col-md-4'B><'col-md-4'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
                buttons: [{
                        extend: 'print',
                        exportOptions: {
                            columns: ':visible'
                        }
                    },
                    'csvHtml5',
                    'excelHtml5',
                    'colvis',
                ]
            });

            $('#questions_table').DataTable({
                "sDom": "<'row'><'row'<'col-md-4'l><'col-md-4'B><'col-md-4'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
                buttons: [{
                        extend: 'print',
                        exportOptions: {
                            columns: ':visible'
                        }
                    },
                    'csvHtml5',
                    'excelHtml5',
                    'colvis',
                ],
                columnDefs: [{
                    targets: [7, 8, 9, 10],
                    visible: false
                }, ]
            });

            $('#search').DataTable({
                'paging': false,
                'lengthChange': false,
                'searching': true,
                'ordering': false,
                'info': false,
                'autoWidth': true,
                "sDom": "<'row'><'row'<'col-md-4'B><'col-md-8'f>r>t<'row'>",
                buttons: [{
                        extend: 'print',
                        exportOptions: {
                            columns: ':visible'
                        }
                    },
                    'excelHtml5',
                    'csvHtml5',
                    'colvis',
                ]
            });

            $('#topTable').DataTable({
                "order": [
                    [5, "desc"]
                ],
                "lengthMenu": [
                    [5, 10, 15, -1],
                    [5, 10, 15, "All"]
                ],
                "sDom": "<'row'><'row'<'col-md-4'l><'col-md-4'B><'col-md-4'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
                buttons: [{
                        extend: 'print',
                        exportOptions: {
                            columns: ':visible'
                        }
                    },
                    'excelHtml5',
                    'csvHtml5',
                    'colvis',
                ]
            });
            //Initialize Select2 Elements
            $('.select2').select2()
        });

        if (!navigator.serviceWorker.controller) {
            navigator.serviceWorker.register("/sw.js").then(function(reg) {
            });
        }

        // Toggle password visibility
        $(document).on('click', '.toggle-password', function() {
            var input = $(this).closest('.input-group').find('.password-field');
            var icon = $(this).find('i');
            if (input.attr('type') === 'password') {
                input.attr('type', 'text');
                icon.removeClass('fa-eye').addClass('fa-eye-slash');
            } else {
                input.attr('type', 'password');
                icon.removeClass('fa-eye-slash').addClass('fa-eye');
            }
        });

        // Mobile number input - only allow digits and +
        $(document).on('keypress', '.mobile-input', function(e) {
            var charCode = e.which || e.keyCode;
            var charStr = String.fromCharCode(charCode);
            if (!/[\d\+]/.test(charStr)) {
                e.preventDefault();
            }
        });
        $(document).on('paste', '.mobile-input', function(e) {
            var pastedData = (e.originalEvent.clipboardData || window.clipboardData).getData('text');
            if (!/^[\d\+]+$/.test(pastedData)) {
                e.preventDefault();
            }
        });

        // Positive numbers only for number inputs in quiz forms
        $(document).on('input', 'input[type="number"]', function() {
            if (this.value < 0) this.value = 0;
        });
    </script>

    <script>
        // Initialize toastr
        toastr.options = {
            "closeButton": true,
            "debug": false,
            "newestOnTop": false,
            "progressBar": true,
            "positionClass": "toast-top-right",
            "preventDuplicates": false,
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "5000",
            "extendedTimeOut": "1000",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };

        $(document).ready(function() {
            // Create FormData object to collect form data
            var formData = new FormData();

            // Handle form submission
            $("#deleteForm").on('submit', function(e) {

                e.preventDefault(); // Prevent default form submission
                $('.request').prop("disabled", true); // Disable submit button

                // Append form data to FormData object
                formData.append('deleteReason', $("#deleteReason").val());

                var baseUrl = "{{ url('/') }}";
                var url = baseUrl + '/delete-account-request';
                $.ajax({
                    type: "POST",
                    url: url,
                    data: formData,
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    contentType: false,
                    processData: false,
                    success: function(response) {
                        // Handle success response
                        toastr.success('Delete Account Request Submitted Successfully');

                        $('#exampleModal').modal('hide');


                    },
                    error: function(xhr, status, error) {
                        // Handle error response
                        toastr.error('Error submitting delete request: ' + error);

                        $('#exampleModal').modal('hide');

                    }
                });
            });
        });
    </script>
</body>

</html>
