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/academy/attendances/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 = "academy_attendance_" . $type_academy;
@endphp

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

<!-- List attendances -->
<div class="box">
    <div class="box-header with-border">
        <h3 class="box-title">{{ Lang::get('messages.academy_attendances.title_list') }}</h3>
    </div>

    <div class="box">
        <div class="box-header">
            <h3 class="box-title"><b>{{ Lang::get('messages.academy_purchases.filters') }}</b></h3>
            <div class="row">
                <div class="col-3 col-md-3">
                    <label for="from_date">{{ Lang::get('messages.academy_attendances.from_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.academy_users.placeholder_date') }}" name="from_date" value="" autocomplete="off">
                    </div>
                </div>
                <div class="col-3 col-md-3">
                    <label for="to_date">{{ Lang::get('messages.academy_attendances.to_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.academy_users.placeholder_date') }}" name="to_date" value="" autocomplete="off">
                    </div>
                </div>
                <div class="col-3 col-md-3">
                    <label for="status">{{ Lang::get('messages.academy_attendances.assistance_status') }}</label>
                    <select class="form-control select2" multiple="multiple" data-placeholder="{{ Lang::get('messages.academy_users.placeholder_select') }}" name="status" value="" required>
                        @foreach ($status as $statu)
                        <option value="{{ $statu }}">{{ $statu }}</option>
                        @endforeach
                    </select>
                </div>
            </div>

            {{-- new filters --}}
            <div class="row">
                <div class="col-3 col-md-3">
                    <label for="locations">{{ config('app.location') . Lang::get('messages.academy_users.tag2') }}</label>
                    <select class="form-control select2" multiple="multiple"
                        data-placeholder="{{ Lang::get('messages.academy_schedules.select') }}"
                        name="locations" id="locations" required>
                    </select>
                </div>
                <div class="col-3 col-md-3">
                    <label for="categories">{{ Lang::get('messages.screen_banners_tag6') }}</label>
                    <select class="form-control select2" multiple="multiple"
                        data-placeholder="{{ Lang::get('messages.academy_schedules.select') }}"
                        name="categories" id ="categories" required>
                    </select>
                </div>
                <div class="col-3 col-md-3 hidden">
                    <label for="schedules">Horarios</label>
                    <select class="form-control select2" multiple="multiple"
                        data-placeholder="{{ Lang::get('messages.academy_schedules.select') }}"
                        name="schedules" id="schedules" required>
                    </select>
                </div>
                <div class="col-3 col-md-3 hidden">
                    <label for="coaches">{{ Lang::get('messages.academy_schedules.tag7') }}</label>
                    <select class="form-control select2" multiple="multiple"
                        data-placeholder="{{ Lang::get('messages.academy_schedules.select') }}"
                        name="coaches" id="coaches" required>
                    </select>
                </div>
            </div>
            {{-- end new filters --}}

            <p style="margin-top: 10px; border-bottom: 1px solid #D3D3D3;"></p>
            <h3 class="box-title"><b>{{ Lang::get('messages.assists') }}</b></h3>
        </div>

        <!-- /.box-header -->
        <div class="box-body table-responsive ">
            <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">
                            {{ Lang::get('messages.academy_attendances.tag1-1') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag1-2') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag1-3') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag1-4') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag1-5') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag2') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag7') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag3') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag4') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag5') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag8') }}
                        </th>
                        <th class="sorting" tabindex="0" aria-controls="example2" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">
                            {{ Lang::get('messages.academy_attendances.tag0') }}
                        </th>
                    </tr>
                </thead>
            </table>
        </div>
        <!-- /.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 src="{{ asset('js/filter.js') . '?v=' . time() }}"></script>

    <script type="text/javascript">
        let typeAcademy = <?php echo json_encode($type_academy); ?>;
        const SELECTOR_PREFIX = "{{$page_prefix}}";

        $(document).ready(function() {
            const existingLocationId = localStorage.getItem(`${SELECTOR_PREFIX}_filterLocations`);
            const existingCategoryId = localStorage.getItem(`${SELECTOR_PREFIX}_filterCategories`);
            const existingScheduleId = localStorage.getItem(`${SELECTOR_PREFIX}_filterSchedules`);
            const existingCoachId = localStorage.getItem(`${SELECTOR_PREFIX}_filterCoaches`);
            const existingFilteredStates = localStorage.getItem(`${SELECTOR_PREFIX}_filterStatesAux`);

            const locationRequest = getAcademyLocations(existingLocationId);
            const categoryRequest = getAcademyCategories(existingCategoryId);
            const scheduleRequest = getAcademySchedules(existingScheduleId);
            const coachRequest = getAcademyCoaches(existingCoachId);

            validateLocalStoreInformation();
            $('.select2').select2();
            
            $.when(locationRequest, categoryRequest, scheduleRequest, coachRequest).done(function() {
                if (existingLocationId || existingCategoryId || existingScheduleId || existingCoachId) {
                    restoreFilteredStates(existingFilteredStates, existingLocationId, existingCategoryId, existingScheduleId, existingCoachId);
                    cleanPagination();
                    getData();
                }else{
                    getData();
                }
            }).fail(function() {
                console.error('Alguna de las peticiones falló');
            });

            $("select[name='locations']").on('change', function(event) {
                // getAcademyCategories();
                generalFilter(event);
                cleanPagination();
                getData();
            });

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

            $.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='places']").on('change', function() {
                getData();
            });
            $("select[name='status']").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("filterFrom_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("filterTo_date", this.value);
                }
            });

            let categories = $("select[name='categories']").select2().val();
            let locations = $("select[name='locations']").select2().val();
        });

        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 + "/academy_attendances/validateExport";
            var downloadUrl = document.location.origin + "/academy_attendances/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 getData() {
            let places = $("select[name='places']").val();
            let status = $("select[name='status']").val();
            let from_date = $("input[name='from_date']").val();
            let to_date = $("input[name='to_date']").val();

            let categories = $("select[name='categories']").val();
            let locations = $("select[name='locations']").val();

            filterData("filterPlaces", places);
            filterData("filterStatus", status);
            filterData("filterFrom_date", from_date);
            filterData("filterTo_date", to_date);

            filterData(`${SELECTOR_PREFIX}_filterLocations`, locations);
            filterData(`${SELECTOR_PREFIX}_filterCategories`, categories);

            var typeAcademy = <?php echo json_encode($type_academy); ?>;

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

            $("#example2").dataTable().fnDestroy();
            _table = $('#example2').DataTable({
                responsive: true,
                processing: true,
                serverSide: true,
                order: [],
                language: {
                    url: window.DATATABLES_LANGUAGE_URL,
                },
                scrollX: true,
                scrollCollapse: true,
                paging: true,
                fixedColumns: fixedColumns,
                ajax: {
                    url: '/academy_attendances/filter/' + (from_date.length ? from_date :
                        'null') + '/' + (to_date.length ? to_date : 'null') + '/' + status + '/' + typeAcademy + '/' + categories + '/' + locations,
                    headers: {
                        "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                    },
                    type: "GET"
                },
                columns: [{
                        data: 'student_name',
                        name: 'academy_users.student_name'
                    },
                    {
                        data: 'student_last_name',
                        name: 'academy_users.student_last_name'
                    },
                    {
                        data: 'identification',
                        name: 'academy_users.identification'
                    },
                    {
                        data: 'academy_place',
                        name: 'academy_users.academy_place'
                    },
                    {
                        data: 'categoryName',
                        name: 'academy_categories.name'
                    },
                    {
                        data: 'attendance_date',
                        name: 'attendance_date'
                    },
                    {
                        data: 'dateAttendance',
                        name: 'created_at'
                    },
                    {
                        data: 'timeAttendance',
                        name: 'created_at'
                    },
                    {
                        data: 'comment',
                        name: 'comment'
                    },
                    {
                        data: 'first_name',
                        render: function(data, type, row, column) {
                            return row.last_name ? (row.first_name + ' ' + row.last_name) : row
                                .first_name;
                        },
                        name: 'users.first_name'
                    },
                    {
                        data: 'attended',
                        render: function(data, type, row, column) {
                            return row.attended ? 'Asistió' : 'No asistió';
                        },
                        name: 'attended'
                    },
                    {
                        data: 'actions',
                        name: 'actions'
                    },
                ]

            });

            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 Nombre, Orden y Link</p></div>';

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

        // Paginacion inicial
        var URLactual = window.location.href;
        document.addEventListener('click', function(e) {
            if (e.target.closest('a')) {
                var href = e.target.closest('a').href || '';
                href = href.split('#')[0];
                if (URLactual != href) {
                    // localStorage.setItem("setPaginaActual", 0);

                    // Removemos los localStorage
                    localStorage.removeItem("filterFrom_term");
                }
            }
        }, false);


        function filterData(setKey, filter) {
            localStorage.setItem(setKey, filter);
        }

        function validateLocalStoreInformation() {
            status = localStorage.getItem("filterStatus");
            places = localStorage.getItem("filterPlaces");
            from_date = localStorage.getItem("filterFrom_date");
            to_date = localStorage.getItem("filterTo_date");

            locations = localStorage.getItem(`${SELECTOR_PREFIX}_filterLocations`);
            categories = localStorage.getItem(`${SELECTOR_PREFIX}_filterCategories`);
            schedules = localStorage.getItem(`${SELECTOR_PREFIX}_filterSchedules`);
            coaches = localStorage.getItem(`${SELECTOR_PREFIX}_filterCoaches`);

            $("select[name='places']").val(places);
            $("select[name='status']").val(status);
            $("input[name='from_date']").val(from_date);
            $("input[name='to_date']").val(to_date);

            $("select[name='categories']").select2().val(categories);
            $("select[name='locations']").select2().val(locations);
            $("select[name='schedules']").select2().val(schedules);
            $("select[name='coaches']").select2().val(coaches);
        }

        let cleanPagination = function() {
            localStorage.removeItem('DataTables_example2');
        };
    </script>
    @endsection