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/public/js/symbolicTickets.js
function createSymbolicTicket() {
    $("#createSymbolicTicket").validator("update");
    $("#createSymbolicTicket")
        .validator("update")
        .on("submit", function (e) {
            if (e.isDefaultPrevented()) {
            } else {
                e.preventDefault();
                var name = $("#createSymbolicTicket input[name='name']").val();
                var image = $("#createSymbolicTicket input[name='path_image']").val();
                var capacity = $("#createSymbolicTicket input[name='capacity']").val();
                var start_date = $("#createSymbolicTicket input[name='start_date']").val();
                var end_date = $("#createSymbolicTicket input[name='end_date']").val();
                var match_event_id = $("#createSymbolicTicket select[name='match_event_id']").val();
                var is_subscriber = $("#createSymbolicTicket input[name='isSubscriber']")[0].checked;

                var info = {
                    name,
                    image,
                    capacity,
                    start_date,
                    end_date,
                    match_event_id,
                    is_subscriber,
                    tags: $("#createSymbolicTicket select[name='generalMultiselect']").val()
                };

                swal(Lang.get("messagesClient.symbolic_tickets.to_create"), {
                    buttons: {
                        cancel: "No",
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        $("#btn-create-symbolic-ticket").prop("disabled", true);
                        $.ajax({
                            url: "/symbolic_tickets/add",
                            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) {
                                    var image = document.getElementById(
                                        "path_image"
                                    ).value;
                                    var data = {
                                        id: r.d,
                                    };
                                    if (image != "") {
                                        saveImage(data);
                                    } else {
                                        swal(r.m, {
                                            icon: "success",
                                            buttons: {
                                                Ok: true,
                                            },
                                        }).then((val) => {
                                            if (val == "Ok") {
                                                $(location).attr("href", "/symbolic_tickets");
                                            }
                                        });
                                    }
                                } else {
                                    swal("Error", r.m, "warning");
                                    $("#btn-create-symbolic-ticket").prop("disabled", false);
                                }
                            },
                            error: function (e) {
                                swal("Error", Lang.get("messagesClient.symbolic_tickets.error_created"), "error");
                                $("#btn-create-symbolic-ticket").prop("disabled", false);
                            },
                        });
                    }
                });
            }
        });
}

function saveImage(obj) {
    var fImage = document.getElementById("path_image");
    fImage = fImage.files[0];
    if (fImage) {
        var formData = new FormData();
        formData.append("image", fImage);
        formData.append("symbolic_ticket_id", obj.id);

        $.ajax({
            type: "POST",
            dataType: "json",
            processData: false,
            contentType: false,
            headers: {
                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
            },
            data: formData,
            url: "/symbolic_tickets/saveImage",
            success: function (r) {
                if (r.r) {
                    swal(r.m, {
                        icon: "success",
                        buttons: {
                            Ok: true,
                        },
                    }).then((val) => {
                        if (val == "Ok") {
                            $(location).attr("href", "/symbolic_tickets");
                        }
                    });
                } else {
                    swal("Ok", Lang.get("messagesClient.product_tag1"), "error");
                }
            },
        });
    } else {
        alert("No hay archivo.");
    }
}

function clickEditSymbolicTicket(value) {
    _table = $("#example2").DataTable();
    index = _table.page();
    localStorage.setItem("symbolicTicketsTableIndex", index);
    $(location).attr("href", "/symbolic_tickets/" + value + "/edit");
}

function clickInfoSymbolicTicket(value) {
    _table = $("#example2").DataTable();
    index = _table.page();
    localStorage.setItem("symbolicTicketsTableIndex", index);
    $(location).attr("href", "/symbolic_tickets_user/" + value + "/info");
}

function chkSymbolicTicket(id) {
    var state = 0;

    if ($("#Checkactive" + id).is(":checked")) {
        state = 1;
    }

    var info = {
        id,
        state,
    };

    $.ajax({
        url: "/symbolic_tickets/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", Lang.get("messagesClient.symbolic_tickets.update_state"), "error");
            }
        },
        error: function (e) {
            swal("Error", Lang.get("messagesClient.symbolic_tickets.update_error"), "error");
        },
    });
}

function clickSymbolicTicketPrices(_id) {
    _table = $("#example2").DataTable();
    index = _table.page();
    localStorage.setItem("symbolicTicketsTableIndex", index);
    $(location).attr("href", "/symbolic_tickets_price/" + _id + "/prices");
}

function editSymbolicTicket() {
    $("#editSymbolicTicket").validator("update");
    $("#editSymbolicTicket")
        .validator("update")
        .on("submit", function (e) {
            e.preventDefault();

            var id = $("#editSymbolicTicket input[name='id']").val();
            var name = $("#editSymbolicTicket input[name='name']").val();
            var capacity = $("#editSymbolicTicket input[name='capacity']").val();
            var start_date = $("#editSymbolicTicket input[name='start_date']").val();
            var end_date = $("#editSymbolicTicket input[name='end_date']").val();
            var match_event_id = $("#editSymbolicTicket select[name='match_event_id']").val();
            var is_subscriber = $("#editSymbolicTicket input[name='isSubscriber']")[0].checked;

            var info = {
                name,
                capacity,
                start_date,
                end_date,
                match_event_id,
                is_subscriber,
                tags: $("#editSymbolicTicket select[name='generalMultiselect']").val()
            };

            swal(Lang.get("messagesClient.symbolic_tickets.to_update"), {
                buttons: {
                    cancel: "No",
                    Ok: true,
                },
            }).then((val) => {
                if (val == "Ok") {
                    $.ajax({
                        url: "/symbolic_tickets/" + 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) {
                                var image = document.getElementById(
                                    "path_image"
                                ).value;
                                var data = {
                                    id: r.d,
                                };
                                if (image != "") {
                                    updateImage(data);
                                } else {
                                    swal(r.m, {
                                        icon: "success",
                                        buttons: {
                                            Ok: true,
                                        },
                                    }).then((val) => {
                                        if (val == "Ok") {
                                            localStorage.setItem("setPageTable", true);
                                            $(location).attr("href", "/symbolic_tickets");
                                        }
                                    });
                                }
                            }
                        },
                        error: function (e) {
                            swal("Error", Lang.get("messagesClient.symbolic_tickets.update_error"), "error");
                            $("#btn-edit-sucursal").prop("disabled", false);
                        },
                    });
                }
            });
        });
}

function updateImage(obj) {
    var fImage = document.getElementById("path_image");
    fImage = fImage.files[0];
    if (fImage) {
        var formData = new FormData();
        formData.append("image", fImage);
        formData.append("symbolic_ticket_id", obj.id);

        $.ajax({
            type: 'POST',
            dataType: 'json',
            processData: false,
            contentType: false,
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            data: formData,
            url: '/symbolic_tickets/updateImage',
            success: function (r) {
                if (r.r) {
                    swal(r.m,
                        {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            }
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr('href', '/symbolic_tickets');
                            }
                        });
                } else {
                    swal("Ok", r.m, "error");
                }

            }
        });
    }
    else {
        alert("No hay archivo.")
    }
}

function clickDeleteSymbolicTicket(value) {

    swal(Lang.get("messagesClient.symbolic_tickets.to_delete"), {
        buttons: {
            cancel: "No",
            Ok: true,
        }
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                "id": value
            };
            $.ajax({
                url: "/symbolic_tickets/delete",
                type: "DELETE",
                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', '/symbolic_tickets');
                            }
                        });
                    }
                }, error: function (e) {
                    swal("Error", Lang.get("messagesClient.symbolic_tickets.error_delete"), "error");
                }
            });
        }
    });

}

function clickGenerateTickets(id) {
    swal(Lang.get("messagesClient.symbolic_tickets.to_generate_tickets"), {
        buttons: {
            cancel: "No",
            Ok: true,
        }
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                id
            };

            $.ajax({
                url: "/symbolic_tickets/generateTickets",
                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,
                            }
                        });
                    } else {
                        swal("Error", Lang.get(r.m), "error");
                    }
                },
                error: function (e) {
                    cons
                    swal("Error", Lang.get("messagesClient.symbolic_tickets.update_error"), "error");
                },
            });
        }
    });
}