<?php $__env->startSection('css'); ?>
    <?php echo $__env->make('layouts.datatables_css', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>

<?php echo $dataTable->table(['width' => '100%', 'class' => 'table table-striped table-bordered']); ?>


<?php $__env->startPush('scripts'); ?>
    <?php echo $__env->make('layouts.datatables_js', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <script>
        const columnSearch = <?php echo json_encode($dataTable->getOptions()['columns']); ?>

        const newTr = $('#dataTableBuilder thead>tr').clone();
        const localOption = <?php echo json_encode(config('local')); ?>


        _.forEach(columnSearch, (element, i, array) => {
            let _th = newTr.find('th').eq(i)
            if(!element.searchable){
                if(i === array.length -1){
                    _th.html('<div class="row"><div class="form-group col-sm-12"><button class="btn btn-primary search-btn"><i class="cil cil-search"></i></button></div></div>')
                    _th.on( 'click','button.search-btn', function () {
                        if (window.LaravelDataTables === undefined){

                            return;
                        }
                        const table = window.LaravelDataTables.dataTableBuilder
                        const _tr = _th.closest('tr')
                        const _columnSearch = []
                        _tr.find('th').not(_th).each(function(i, elm){
                            let _searchValue = []                            
                            $(elm).find('input, select').each(function(j, _input){
                                let _searchValueTmp = _input.value
                                
                                const _className = _input.className
                                if(_.includes(_className,'datetime')){
                                    _searchValueTmp = main.getValueDateSQL(_input)
                                }
                                if(_.includes(_className,'inputmask')){
                                    const _optionMask = $(_input).data('optionmask') || {}
                                    _searchValueTmp = $(_input).inputmask('unmaskedvalue')
                                    if (_optionMask.radixPoint === ',') {
                                        _searchValueTmp = _searchValueTmp.replace(',', '.')
                                    }
                                }
                                _searchValue.push(_searchValueTmp)
                            })
                            _columnSearch[i] = _.join(_searchValue,'__')
                            
                        })
                        
                        for(const i in _columnSearch){
                            table
                            .column(i)
                            .search(_columnSearch[i] )
                        }
                        table.draw()
                    })
                }else{
                    _th.html('')
                }
                
                return
            }

            _th.html(window.elementGenerator.inputSearch(element,{'localOption' : localOption}))            
        })
        main.initFormatInput($(newTr));
        $(newTr).appendTo($('#dataTableBuilder thead'));
    </script>
    <?php echo $dataTable->scripts(); ?>

<?php $__env->stopPush(); ?>
<?php /**PATH /data/docker/laravel/easyadms/resources/views/base/menus/table.blade.php ENDPATH**/ ?>