<script src="{{ asset('assets/vendor/jquery/jquery.min.js') }}"></script>
<script src="{{ asset('assets/vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('assets/vendor/fontawesome-free/js/all.min.js') }}"></script>
<script src="{{ asset('assets/vendor/jquery-easing/jquery.easing.min.js') }}"></script>
<script src="{{ asset('assets/js/sb-admin-2.min.js') }}"></script>

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

<script src="{{ asset('assets/js/datatables.min.js') }}"></script>
<script src="{{ asset('assets/js/toastr.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/js/wizard.js') }}" type="text/javascript"></script>
<script src="https://momentjs.com/downloads/moment.js"></script>
<script>
    toastr.options = {
        "progressBar": true,
        "positionClass": "toast-top-left",
        "preventDuplicates": true,
        "onclick": null,
        "showDuration": "300",
        "hideDuration": "1000",
        "timeOut": "2000",
        "extendedTimeOut": "1000",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    }
    
    @php
        $success = '';
        if(\Session::has('success'))
            $success = \Session::get('success');

        $error = '';
        if(\Session::has('error'))
            $error = \Session::get('error');
    @endphp

    var success = "{{ $success }}";
    var error = "{{ $error }}";

    if(success != ''){
        toastr.success(success, 'Success');
        // Session::forget('Success');
        // \Session::flash('success');
    }

    if(error != ''){
        toastr.error(error, 'error');
        // $request->session()->flash('error');
        // \Session::flash('error');
    }

    @php
        $success = '';
        if(\Session::has('success'))
            \Session::forget('success');

        $error = '';
        if(\Session::has('error'))
            \Session::forget('error');
    @endphp

</script>
<script>
    function notification(){
          
             $.ajax({
                url : "{{ url('notifications/top_notify') }}",
                type : 'get',
                dataType : 'json',

                success : function(resp){
                    $("#notify_hide").css("display", "block");
                    var html = '';
                    var notify = resp.data;
                    var notification_count = resp.notification_count;

                    if(notify.length > 0){
                        jQuery.each(notify, function(key, val){ 
                           
                           html += '<li class="notify_li"><a href="'+val.notification_link+'" style=" text-decoration: none !important; color:black;"><b class="width ellipse two-lines">'+val.notification_text+'</b><span class="notify_date">'+val.created_at+'</span></a></li>';
                        });    
                    }else{
                        html += '<li class="notify_li"><b class="width ellipse two-lines">No Notification Found</b></li>';   
                    }

                    jQuery("#top_notification").empty();
                    jQuery("#top_notification").html(html);
                    
                    jQuery(".main_class_2").html(notification_count);


                    
                }
            });
            
        }
        $("body").click(function(){
            $("#notify_hide").hide();
        });

    function notification_count_get(){
        $.ajax({
            url : "{{ url('notifications/notification_count_get') }}",
            type : 'get',
            dataType : 'json',

            success : function(resp){
                var html = '';
                var notification_count = resp.notification_count;
                jQuery(".main_class_2").html(notification_count);
            }
        });            
    }

    notification_count_get();

    
</script>
@yield('scripts')