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/alq-cali.bikenow.co/public/js/payment.js
/**
 * Esta función obtiene los datos de la vista y los envía a la capa de lógica 
 * para la creacion de una marca
 * @version 2018/05/20 
 */
function createPayment() {
    $('#createPayment').validator('update');

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

            var info = {
                "name": $(" #createPayment input[name='name']").val()
            };
            swal(Lang.get("messagesClient.payment_tag3"), {

                buttons: {
                    cancel: "No",
                    Ok: true,

                }
            }).then((val) => {
                if (val == "Ok") {

                    create_Payment(info);
                }
            });


        }
    });

    /**
     * Esta función hace un llamado AJAX y envia un json creando un nuevo registro de linea de negocio
     * @param info el json con la informacion de la vista
     * @version 2018/05/20
     */
    function create_Payment(info) {
        $.ajax({
            url: "/payments/create",
            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") {
                            console.log('creado');
                            $(location).attr('href', '/payments');
                        }
                    });
                } else {
                    swal("Error",r.m, "error");
                }
            }, error :function(e){
                swal(Lang.get("messagesClient.payment_tag1"), "error");
            }
        });
    }
}


/*
 * En caso de que se haga clic en el icono de editar 
 * se redirecciona a la vista de edición de Lineas de Negocio
 */
function clickEditPayment(value) {
    _table = $("#example2").DataTable();
    index = _table.page();
    localStorage.setItem("productsTableIndex", index);
    $(location).attr('href','/payments/edit/' + value);
}

//eliminar linea de negocio
function clickDeletePayment(value) {

   var info = {
        "id":value
    };
    swal( Lang.get("messagesClient.payment_tag4"), {
        buttons: {
            cancel: "No",
            Ok: true,
        }
    }).then((val) => {
        if (val == "Ok") {
            deletePayment(info);
        }
    });

}

/**
 * Esta función obtiene los datos de la vista de edtitar y los envía a la capa de lógica 
 * para la actualización de los datos de una línea de negocio 
 * @version 2018/05/20 
 */
function editPayment() {
    $('#editPayment').validator('update');
    $("#editPayment").validator('update').on('submit', function (e) {
        if (e.isDefaultPrevented()) {} else {
            e.preventDefault();

            var info = {
                "id": $(" #editPayment input[name='id']").val(),
                "name": $(" #editPayment input[name='name']").val(),

            };
            swal(Lang.get("messagesClient.payment_tag5"), {

                buttons: {
                    cancel: "No",
                    Ok: true,

                }
            }).then((val) => {
                if (val == "Ok") {
                    updatePayment(info);
                }
            });
        }
    });

    /**
     * Esta función hace un llamado AJAX y envia un json actualizando un registro de linea de negocio
     * @param info el json con la informacion de la vista
     * @version 2018/05/20
     */
    function updatePayment(info) {
        $.ajax({
            url: "/payments/update",
            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") {
                            console.log('modificado');
                            localStorage.setItem("setPageTable", true);
                            $(location).attr('href','/payments');
                        }
                    });
                } else {
                    swal("Error",r.m, "error");
                }
            }, error: function (e){
                swal("Error",Lang.get("messagesClient.payment_tag2"), "error"); 
            }
        });
    }
}

function setPageTable(){
    localStorage.setItem("setPageTable", true);
    $(location).attr('href', '/payments');
  }

function chkPayment(id) {

    var state;

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

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

    $.ajax({
        url: "/payments/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("Ok", r.m, "error");
            }
        },
        error: function (e) {
            swal("Ok", e, "error");
        }
    });

}

//funcion eliminar linea de negocio

function deletePayment(info) {
    $.ajax({
        url: "/payments/delete",
        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") {
                        console.log('modificado');
                        $(location).attr('href', '/payments');
                    }
                });
            } else {
                swal("Hubo un error al querer eliminar la Forma de Pago", "error");
            }
        },
        error: function (e) {

            swal(e, "error");

        }
    });

}