<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{{ Config::get('constants.website.title') }}</title>


    <!-- begin::global styles -->
    <link rel="stylesheet" href="{{ asset('public/admin/vendors/bundle.css') }}" type="text/css">
    <!-- end::global styles -->
    <!-- begin::custom styles -->
    <link rel="stylesheet" href="{{ asset('public/admin/css/app.min.css') }}" type="text/css">
    <link rel="stylesheet" href="{{ asset('public/admin/css/custom.css') }}" type="text/css">
    <!-- end::custom styles -->
    <!-- begin::datepicker -->
    <link rel="stylesheet" href="{{ asset('public/admin/vendors/datepicker/daterangepicker.css') }}">
    <!-- begin::datepicker -->

    <!-- begin::vmap -->
    <link rel="stylesheet" href="{{ asset('public/admin/vendors/vmap/jqvmap.min.css') }}">
    <!-- begin::vmap -->

    <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.0/css/toastr.css" rel="stylesheet" />

    <!-- JS -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.0/js/toastr.js"></script>


    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <script>
        const _base_url = "{{ URL::to('/') }}";
        let table;
    </script>
    <style>
        .error {
            color: red;
        }
    </style>
    <style>
        div.dt-buttons {
            margin-top: 20px;
        }
    </style>


</head>

<body>

    <!-- begin::page loader-->
    <div class="page-loader">
        <div class="spinner-border"></div>
        <span>Loading</span>
    </div>
    <!-- end::page loader -->

    <!-- begin::sidebar -->

    <x-SuperadminSideBar />

    <!-- end::sidebar -->

    <!-- begin::side menu -->
    <x-SuperadminSideMenu :mainSuperAdminMenu="$mainSuperAdminMenu" :superadminSubMenu="$superadminSubMenu" />
    <!-- end::side menu -->

    <!-- begin::navbar -->
    <x-SuperadminNavBar />
    <!-- end::navbar -->

    <!-- begin::main content -->

    @yield('content')
    <!-- end::main content -->

    <div class="modal fade school-modal" id="staticBackdrop" data-backdrop="static" tabindex="-1" role="dialog"
        aria-labelledby="staticBackdropLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="staticBackdropLabel">Select School</h5>
                    {{-- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button> --}}
                </div>
                <div class="modal-body">
                    {{-- <label for="class">School</label> --}}
                    <select class="form-control select2 schools">
                        <?php
                        $schools = App\Helpers\Dashboard::getSchools();
                        ?>
                        @if (!empty($schools))
                            <option value="">--select-school--</option>
                            @foreach ($schools as $school)
                                <option value="{{ $school->id }}">{{ $school->school }}</option>
                            @endforeach
                        @endif
                    </select>
                </div>
            </div>
        </div>
    </div>


    <!-- begin::global scripts -->
    <script src="{{ asset('public/admin/vendors/bundle.js') }}"></script>
    <script src="{{ asset('public/admin/js/custom.js') }}"></script>
    <script src="{{ asset('public/admin/js/borderless.min.js') }}"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
    <script src="{{ asset('public/admin/vendors/datepicker/daterangepicker.js') }}"></script>
    <link rel="stylesheet" href="{{ asset('public/admin/vendors/select2/css/select2.min.css') }}" type="text/css">
    <script src="{{ asset('public/admin/vendors/select2/js/select2.min.js') }}"></script>
    <script src="{{ asset('public/admin/js/examples/select2.js') }}"></script>


    @stack('footer-script')
    @if (!Request::session()->has('school'))
        <script type="text/javascript">
            $('.school-modal').modal({
                backdrop: 'static',
                keyboard: false
            }, 'show');
        </script>
    @endif

    <script type="text/javascript">
        $('.schools').on('change', function() {

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });


            var school = $(this).val();
            $.ajax({
                type: "post",
                data: {
                    "school": school
                },
                url: "{{ route('change-loggedin-school') }}",
                success: function(result) {
                    location.reload();
                }
            });
        });




        $('.change-school').on('click', function() {
            $('.school-modal').modal({
                backdrop: 'static',
                keyboard: false
            }, 'show');
        });

        $('.select2').select2({
            tags: false
        });
        $('#school').select2({
            placeholder: "Select School/Center",
            tags: false
        });

        $('.delete-confirm').on('click', function(event) {
            event.preventDefault();
            const url = $(this).attr('link');

            swal({
                title: 'Are you sure?',
                text: 'Once deleted, you will not be recover!',
                icon: 'warning',
                dangerMode: true,
                buttons: ["Cancel", "Yes!"],
            }).then(function(value) {
                if (value) {

                    window.location.href = url;

                }
            });
        });
    </script>

    <script>
        $('.status-change').on('change', function(e) {
            e.preventDefault();
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            var id = $(this).data('id');
            var ckb = $(this).is(':checked');

            $.ajax({
                type: "POST",
                data: {
                    "id": id,
                    "ckb": ckb
                },
                url: $(this).data('link'),
                success: function(result) {
                    if (ckb && result) {
                        toastr.success('Successfully Activated!');
                    } else {
                        toastr.warning('Successfully Deactivated!');
                    }
                }
            });
        });
    </script>

    <script>
        $(document).ready(function() {
            toastr.options.timeOut = 10000;
            @if (Session::has('error'))
                toastr.error('{{ Session::get('error') }}');
            @elseif (Session::has('success'))
                toastr.success('{{ Session::get('success') }}');
            @endif
        });
    </script>


</body>

</html>
