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/academy_tournament_payments.js
function clickEdit(payment_id) {
    $(location).attr("href", "/academy_tournament_payments/edit/" + payment_id);
}

function editPurchase() {
    $("#editPayment").validator("update");
    $("#editPayment")
        .validator("update")
        .on("submit", function (e) {
            if (e.isDefaultPrevented()) {
            } else {
                e.preventDefault();
                if (!validateFormData()) {
                    return;
                }
                swal(Lang.get("messagesClient.academy_payments.update_payment"), {
                    buttons: {
                        cancel: "No",
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        $('#loading').show();
                        var info = {
                            id: $("#btn-edit-payment").attr("data-id"),
                            term: $("#editPayment input[name='term']").val(),
                            price: $("#editPayment input[name='price']").val(),
                            price_discount: $("#editPayment input[name='price_discount']").val(),
                            discount: $("#editPayment input[name='discount']").val(),
                            subtotal: $("#editPayment input[name='subtotal']").val(),
                            service_charge: $("#editPayment input[name='service_charge']").val(),
                            total: $("#editPayment input[name='total']").val(),
                            reference: $("#editPayment input[name='reference']").val(),
                            state: $("#editPayment select[name='state']").val(),
                            comment: $("#editPayment input[name='comment']").val(),
                            payment_method_id: $("#editPayment select[name='payment_method_id']").val(),
                        };
                        $.ajax({
                            url: "/academy_tournament_payments/update",
                            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) {
                                $('#loading').hide();
                                if (r.r) {
                                    swal(r.m, {
                                        icon: "success",
                                        buttons: {
                                            Ok: true,
                                        },
                                    }).then((val) => {
                                        if (val == "Ok") {
                                            localStorage.setItem("setPageTable", true);
                                            $(location).attr("href", "/academy_tournament_payments");
                                        }
                                    });
                                } else {
                                    swal("Error", r.m, "error");
                                }
                            },
                            error: function (e) {
                                $('#loading').hide();
                                swal("Error", Lang.get("messagesClient.academy_payments.error_update_payment"), "error");
                            },
                        });
                    }
                });
            }
        });
}

function clickPay(payment_id) {
    $(location).attr("href", "/academy_tournament_payments/pay/" + payment_id);
}

function purchase() {
    $("#pay").validator("update");
    $("#pay")
        .validator("update")
        .on("submit", function (e) {
            if (e.isDefaultPrevented()) {
            } else {
                e.preventDefault();
                swal(Lang.get("messagesClient.academy_payments.confirm_payment"), {
                    buttons: {
                        cancel: "No",
                        Ok: true,
                    },
                }).then((val) => {
                    if (val == "Ok") {
                        $('#loading').show();
                        let payment_date = $("#pay input[name='start_date']").val() + ' ' + convertTime12to24($("#pay input[name='start_time']").val())
                        var data = {
                            id: $("#btnPay").attr("data-id"),
                            reference: $("#pay input[name='payment_reference']").val(),
                            state: $("#pay select[name='state_payment']").val(),
                            comment: $("#pay input[name='payment_comment']").val(),
                            payment_method_id: $("#pay select[name='payment_method_id']").val(),
                            support: document.getElementById("document").files.length ? document.getElementById("document").files[0] : '',
                            payment_date: payment_date,
                        };
                        formData = new FormData();
                        for (var key in data) {
                            formData.append(key, data[key]);
                        }
                        $.ajax({
                            url: "/academy_tournament_payments/pay",
                            type: "POST",
                            dataType: "json",
                            processData: false,
                            contentType: false,
                            headers: {
                                "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr(
                                    "content"
                                )
                            },
                            data: formData,
                            success: function (r) {
                                $('#loading').hide();
                                if (r.r) {
                                    swal(r.m, {
                                        icon: "success",
                                        buttons: {
                                            Ok: true,
                                        },
                                    }).then((val) => {
                                        if (val == "Ok") {
                                            localStorage.setItem("setPageTable", true);
                                            $(location).attr("href", "/academy_tournament_payments");
                                        }
                                    });
                                } else {
                                    swal("Error", r.m, "error");
                                }
                            },
                            error: function (e) {
                                $('#loading').hide();
                                swal("Error", Lang.get("messagesClient.academy_payments.error_confirm_payment"), "error");
                            },
                        });
                    }
                });
            }
        });
}

function clickDelete(value) {
    deleteRegister("/academy_tournament_payments/delete/" + value, Lang.get("messagesClient.academy_purchases.delete_question"), "/academy_tournament_payments");
}

function validateFormData() {
    if ($("#editPayment select[name='state']").val() == "CONFIRMED" && !$("#editPayment input[name='reference']").val()) {
        swal("Error", Lang.get("messagesClient.academy_purchases.reference_required"), "error").then(() => {
            $("#editPayment input[name='reference']").focus();
        });
        return false;
    }
    return true;
}