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/comfama.sports-crowd.com/public/js/events.js
var specialTicketId;

let matchEventId;
$(document).on('ready', function () {
    matchEventId = document.location.href.match(/[0-9]+/)[0];
});

function create() {
    $("#form_create").validator("update");
    $("#form_create")
        .validator("update")
        .on("submit", function (e) {
            if (e.isDefaultPrevented()) {
            } else {
                e.preventDefault();

                var season_id = $('#form_create').attr('season_id');
                var team_id = $("#form_create select[name='team_id']").val();
                var event_start = $("#form_create input[name='event_start']").val();
                event_start = event_start.replace("T", " ");

                var event_start_sale = $("#form_create input[name='event_start_sale']").val();
                event_start_sale = event_start_sale.replace("T", " ");

                var event_end_sale = $("#form_create input[name='event_end_sale']").val();
                event_end_sale = event_end_sale.replace("T", " ");

                if (!season_id || season_id == "0") {
                    swal(Lang.get("messagesClient.events.tag_3"), {
                        icon: "error",
                    });
                    return;
                }

                if (!team_id || team_id == "0") {
                    swal(Lang.get("messagesClient.events.tag_4"), {
                        icon: "error",
                    });
                    return;
                }

                var salesType = $("#form_create select[name='sales_type']").val();
                if (!salesType || salesType == "0") {
                    swal(Lang.get("messagesClient.events.sales_type_required"), {
                        icon: "error",
                    });
                    return;
                }

                var stadium = $("#form_create select[name='stadium']").val();
                if (!stadium || stadium == "0") {
                    swal(Lang.get("messagesClient.events.stadium_required"), {
                        icon: "error",
                    });
                    return;
                }

                var info = {
                    season_id,
                    team_id,
                    name: $("#form_create input[name='name']").val(),
                    date_name: $("#form_create input[name='date_name']").val(),
                    event_start,
                    event_start_sale,
                    event_end_sale,
                    zone_id: stadium,
                    active: $("#form_create select[name='active']").val(),
                    tags: $("#form_create select[name='generalMultiselect']").val(),
                    sales_type: salesType,
                };

                $("#btn-create").addClass("displayNone");
                $("#spinnerButton").removeClass("displayNone");

                swal(Lang.get("messagesClient.events.tag_1"), {
                    buttons: {
                        cancel: "No",
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        $.ajax({
                            url: `/season/${season_id}/event`,
                            type: "POST",
                            contentType: "application/json",
                            headers: {
                                "X-CSRF-TOKEN": $(
                                    'meta[name="csrf-token"]'
                                ).attr("content"),
                                "Content-Type": "application/json",
                            },
                            data: JSON.stringify(info),
                            success: function (r) {
                                if (r.r) {
                                    swal(r.m, {
                                        icon: "success",
                                        buttons: {
                                            Ok: true,
                                        },
                                    }).then((val) => {
                                        if (val == "Ok") {
                                            $(location).attr("href", `/season/${season_id}/event`);
                                        }
                                    });
                                } else {
                                    swal("Error", r.m, "error");
                                    $("#btn-create").removeClass("displayNone");
                                    $("#spinnerButton").addClass("displayNone");
                                }
                            },
                            error: function (e) {
                                swal("Error", "¡Hubo un Error al crear!", "error");
                                $("#btn-create").removeClass("displayNone");
                                $("#spinnerButton").addClass("displayNone");
                            },
                        });
                    } else {
                        $("#btn-create").removeClass("displayNone");
                        $("#spinnerButton").addClass("displayNone");
                    }
                });
            }
        });
}

function clickEdit(event_id, season_id) {
    $(location).attr("href", `/season/${season_id}/event/${event_id}/edit`);
}

function clickInfoEvent(value) {
    $(location).attr("href", "/events/tickets/" + value + "/info");
}

function clickInfoBlocks(value) {
    $(location).attr("href", "/events/tickets/" + value + "/blocks");
}

function clickInfoBlockList(value) {
    $(location).attr("href", "/events/tickets/" + value + "/block/info");
}

function eventPrice(value) {
    $(location).attr("href", "/event_prices/" + value + "/list");
}

function clickMatchEventStage(value) {
    $(location).attr("href", `/event/${value}/stage`);
}

function edit() {
    $("#form_edit").validator("update");
    $("#form_edit")
        .validator("update")
        .on("submit", function (e) {
            if (e.isDefaultPrevented()) {
            } else {
                e.preventDefault();

                var season_id = $('#form_edit').attr('season_id');
                var team_id = $("#form_edit select[name='team_id']").val();
                var event_start = $("#form_edit input[name='event_start']").val();
                event_start = event_start.replace("T", " ");

                var event_start_sale = $("#form_edit input[name='event_start_sale']").val();
                event_start_sale = event_start_sale.replace("T", " ");

                var event_end_sale = $("#form_edit input[name='event_end_sale']").val();
                event_end_sale = event_end_sale.replace("T", " ");

                if (!season_id || season_id == "0") {
                    swal(Lang.get("messagesClient.events.tag_3"), {
                        icon: "error",
                    });
                    return;
                }

                if (!team_id || team_id == "0") {
                    swal(Lang.get("messagesClient.events.tag_4"), {
                        icon: "error",
                    });
                    return;
                }

                var salesType = $("#form_edit select[name='sales_type']").val();
                if (!salesType || salesType == "0") {
                    swal(Lang.get("messagesClient.events.sales_type_required"), {
                        icon: "error",
                    });
                    return;
                }

                var stadium = $("#form_edit select[name='stadium']").val();
                if (!stadium || stadium == "0") {
                    swal(Lang.get("messagesClient.events.stadium_required"), {
                        icon: "error",
                    });
                    return;
                }

                var info = {
                    _method: $("input[name=_method]").val(),
                    season_id,
                    team_id,
                    name: $("#form_edit input[name='name']").val(),
                    date_name: $("#form_edit input[name='date_name']").val(),
                    event_start,
                    event_start_sale,
                    event_end_sale,
                    zone_id: stadium,
                    active: $("#form_edit select[name='active']").val(),
                    tags: $("#form_edit select[name='generalMultiselect']").val(),
                    sales_type: salesType,
                };

                var id = $("#form_edit").attr("event_id");

                $("#btn-edit").addClass("displayNone");
                $("#spinnerButton").removeClass("displayNone");

                swal(Lang.get("messagesClient.events.tag_2"), {
                    buttons: {
                        cancel: "No",
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        $.ajax({
                            url: `/season/${season_id}/event/${id}`,
                            type: "PUT",
                            contentType: "application/json",
                            headers: {
                                "X-CSRF-TOKEN": $(
                                    'meta[name="csrf-token"]'
                                ).attr("content"),
                                "Content-Type": "application/json",
                            },
                            data: JSON.stringify(info),
                            success: function (r) {
                                if (r.r) {
                                    swal(r.m, {
                                        icon: "success",
                                        buttons: {
                                            Ok: true,
                                        },
                                    }).then((val) => {
                                        if (val == "Ok") {
                                            $(location).attr("href", `/season/${season_id}/event`);
                                        }
                                    });
                                } else {
                                    swal("Error", r.m, "error");
                                    $("#btn-edit").removeClass("displayNone");
                                    $("#spinnerButton").addClass("displayNone");
                                }
                            },
                            error: function (e) {
                                swal("Error", "¡Hubo un Error al actualizar!", "error");
                                $("#btn-edit").removeClass("displayNone");
                                $("#spinnerButton").addClass("displayNone");
                            },
                        });
                    } else {
                        $("#btn-edit").removeClass("displayNone");
                        $("#spinnerButton").addClass("displayNone");
                    }
                });
            }
        });
}

/**Activar/Desactivar torneo usando switch*/
function chk(value) {
    var state;
    if ($("#Checkactive" + value).is(":checked")) {
        state = 1;
    } else {
        state = 0;
    }

    var info = {
        id: value,
        state: state,
    };

    $.ajax({
        url: "/events/active",
        type: "POST",
        contentType: "application/json",
        headers: {
            "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            "Content-Type": "application/json",
        },
        data: JSON.stringify(info),
        success: function (r) {
            if (r.r) {
                swal("Ok", r.m);
            } else {
                swal("Error", r.m, "error");
            }
        },
        error: function (e) {
            swal(
                "Error",
                Lang.get("messagesClient.events.error_update_image"),
                "error"
            );
        },
    });
}

/**Método para eliminar banner*/
function clickDelete(event_id, season_id) {
    swal(Lang.get("messagesClient.events.tag_6"), {
        buttons: {
            cancel: "No",
            Ok: true,
        },
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                _method: "DELETE",
            };

            $.ajax({
                url: `/season/${season_id}/event/${event_id}`,
                type: "POST",
                contentType: "application/json",
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                        "content"
                    ),
                    "Content-Type": "application/json",
                },
                data: JSON.stringify(info),
                success: function (r) {
                    if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr("href", `/season/${season_id}/event`);
                            }
                        });
                    } else {
                        swal(r.m, { icon: "error" });
                    }
                },
                error: function (e) {
                    swal(
                        "Error",
                        Lang.get("messagesClient.events.error_delete"),
                        "error"
                    );
                },
            });
        }
    });
}

function changeSeat(ticket_id, match_event_id) {
    // Obtener las sillas actuales.
    $('#modal-change-seat').modal('show');
    $('#modal-change-seat').data('ticket_id', ticket_id);
    $('#modal-change-seat').data('match_event_id', match_event_id);

    loadTribunes();
}

function loadTribunes() {
    calculateDestino();
    $.ajax({
        url: "/tickets/tribunes",
        method: "GET",
        success: function (data) {
            clearScreenSeatChange();

            data.forEach(element => {
                let optionText = element.name;
                let optionValue = element.id;

                $('#tribune_id').append(`<option value="${optionValue}">${optionText}</option>`);
            });
        }
    });
}

function clearScreenSeatChange() {
    $('#tribune_id')
        .find('option')
        .remove()
        .end()
        .append('<option value="">--Seleccione</option>')
        .val('');

    $('#zone_id')
        .find('option')
        .remove()
        .end()
        .append('<option value="">--Seleccione</option>')
        .val('');

    $('#seat_id')
        .find('option')
        .remove()
        .end()
        .append('<option value="">--Seleccione</option>')
        .val('');

    calculateDestino();
}

function loadSubZones() {
    let tribune_id = $('#tribune_id').val();
    $('#seat_id')
        .find('option')
        .remove()
        .end()
        .append('<option value="">--Seleccione</option>')
        .val('');
    calculateDestino();


    $.ajax({
        url: `/tickets/getTribunesByZone/${tribune_id}`,
        dataType: "json",
        processData: false,
        contentType: false,
        success: function (data) {
            $('#zone_id')
                .find('option')
                .remove()
                .end()
                .append('<option value="">--Seleccione</option>')
                .val('');

            data.data.forEach(element => {
                let optionText = element.name;
                let optionValue = element.id;

                $('#zone_id').append(`<option value="${optionValue}">${optionText}</option>`);
            });
        }
    });
}

function loadSeats() {
    let zone_id = $('#zone_id').val();
    let match_event_id_origin = $('#modal-change-seat').data('match_event_id');
    calculateDestino();

    $.ajax({
        url: `/tickets/getSeatFreeByZone/${zone_id}/${match_event_id_origin}`,
        dataType: "json",
        processData: false,
        contentType: false,
        success: function (data) {
            $('#seat_id')
                .find('option')
                .remove()
                .end()
                .append('<option value="">--Seleccione</option>')
                .val('');

            data.data.forEach(element => {
                let optionText = `${element.letter.name}${element.code}`;
                let optionValue = element.id;

                $('#seat_id').append(`<option value="${optionValue}">${optionText}</option>`);
            });
        }
    });
}

function finishSelectionSeat() {
    calculateDestino();
}

function calculateDestino() {
    let tribune_id = $('#tribune_id').find(":selected").text();
    let zone_id = $('#zone_id').find(":selected").text();
    let seat_id = $('#seat_id').find(":selected").text();
    let labelDestino = $('#labelDestino');
    let textDestino = `${tribune_id} - ${zone_id} - ${seat_id}`;

    labelDestino.text(`Silla destino: ${textDestino}`)
}

function getConfirmationSeatChangeTickets() {
    let tribune_id = $('#tribune_id').val();
    let zone_id = $('#zone_id').val();
    let seat_id = $('#seat_id').val();
    let ticket_id_origin = $('#modal-change-seat').data('ticket_id');
    let match_event_id_origin = $('#modal-change-seat').data('match_event_id');

    // Se obtienen para informar los tickets que se modificaran del usuario, adicional se valida si el cambio es posible.
    $.ajax({
        url: `/tickets/getPendingMatchesTickets/${ticket_id_origin}/${tribune_id}/${zone_id}/${seat_id}`,
        method: "GET",
        success: function (data) {
            let msgSwal = "";

            data.forEach(elem => {
                msgSwal = msgSwal + `* (${elem.match_event.date_name}) ${elem.match_event.name} ${elem.code_ticket} - ${elem.door} - ${elem.zone} - ${elem.letter_seat}${elem.code_seat}` + "\n\n";
            });

            swal(msgSwal, {
                title: "Se han encontrado los siguientes tickets:",
                icon: "success",
                buttons: {
                    Ok: "Si, Continuar",
                    cancel: "Cancelar"
                },
            }).then((val) => {
                if (val == "Ok") {
                    postChangesChangeSeat(ticket_id_origin, seat_id);
                }
            });
        }
    });
}

function postChangesChangeSeat(ticket_id_origin, seat_id_final) {
    const data = {
        ticket_id_origin,
        seat_id_final
    };

    $.ajax({
        url: "/tickets/changeMassiveTicketSeat",
        method: "POST",
        data: JSON.stringify(data),
        contentType: "application/json",
        headers: {
            "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            "Content-Type": "application/json",
        },
        success: function (data) {
            if (data.r) {
                swal(data.m, {
                    icon: "success",
                    buttons: {
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        window.location.reload();
                    }
                });
            } else {
                swal("Error", data.m, "error");
            }
        }
    })
}

function changeStateTicket(ticket_id, match_event_id) {
    swal("Cambiar estado: 3. Anulado 4. Reversado", {
        content: {
            element: "input",
            attributes: {
                placeholder: "Ingresa el código del estado",
                type: "text",
            },
        },
    }).then((state_id) => {
        if (state_id != "3" && state_id != "4") {
            swal({
                title: "Selecciona un valor correcto",
                icon: "error",
            });
            return;
        }
        swal(Lang.get("messagesClient.events.tag_7"), {
            buttons: {
                cancel: "No",
                Ok: true,
            },
        }).then((val) => {
            if (val == "Ok") {
                let info = { ticket_id, state_id: parseInt(state_id) };
                $.ajax({
                    url: "/tickets/changeState",
                    type: "POST",
                    contentType: "application/json",
                    headers: {
                        "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                            "content"
                        ),
                        "Content-Type": "application/json",
                    },
                    data: JSON.stringify(info),
                    success: function (r) {
                        if (r.r) {
                            swal(r.m, {
                                icon: "success",
                                buttons: {
                                    Ok: true,
                                },
                            }).then((val) => {
                                if (val == "Ok") {
                                    $(location).attr(
                                        "href",
                                        `/events/tickets/${match_event_id}/info`
                                    );
                                }
                            });
                        } else {
                            swal("Error", r.m, "error");
                            $("#btn-edit").removeClass("displayNone");
                            $("#spinnerButton").addClass("displayNone");
                        }
                    },
                    error: function (e) {
                        swal("Error", "¡Hubo un Error al actualizar!", "error");
                        $("#btn-edit").removeClass("displayNone");
                        $("#spinnerButton").addClass("displayNone");
                    },
                });
            } else {
                $("#btn-edit").removeClass("displayNone");
                $("#spinnerButton").addClass("displayNone");
            }
        });
    });
}

/** Método para validar tickets */
function validateTickets(value, season_id) {
    swal("¿Estás seguro de generar estas boletas?", {
        buttons: {
            cancel: "No",
            Ok: true,
        },
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                ticket_main_id: value,
            };
            $.ajax({
                url: "/events/validateTicket",
                type: "POST",
                contentType: "application/json",
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                        "content"
                    ),
                    "Content-Type": "application/json",
                },
                data: JSON.stringify(info),
                success: function (r) {
                    if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr("href", `/season/${season_id}/event`);
                            }
                        });
                    } else {
                        swal(r.m, { icon: "error" });
                    }
                },
                error: function (e) {
                    swal(
                        "Error",
                        Lang.get("messagesClient.events.error_delete"),
                        "error"
                    );
                },
            });
        }
    });
}

/** Método de notificacion email */
function sendEmailNotifications(value, id_event, code_tickets) {
    swal("¿Estás seguro de enviar correo?", {
        buttons: {
            cancel: "No",
            Ok: true,
        },
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                id_user: value,
                code_ticket: code_tickets,
            };
            $.ajax({
                url: "/events/sendEmailNotifications",
                type: "POST",
                contentType: "application/json",
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                        "content"
                    ),
                    "Content-Type": "application/json",
                },
                data: JSON.stringify(info),
                success: function (r) {
                    if (r.r) {
                        swal("Correo enviado", {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        });
                    } else {
                        swal(r.m, { icon: "error" });
                    }
                },
                error: function (e) {
                    swal(
                        "Error",
                        Lang.get("messagesClient.events.tag_9"),
                        "error"
                    );
                },
            });
        }
    });
}

function clickDeleteBackups(match_event_id) {
    swal({
        icon: "warning",
        text: 'Se eliminará todos los tickets backups para este evento, ¿Desea continuar?',
        buttons: {
            cancel: 'Cancelar',
            ok: {
                text: "Continuar",
                closeModal: false,
            },
        },
        closeOnClickOutside: false,
        closeOnEsc: false
    })
        .then(value => {
            if (value == "ok") {
                $.ajax({
                    url: "/events/deleteBackups/" + match_event_id,
                    type: "GET",
                    contentType: "application/json",
                    headers: {
                        "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                            "content"
                        ),
                        "Content-Type": "application/json",
                    },
                    success: function (r) {
                        if (r.r) {
                            swal("Proceso exitoso", r.m, {
                                icon: "success",
                                buttons: {
                                    Ok: true,
                                },
                            });
                        } else {
                            swal("Ops...", r.m, {
                                icon: "error",
                                buttons: {
                                    Ok: true,
                                },
                            });
                        }
                    },
                });
            }
        })
        .catch(err => {
            if (err) {
                swal("Ops...", "Ocurrió un error", "error");
            } else {
                swal.stopLoading();
                swal.close();
            }
        });
}

function getTicketsUserid(dataId, emailError, ticketid, code_ticket, ticketRelatedDocument) {

    if (!ticketRelatedDocument) {
        swal({
            icon: "warning",
            text: 'Correo que no tiene la cedula registrada',
            buttons: {
                ok: {
                    text: "Continuar",
                    closeModal: true,
                },
            }
        })
            .then(value => {
                if (value == "ok") {

                    $('#modal_tickets_valid').modal('show');
                    $("#result").html("<div class='alert alert-dismissible alert-danger' id='emailError'>Boleta con el siguiente correo  <strong>'" + emailError + "'</strong> </div>");
                    $("#resultInput").html("<input type='hidden' class='alert alert-dismissible alert-danger' id='ticketRelatedDocument' value='" + ticketRelatedDocument + "'data-options='" + dataId + "'data-id-evenst='" + ticketid + "'data-id-code='" + code_ticket + "'DISABLED>");
                    $('#resultInput').hide();

                }
            })
    } else {
        $('#modal_tickets_valid').modal('show');
        $("#result").html("<div class='alert alert-dismissible alert-danger' id='emailError'>Boleta con el siguiente correo  <strong>'" + emailError + "'</strong> </div>");
        $("#resultInput").html("<input type='hidden' class='alert alert-dismissible alert-danger' id='ticketRelatedDocument' value='" + ticketRelatedDocument + "'data-options='" + dataId + "'data-id-evenst='" + ticketid + "'data-id-code='" + code_ticket + "'DISABLED>");
        $('#resultInput').hide();

    }
}

function searchUser() {
    var document_search = $("#document_search").val();
    $("#user_id").val("0");
    $("#first_name").val("");
    $("#last_name").val("");
    $("#phone").val("");
    $("#email_user").val("");
    if (document_search && document_search != "") {
        $.ajax({
            url: "/tickets/users/" + document_search,
            type: "GET",
            contentType: "application/json",
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                "Content-Type": "application/json",
            },
            success: function (r) {
                if (r.r) {
                    $("#container_data_user").removeClass("displayNone");
                    $("#document").val(document_search);
                    var current_user = r.data;
                    let contentHtml = "";
                    $("#emailUser").html();
                    if (current_user) {
                        for (var i = 0; i < current_user.length; i++) {
                            $("#emailUser").html();
                            contentHtml = contentHtml + "<div> <label class='container' style='background:#ddd; text-align: center;' > <input type='radio' id='infoUser" + i + "' name='infoUser' value='" + current_user[i].document + "'data-options='" + current_user[i].id + "' > <label for='email'>" + current_user[i].email + " </label>    </label> </div>";
                            $("#button_edi_user").prop("disabled", false);
                        }
                        $("#emailUser").html(contentHtml);
                    } else {
                        $("#button_edi_user").prop("disabled", true);
                    }
                }
            }
        });
    } else {
        swal("Advertencia", "¡Debes ingresar un documento valido!", "warning");
    }
}

function editUserTicket() {
    let userSelected;
    let idSelected;
    let cont = 0;

    do {
        userSelected = $("input[id=infoUser" + cont + "]");
        idSelected = $("input[id=infoUser" + cont + "]").data("options");

        cont++;
    }
    while (userSelected && userSelected.is(':checked') == false)

    var markedUserDocument = userSelected.val();

    if (markedUserDocument) {
        var user_document = $("input[id='ticketRelatedDocument']").val();
        if (markedUserDocument == user_document) {
            var info = {
                userIdError: $("input[id='ticketRelatedDocument']").data('options'),
                usertIdValid: idSelected,
                document: markedUserDocument,
                id_event: $("input[id='ticketRelatedDocument']").data('id-evenst'),
                id_code: $("input[id='ticketRelatedDocument']").data('id-code'),
            };
            swal(Lang.get("messagesClient.user_ticket_change.tag_2"), {
                buttons: {
                    cancel: "No",
                    Ok: true,
                },
            }).then((val) => {
                if (val == "Ok") {
                    $.ajax({
                        url: "/tickets/toUpdateUsersWithTickets",
                        type: "PUT",
                        contentType: "application/json",
                        headers: {
                            "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                                "content"
                            ),
                            "Content-Type": "application/json",
                        },
                        data: JSON.stringify(info),
                        success: function (r) {
                            if (r.r) {
                                swal(Lang.get("messagesClient.user_ticket_change.tag_3"), {
                                    icon: "success",
                                    timer: 1700,
                                    showConfirmButton: false,
                                    buttons: false,
                                });

                                // $(location).attr('href', '/tickets');
                            } else {
                                swal("Error", r.m, "error");
                                $("#button_edi_user").removeClass("displayNone");
                                $("#spinnerButton").addClass("displayNone");
                            }
                        },
                        error: function (e) {
                            swal(Lang.get("messagesClient.user_ticket_change.tag_1"), "error");
                            $("#button_edi_user").removeClass("displayNone");
                            $("#spinnerButton").addClass("displayNone");
                        },
                    });
                } else {
                    $("#button_edi_user").removeClass("displayNone");
                    $("#spinnerButton").addClass("displayNone");
                }
            });
        } else {

            swal(Lang.get("messagesClient.user_ticket_change.tag_4"), {
                text: "Al parecer son diferentes documentos, por favor validar!",
                icon: 'warning',
                showCancelButton: true,
                cancelButtonColor: '#d33',
            });

        }
        // var document = $('input[id=infoUser]').data("options");

    }

    // .then((result) => {
    //     if (result.isConfirmed) {
    //       Swal.fire(
    //         'Deleted!',
    //         'Your file has been deleted.',
    //         'success'
    //       )
    //     }
    //   })

    // var document = $('input[name=emailUser]').val();
    //  var document = $('input[name=infoUser]').val();

    // if(document){
    // var info = {
    //     user_id: $("#form_sell_checkout input[name='user_id']").val(),
    //     first_name: $("#form_sell_checkout input[name='first_name']").val(),
    //     last_name: $("#form_sell_checkout input[name='last_name']").val(),
    //     document: $("#form_sell_checkout input[name='document']").val(),
    //     phone: $("#form_sell_checkout input[name='phone']").val(),
    //     email: $("#form_sell_checkout input[name='email_user']").val(),
    // };

    // swal(Lang.get("messagesClient.tickets.tag_2"), {
    //     buttons: {
    //         cancel: "No",
    //         Ok: true,
    //     },
    // }).then((val) => {
    //     if (val == "Ok") {
    //         $.ajax({
    //             url: "/tickets/updater",
    //             type: "PUT",
    //             contentType: "application/json",
    //             headers: {
    //                 "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
    //                     "content"
    //                 ),
    //                 "Content-Type": "application/json",
    //             },
    //             data: JSON.stringify(info),
    //             success: function (r) {
    //                 if (r.r) {
    //                     swal(Lang.get("messagesClient.tickets.tag_3"), {
    //                         icon: "success",
    //                         timer: 1700,
    //                         showConfirmButton: false,
    //                         buttons: false,
    //                     });

    //                     // $(location).attr('href', '/tickets');
    //                 } else {
    //                     swal("Error", r.m, "error");
    //                     $("#button_edi_user").removeClass("displayNone");
    //                     $("#spinnerButton").addClass("displayNone");
    //                 }
    //             },
    //             error: function (e) {
    //                 swal(Lang.get("messagesClient.tickets.tag_1"), "error");
    //                 $("#button_edi_user").removeClass("displayNone");
    //                 $("#spinnerButton").addClass("displayNone");
    //             },
    //         });
    //     } else {
    //         $("#button_edi_user").removeClass("displayNone");
    //         $("#spinnerButton").addClass("displayNone");
    //     }
    // });
    //    }
}

function importMatchEventSeats() {
    var archivo = document.getElementById("fileImportMatchEventSeats");
    var t = $("#example22").DataTable();
    var state;
    archivo = archivo.files[0];
    t.clear().draw();

    if (archivo) {
        var formData = new FormData();
        formData.append("archivo", archivo);
        formData.append("matchEventId", matchEventId);
        $("#buttonImportMatchEventSeats").addClass("displayNone");
        $("#spinnerButtonMatchEventSeats").removeClass("displayNone");
        $.ajax({
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            data: formData,
            url: "/tickets/importMatchEventSeats",
            success: function (r) {
                if (r.d != null) {
                    if (r.d.length > 0) {
                        for (var i = 0; i < r.d.length; i++) {
                            t.row.add({
                                message: r.d[i].message,
                                line: r.d[i].line,
                            });
                            message = r.d[i].message;
                            state = r.d[i].state;
                        }
                        if (state == false) {
                            $('#logModal').modal("show");
                            t.draw();
                        }
                    } else if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr("href", `/events/tickets/${matchEventId}/info`);
                            }
                        });
                    }
                } else {
                    swal("Error", "¡Error al subir el archivo!", "error");
                    $("#buttonImportMatchEventSeats").removeClass("displayNone");
                    $("#spinnerButtonMatchEventSeats").addClass("displayNone");
                }
            },
        });
    } else {
        swal("Ok", "¡No hay archivo!", "warning");
    }
}


function importMatchEventSpecialText() {
    var archivo = document.getElementById("fileImportMatchEventSpecialText");
    var t = $("#example22").DataTable();
    var state;
    archivo = archivo.files[0];
    t.clear().draw();

    if (archivo) {
        var formData = new FormData();
        formData.append("archivo", archivo);
        formData.append("matchEventId", matchEventId);
        $("#buttonImportMatchEventSpecialText").addClass("displayNone");
        $("#spinnerButtonMatchEventSpecialText").removeClass("displayNone");
        $.ajax({
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            data: formData,
            url: "/tickets/importMatchEventSpecialText",
            success: function (r) {
                if (r.d != null) {
                    if (r.d.length > 0) {
                        for (var i = 0; i < r.d.length; i++) {
                            t.row.add({
                                message: r.d[i].message,
                                line: r.d[i].line,
                            });
                            message = r.d[i].message;
                            state = r.d[i].state;
                        }
                        if (state == false) {
                            $('#modalMassiveLoadSpecialTextInTickets').modal("hide");
                            $('#logModal').modal("show");
                            t.draw();
                        }
                    } else if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr("href", `/events/tickets/${matchEventId}/info`);
                            }
                        });
                    }
                } else {
                    swal("Error", "¡Error al subir el archivo!", "error");
                    $("#buttonImportMatchEventSpecialText").removeClass("displayNone");
                    $("#spinnerButtonMatchEventSpecialText").addClass("displayNone");
                }
            },
        });
    } else {
        swal("Ok", "¡No hay archivo!", "warning");
    }
}

function alertLogMatchEventSeats() {
    $(location).attr("href", `/events/tickets/${matchEventId}/info`);
}

function specialTicketModalClick(value) {
    specialTicketId = value;
}

function generateSpecialTickets() {
    $("#createSpecialTickets").validator("update");

    var info = {
        special_text: $('#special_text').val(),
        amount: $("#createSpecialTickets input[name='amount']").val(),
        ticket_id: specialTicketId
    };

    if (!info.special_text || !info.amount || !info.ticket_id) {
        return;
    }

    swal(Lang.get("messagesClient.match_event_tickets.tag_1"), {
        buttons: {
            cancel: "No",
            Ok: true,
        },
    }).then((val) => {
        if (val == "Ok") {
            $.ajax({
                url: "/events/generateSpecialTickets",
                type: "POST",
                contentType: "application/json",
                headers: {
                    "X-CSRF-TOKEN": $(
                        'meta[name="csrf-token"]'
                    ).attr("content"),
                    "Content-Type": "application/json",
                },
                data: JSON.stringify(info),
                success: function (r) {
                    if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr("href", window.location.pathname);
                            }
                        });
                    } else {
                        if (r.r == false) {
                            swal("Error", r.m, "warning");
                        } else {
                            swal("Error", Lang.get("messagesClient.user_client_tag3"), "error");
                        }
                    }
                },
            });
        }
    });
}