<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>Jasa Raharja - {{ $title ?? '' }}</title>
        <script type="text/javascript">
            var base_url = "{{ url('/') }}";
        </script>
        <!-- Favicon -->
        <link href="{{ asset('storage/jasaraharja.png') }}" rel="icon" type="image/png">
        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
        <!-- Icons -->
        <link href="{{ asset('assets') }}/vendor/nucleo/css/nucleo.css" rel="stylesheet">
        <link href="{{ asset('assets') }}/vendor/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
        <!-- Argon CSS -->

        <!-- UIkit CSS -->
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/css/uikit.min.css" />
        <link href="{{ asset('assets') }}/vendor/datatable/dataTables.bootstrap4.min.css" rel="stylesheet">
        <link type="text/css" href="{{ asset('assets') }}/css/argon.css?v=1.0.0" rel="stylesheet">
        <link type="text/css" href="{{ asset('assets') }}/css/custom.css?v=1.7" rel="stylesheet">

        <!-- Datepicker CSS -->
        <link href="{{ asset('assets') }}/vendor/datetimepicker/tempusdominus-bootstrap-4.min.css" rel="stylesheet">
        <link href="{{ asset('assets') }}/css/fontawesome.min.css" rel="stylesheet">

        <link href="{{ asset('/vendor/select2-develop/dist/css/select2.min.css') }}" rel="stylesheet">
        <link href="{{ asset('/vendor/select2-bootstrap4-theme-master/dist/select2-bootstrap4.min.css') }}" rel="stylesheet">
        {{-- <link type="text/css" href="{{ asset('assets') }}/vendor/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css" rel="stylesheet"> --}}
        @stack('css')
    </head>
    <body class="{{ $class ?? '' }}"  onload="startTime()">
        {{-- swal2 --}}

        {{-- end swal 2 --}}
        {{-- BLOCK UI --}}
        {{-- <div id="loading" style="display: none;">
            <div class="lds-ripple">
                <div></div>
                <div></div>
            </div>
            <br/>
            <span style="color: #C0B6AC;">Loading...</span>
        </div> --}}
        {{-- end block ui  --}}
        @auth()
            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                @csrf
            </form>
            @include('admin.layouts.navbars.sidebar')
        @endauth

        <div class="main-content">
            @include('admin.layouts.navbars.navbar')
            @auth
                @include('admin.layouts.headers.cards')
                <div class="container-fluid mt--11 mt-sm--10">
            @endauth
                @yield('content')
                @auth()
                    @include('admin.layouts.footers.auth')
                    </div>
                @endauth


        </div>

        @guest()
            @include('admin.layouts.footers.guest')
        @endguest

        @include('sweetalert::alert')

        <script src="{{ asset('assets') }}/vendor/jquery/dist/jquery.min.js"></script>
        <script src="{{ asset('assets') }}/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>


        @stack('js')
        <script src="{{ asset('/vendor/select2-develop/dist/js/select2.full.min.js') }}"></script>

        <script src="{{ asset('assets') }}/vendor/datatable/jquery.dataTables.min.js"></script>

        <script src="{{ asset('assets') }}/vendor/datatable/dataTables.bootstrap4.min.js"></script>

        <!-- ARGON JS -->
        <script src="{{ asset('assets') }}/js/argon.js?v=1.0.0"></script>

        <!-- UIkit JS -->
        <script src="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/js/uikit.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/uikit@3.9.2/dist/js/uikit-icons.min.js"></script>

        <script>
            // function startTime() {
            //     var today = new Date();
            //     var days = ['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu'];
            //     var months = ['Januari','Februari','Maret','April','Mei','Juni','Juli','Agustus','September','Oktober','November','Desember'];
            //     var D = days[today.getDay()];
            //     var M = months[today.getMonth()];
            //     var d = today.getDate();
            //     var h = today.getHours();
            //     var m = today.getMinutes();
            //     var s = today.getSeconds();
            //     m = checkTime(m);
            //     s = checkTime(s);
            //     document.getElementById('show-clock').innerHTML = D +", " + d + " " + M + "  " + h + ":" + m + ":" + s;
            //     var t = setTimeout(startTime, 500);
            // }
            // function checkTime(i) {
            //     if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
            //     return i;
            // }
        </script>
        <script type="text/javascript">
            $(document).ready(function(){
                    //stert of select2
                    $('.global-select2').each(function(){
                        var urlglobal   = base_url + '/fetch/globalfetch';
                        var id          = $(this).attr('id'); // ID dari element yang di definisikan sebagai select 2
                        var link        = $(this).attr('link') == 'globalfetch' ? urlglobal : $(this).attr('link'); // link yang ditembak untuk diambil oleh select 2
                        var t           = $(this).attr('t'); // t = table(penyamaran) ,hanya jika menggunakan global link
                        var s           = $(this).attr('s'); // s = select(penyamaran) ,hanya jika menggunakan global link
                        var placeholder = $(this).attr('placeholder') != '' ? $(this).attr('placeholder') : 'choose the option'; // placeholder
                        var allowclear = $(this).attr('required') ? false : true; // untuk menentukan dia boleh di clear atau tidak
                        var tag = $(this).attr('tags') == true ? true : false;
                        var maxselect = (typeof $(this).attr('maxs') !== "undefined") ? (($(this).attr('maxs') != '') ? $(this).attr('maxs') : 1000) : 1000; //untuk memberi rule , maksimal value yg di select hanya sejumlah berapa
                        var exception = (typeof $(this).attr('exception') !== "undefined") ? $(this).attr('exception') : '';
                        var onlyin    = (typeof $(this).attr('onlyin') !== "undefined") ? $(this).attr('onlyin') : '';
                        var w = new Array();
                        var exceptid = exception != '' ? getvaluefrom(exception) : '';
                        var onlyinid = onlyin != '' ? getvaluefrom(onlyin) : '';
                        var indextones = 'select-index-1';

                        if (typeof link === "undefined") {
                            link = '#';
                        }

                        if (typeof placeholder === "undefined") {
                            placeholder = 'choose the option';
                        }

                        if (typeof s === "undefined") {
                            w = [];
                        } else {
                            if (s != '' && typeof s.split(',')[1] === 'undefined') {
                                indextones = 'select-index-1';
                            }else{
                                indextones = s.split(',')[1];
                            }
                            var w     = [
                                                           {field:indextones , operator:'LIKE' , value:'-NMSearch-'} //NMSearch untuk di replace dengan keyword
                                       ];
                        }
                        var parameters = {
                            'q': '',
                            't': t,
                            's': s,
                            'w': w,
                        };
                        // if (destroy == true) {
                        // $('#'+id).select2('destroy');
                        // }else{
                        if (link != '#') {
                            $('#' + id).select2({
                                tokenSeparators: [','],
                                allowClear: allowclear,
                                theme: 'bootstrap4',
                                placeholder: placeholder,
                                maximumSelectionLength: maxselect,
                                ajax: {
                                    url: link,
                                    dataType: 'json',
                                    type: 'post',
                                    data: function(params) {
                                        if (exception != '') {
                                            // $('#'+id).on('select2:opening',function(e){
                                            exceptid = getvaluefrom(exception);
                                            // })
                                        }
                                        if (onlyin != '') {
                                            // $('#'+id).on('select2:opening',function(e){
                                            onlyinid = getvaluefrom(onlyin);
                                            // })
                                        }
                                        return {
                                            "_token": $('meta[name="csrf-token"]').attr('content'),
                                            q: params.term, // search term
                                            page: params.page,
                                            parameter: parameters,
                                            except: exceptid,
                                            onlyin: onlyinid,
                                        };
                                    },
                                    processResults: function(data, params) {
                                        return {
                                            results: data.item
                                        }
                                    },
                                    cache: true
                                },
                                tags: tag,
                                tokeSparator: [','],
                                escapeMarkup: function(markup) { return markup; }, // let our custom formatter work
                                minimumInputLength: 0,
                                templateResult: formatResult, // omitted for brevity, see the source of this page
                                templateSelection: formatResult // omitted for brevity, see the source of this page
                            });
                        } else {
                            $('#' + id).select2({
                                allowClear: allowclear,
                                theme: 'bootstrap4',
                                placeholder: placeholder,
                            });
                        }
                        // }
                    });

                    function formatResult(result) {
                        return result.text;
                    }

                    //end of select2
            });
        </script>
    </body>
</html>
