@if(!defined('LOAD_DATEPICKER'))
    @push('css')
        <link rel="stylesheet" href="/assets/plugins/daterangepicker/daterangepicker.css">
    @endpush
    @push('js')
        @include('load.moment')
        <script src="/assets/plugins/daterangepicker/daterangepicker.js"></script>
        <script src="/assets/plugins/daterangepicker/{{ App::getLocale() }}.js"></script>
        <script>

            function initDaterangepicker(sel, start, end, format) {
                var selector = (typeof(sel) == 'undefined') ? '.daterangepickerItems' : sel;
                var format = (typeof(format) == 'undefined') ? 'L' : format;
                var start = (typeof(start) == 'undefined') ? moment() : start; 
                var end = (typeof(end) == 'undefined') ? moment() : end;
                $(selector).daterangepicker({
                    alwaysShowCalendars: true,
		            autoUpdateInput: false,
                    format: dateRangePickerLanguage.format,
                    showDropdowns: true,
		            showWeekNumbers: true,
                    startDate: start,
                    endDate: end,
                    separator: dateRangePickerLanguage.separator,
            		locale: dateRangePickerLanguage.locale,
		            buttonClasses: 'btn light uppercase weight-900',
                    ranges: dateRangePickerLanguage.ranges,
                }).on("apply.daterangepicker", function (e, picker) {
                    var range = picker.startDate.format(picker.locale.format) + ' - ' + picker.endDate.format(picker.locale.format);
                    picker.element.val(range);
                });
            }
            
            function initDatetimerangepicker(sel, date, format) {
                var selector = (typeof(sel) == 'undefined') ? '.datetimerangepicker' : sel;
                var format = (typeof(format) == 'undefined') ? '' : format;
                var date = (typeof(date) == 'undefined') ? new Date() : date;  
                $(selector).daterangepicker({
                    timePicker: true,
                    locale: {
                        format: format,
                    }
                });
            }

        </script>
    @endpush
    @php(define('LOAD_DATEPICKER', true))
@endif
