HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/demo.sports-crowd.com/resources/views/business/list.blade.php
@extends('modules.head') @section('contenido')
<style>
    /* Ensure that the demo table scrolls */
    /* th, */
    td {
        white-space: nowrap;
    }

    div.dataTables_wrapper {
        height: fit-content;
        margin: 0px 10px 0px 10px;
    }

    .dataTables_scrollBody {
        max-height: none !important;
    }
</style>
@php
$page_prefix = 'business_';
@endphp
<div class="box-header">
    <a class="btn btn-app btnReportProducts" onclick="clickExportAll()">
        <i class="fa fa-file-excel-o"></i> {{ Lang::get('messages.business.title_export_all') }}
    </a>
    <a class="auxiliar-black" href="{{ route('business.create') }}">
        <button class="btn btnAdd pull-right">
            <i style="margin-right:5px;" class="fa fa-plus"></i>{{ __('messages.business.title_1') }}
        </button>
    </a>
</div>

<div class="box">
    <div class="box-header">
        <h3 class="box-title"><b>{{ Lang::get('messages.business.filters') }}</b></h3>
        <div class="row">
            <div class="col-3 col-md-3">
                <label for="categories">{{ Lang::get('messages.business.title_17')}}</label>
                <select class="form-control select2" multiple="multiple" data-placeholder="{{ Lang::get('messages.business.placeholder_select') }}" name="categories" value="" required>
                    @foreach ($categories as $category)
                    <option value="{{ $category->id }}">{{ $category->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="col-3 col-md-3">
                <label for="ages">{{ Lang::get('messages.business.title_7')}}</label>
                <select class="form-control select2" multiple="multiple" data-placeholder="{{ Lang::get('messages.business.placeholder_select') }}" name="ages" value="" required>
                    @foreach ($ages as $age)
                    <option value="{{ $age }}">{{ $age }}</option>
                    @endforeach
                </select>
            </div>
            <div class="col-3 col-md-3">
                <label for="from_date">{{ Lang::get('messages.business.title_19-1')}}</label>
                <div class="input-group date">
                    <div class="input-group-addon">
                        <i class="fa fa-calendar"></i>
                    </div>
                    <input type="text" class="form-control pull-right" placeholder="{{ Lang::get('messages.business.placeholder_date') }}" name="from_date" value="" autocomplete="off">
                </div>
            </div>
            <div class="col-3 col-md-3">
                <label for="to_date">{{ Lang::get('messages.business.title_19-2')}}</label>
                <div class="input-group date">
                    <div class="input-group-addon">
                        <i class="fa fa-calendar"></i>
                    </div>
                    <input type="text" class="form-control pull-right" placeholder="{{ Lang::get('messages.business.placeholder_date') }}" name="to_date" value="" autocomplete="off">
                </div>
            </div>
        </div>
        <p style="margin-top: 10px; border-bottom: 1px solid #D3D3D3;"></p>
        <h3 class="box-title"><b>{{ Lang::get('messages.business.title_list') }}</b></h3>
    </div>

    <table id="{{$page_prefix}}" class="stripe row-border order-column" style="width:100%" role="grid" aria-describedby="{{$page_prefix}}_info">
        <thead>
            <tr role="row">
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_3') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_4') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_11') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_17') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_15') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_5') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_6') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_7') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_20-1') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_20-2') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_18') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_14') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_8') }}</th>
                <th class="sorting" tabindex="0" aria-controls="{{$page_prefix}}" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.business.title_9') }}</th>
            </tr>
        </thead>
    </table>
    <!-- /.box-body -->
</div>

<script src="{{ asset('js/jQuery/jquery-2.2.3.min.js') }}"></script>
<script src="{{ asset('js/business.js') . '?v=' . time() }}"></script>
<script src="{{ asset('js/bootstrap/js/bootstrap.min.js') }}"></script>
<script type="text/javascript">
    const SELECTOR_PREFIX = "{{$page_prefix}}";
    $(document).ready(function() {
        validateLocalStoreInformation();
        getData();
        var info = '<i class="fa  fa-info-circle"  id="btn-info-busqueda"></i><div class="dropdown-menu" id="menuBusqueda" style="left: 50%; padding: 5px; background-color: #f9fb8f;"><p data-toggle="modal">Busqueda por Cedula, Nombre y Correo</p></div>';

        $(`#${SELECTOR_PREFIX}_filter`).append(info);
        $('#btn-info-busqueda').on('click', function() {
            $('#menuBusqueda').toggle();
        });

        $('.select2').select2();

        $.fn.datepicker.dates['en'] = {
            days: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
            daysShort: ['Dom', 'Lun', 'Mar', 'Mié', 'Juv', 'Vie', 'Sáb'],
            daysMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
            months: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre',
                'Octubre', 'Noviembre', 'Diciembre'
            ],
            monthsShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
            today: "Hoy",
            clear: "Clear",
            format: "yyyy-mm-dd",
            titleFormat: "MM yyyy",
            weekStart: 0
        };

        $("input[name='from_date']").datepicker({
            dateFormat: 'yyyy-mm-dd'
        });
        $("input[name='to_date']").datepicker({
            dateFormat: 'yyyy-mm-dd'
        });

        $("select[name='categories']").on('change', function() {
            getData();
        });
        $("select[name='ages']").on('change', function() {
            getData();
        });

        let from_date;
        $("input[name='from_date']").on('change', function(event) {
            if ((this.value && from_date != this.value) || (!this.value && from_date)) {
                from_date = this.value;
                getData();
            } else {
                filterData("businessfilterFrom_date", this.value);
            }
        });
        let to_date;
        $("input[name='to_date']").on('change', function() {
            if ((this.value && to_date != this.value) || (!this.value && to_date)) {
                to_date = this.value;
                getData();
            } else {
                filterData("businessfilterTo_date", this.value);
            }
        });

    });

    function getData() {
        let categories = $("select[name='categories']").val();
        let ages = $("select[name='ages']").val();
        let from_date = $("input[name='from_date']").val();
        let to_date = $("input[name='to_date']").val();

        localStore(`${SELECTOR_PREFIX}_filterCategories`, categories);
        localStore(`${SELECTOR_PREFIX}_filterAges`, ages);
        localStore(`${SELECTOR_PREFIX}_filterFromDate`, from_date);
        localStore(`${SELECTOR_PREFIX}_filterToDate`, to_date);

        var sort_col = $(`#${SELECTOR_PREFIX}`).find("th:contains(" + Lang.get('messages.business.title_18') + ")")[0].cellIndex;

        let fixedColumns = false;
        let isMobileDevice = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
        if (!isMobileDevice) {
            fixedColumns = {
                left: 1,
                right: 3
            };
        }

        $(`#${SELECTOR_PREFIX}`).dataTable().fnDestroy();
        _table = $(`#${SELECTOR_PREFIX}`).DataTable({
            stateSave: true,
            stateSaveCallback: function(settings, data) {
                localStore(`DataTables_${SELECTOR_PREFIX}`, data)
            },
            stateLoadCallback: function(settings) {
                return localRetrieve(`DataTables_${SELECTOR_PREFIX}`)
            },
            responsive: true,
            processing: true,
            serverSide: true,
            order: [
                [sort_col, 'desc']
            ],
            language: {
                url: window.DATATABLES_LANGUAGE_URL,
            },
            scrollX: true,
            scrollCollapse: true,
            paging: true,
            fixedColumns: fixedColumns,
            ajax: {
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                },
                type: "POST",
                url: '/business/list',
                data: {
                    categories: categories,
                    ages: ages,
                    from_date: from_date,
                    to_date: to_date
                }
            },
            columns: [{
                    data: 'name',
                    name: 'name'
                },
                {
                    data: 'image',
                    name: 'image'
                },
                {
                    data: 'description',
                    name: 'description'
                },
                {
                    data: 'category',
                    name: 'business_categories.name'
                },
                {
                    data: 'emailClient',
                    name: 'users.email'
                },
                {
                    data: 'addressesClient',
                    name: 'addresses.direction'
                },
                {
                    data: 'phone',
                    name: 'phone'
                },
                {
                    data: 'age',
                    name: 'age'
                },
                {
                    data: 'instagram',
                    name: 'instagram'
                },
                {
                    data: 'facebook',
                    name: 'facebook'
                },
                {
                    data: 'created_at',
                    name: 'created_at'
                },
                {
                    data: 'approved',
                    name: 'approved'
                },
                {
                    data: 'active',
                    name: 'active'
                },
                {
                    data: 'actions',
                    name: 'actions'
                },
            ]
        });
    }

    function clickExportAll() {
        $('#loading').show();
        _table = $(`${SELECTOR_PREFIX}`).DataTable();
        let query = _table.ajax.json().queries[_table.ajax.json().queries.length - 1].query;
        let bindings = _table.ajax.json().queries[_table.ajax.json().queries.length - 1].bindings;
        query = query.split(' limit ')[0];

        var validateDownloadUrl = document.location.origin + "/business/validateExport";
        var downloadUrl = document.location.origin + "/business/export/";

        var formData = new FormData();
        formData.append("query", query);
        formData.append("bindings", bindings);

        $.ajax({
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            data: formData,
            url: validateDownloadUrl,
            success: function(response) {
                $('#loading').hide();
                if (response.success) {
                    window.location.assign(downloadUrl + response.data);
                } else {
                    swal("Error", response.message, "error");
                }
            },
            error: function(response) {
                $('#loading').hide();
                swal("Error", response.responseJSON ? response.responseJSON.message :
                    'Hubo un error en el servidor, espere unos segundos e intente de nuevo', "error");
            }
        });
    }

    function validateLocalStoreInformation() {
        $("select[name='categories']").select2().val(localRetrieve(`${SELECTOR_PREFIX}_filterCategories`));
        $("select[name='ages']").select2().val(localRetrieve(`${SELECTOR_PREFIX}_filterAges`));
        $("input[name='from_date']").val(localRetrieve(`${SELECTOR_PREFIX}_filterFromDate`));
        $("input[name='to_date']").val(localRetrieve(`${SELECTOR_PREFIX}_filterToDate`));
    }
</script>
@endsection