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/report_redemptions/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>
<div class="box-header">
    <a class="btn btn-app btnReportProducts" onclick="clickExportAll()">
        <i class="fa fa-file-excel-o"></i> {{ Lang::get('messages.report_redemptions.title_export_all') }}
    </a>
</div>

<div class="box">
    <div class="box-header">
        <h3 class="box-title"><b>{{ Lang::get('messages.report_redemptions.filters') }}</b></h3>
        <div class="row">
            <div class="col-4 col-md-4">
                <label for="appValidationSections">{{ Lang::get('messages.report_redemptions.filter_app_sections')}}</label>
                <select class="form-control select2" multiple="multiple" data-placeholder="{{ Lang::get('messages.report_redemptions.placeholder_select') }}" name="appValidationSections" value="" required>
                    @foreach ($appValidationSections as $section)
                    <option value="{{ $section->id }}">{{ $section->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="col-4 col-md-4">
                <label for="from_date">{{ Lang::get('messages.report_redemptions.filter_start_date')}}</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.report_redemptions.placeholder_date') }}" name="from_date" value="" autocomplete="off">
                </div>
            </div>
            <div class="col-4 col-md-4">
                <label for="to_date">{{ Lang::get('messages.report_redemptions.filter_end_date')}}</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.report_redemptions.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.report_redemptions.title_list') }}</b></h3>
    </div>

    <table id="example2" class="stripe row-border order-column" style="width:100%" role="grid" aria-describedby="example2_info">
        <thead>
            <tr role="row">
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_1') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_4') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_2-1') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_2-2') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_2-3') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.screen_banners_tag23') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_3-1') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_3-2') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_3-3') }}</th>
                <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">{{ __('messages.report_redemptions.title_5') }}</th>
            </tr>
        </thead>
    </table>
    <!-- /.box-body -->
</div>

<script src="{{ asset('js/jQuery/jquery-2.2.3.min.js') }}"></script>
<script src="{{ asset('js/bootstrap/js/bootstrap.min.js') }}"></script>
<script type="text/javascript">
    $(document).ready(function() {
        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>';

        $('#example2_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='appValidationSections']").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();
            }
        });
        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();
            }
        });

    });

    function getData() {
        let appValidationSections = $("select[name='appValidationSections']").val();
        let from_date = $("input[name='from_date']").val();
        let to_date = $("input[name='to_date']").val();
        var sort_col = $('#example2').find("th:contains(" + Lang.get("messages.report_redemptions.title_5") + ")")[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: 1
            };
        }

        $("#example2").dataTable().fnDestroy();
        _table = $('#example2').DataTable({
            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: {
                url: '/report_redemptions/list/' + appValidationSections + '/' + (from_date.length ? from_date : 'null') + '/' + (to_date.length ? to_date : 'null'),
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                },
                type: "POST"
            },
            columns: [{
                    data: 'name',
                    name: 'app_validation_sections.name'
                },
                {
                    data: 'options',
                    name: 'options'
                },
                {
                    data: 'first_name',
                    render: function(data, type, row) {
                        return row.first_name;
                    },
                    name: 'users.first_name' || 'academy_users.student_name'
                },
                {
                    data: 'last_name',
                    render: function(data, type, row) {
                        return row.last_name;
                    },
                    name: 'users.last_name' || 'academy_users.student_last_name'
                },
                {
                    data: 'email',
                    render: function(data, type, row) {
                        return (row.email ?? row.mail);
                    },
                    name: 'users.email'
                },
                {
                    data: 'segmentation',
                    render: function(data, type, row) {
                        let tags = '';
                        if (row.segmentation) {
                            let list = row.segmentation.split(',');
                            let data = list.map(function(d) {
                                return '<li>' + d + '</li>';
                            });
                            tags = data.join('');
                        }
                        return tags;
                    },
                    name: 'tags.name'
                },
                {
                    data: 'logged_first_name',
                    name: 'loggedUsers.first_name'
                },
                {
                    data: 'logged_last_name',
                    name: 'loggedUsers.last_name'
                },
                {
                    data: 'logged_email',
                    name: 'loggedUsers.email'
                },
                {
                    data: 'created_at',
                    name: 'created_at'
                }
            ]
        });
    }

    function clickExportAll() {
        $('#loading').show();
        _table = $("#example2").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 + "/report_redemptions/validateExport";
        var downloadUrl = document.location.origin + "/report_redemptions/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");
            }
        });
    }
</script>
@endsection