jQuery(document).ready(function () {

    jQuery('.status_set').click(function() {
        var status = jQuery(this).attr('data-status');
        var status_id = jQuery(this).attr('data-id');
        var user_id = jQuery(this).attr('data-user_id');
        var status_get = jQuery(this).attr('data-status_get');
        
        console.log(status);
        jQuery.ajax({
            type: "POST",
            url: "/wp-admin/admin-ajax.php",
            data: {
                action: 'cancel_request',
                status : status,
                status_id : status_id,
                user_id : user_id,
                status_get  : status_get,
            },
            success: function (output) {
                var check_user_id = jQuery('#check_user_id').val();
                window.location.reload();
            }
        });
    })

    jQuery('.status_cancel_view').click(function() {
        var status = jQuery(this).attr('data-status');
        var status_id = jQuery(this).attr('data-id');
        var user_id = jQuery(this).attr('data-user_id');

        console.log(status);
        jQuery.ajax({
            type: "POST",
            url: "/wp-admin/admin-ajax.php",
            dataType: "json",
            data: {
                action      : 'status_cancel_view',
                status      : status,
                status_id   : status_id,
                user_id     : user_id,
            },
            success: function (data) {
                jQuery('.table_data_add').empty();
                console.log(data.delete);
                if(data.delete == 'delete'){
                    window.location.reload();
                }
               
                console.log(data);
                var name = data.name;
                var account_name = data.account_name;
                var account_number = data.account_number;
                var bsb_number = data.bsb_number;
                var cancel_resion = data.cancel_resion;
                var status = data.status;
                var success = data.success;
                var refund = data.refund;
               
                var html = '';
                
                html += '<thead>';
                    html += '<tr>';
                      html += '<th scope="col">Field Name</th>';
                      html += '<th scope="col">Data</th>';
                    html += '</tr>';
                html += '</thead>';
                
                html += '<tbody>';
                    html += '<tr>';
                        html += '<td>Name</td>';
                        html += '<td>' + name + '</td>';
                    html += '</tr>';
                    
                    html += '<tr>';
                        html += '<td>Account Holder Name</td>';
                        html += '<td>' + account_name + '</td>';
                    html += '</tr>';
    
                    html += '<tr>';
                        html += '<td>Account Number</td>';
                        html += '<td>' + account_number + '</td>';
                    html += '</tr>';
    
                    html += '<tr>';
                        html += '<td>BSB Number</td>';
                        html += '<td>' + bsb_number + '</td>';
                    html += '</tr>';
    
                    html += '<tr>';
                        html += '<td>Comment</td>';
                        html += '<td>' + cancel_resion + '</td>';
                    html += '</tr>';
                    html += '<tr>';
                        html += '<td>Refund</td>';
                        html += '<td> $' + refund + '</td>';
                    html += '</tr>';
    
                    html += '<tr>';
                        html += '<td>Status</td>';
                        html += '<td>' + status + '</td>';
                    html += '</tr>';
                html += '</tbody>';    

                jQuery('.view_modal_open').modal('show');
                jQuery('.table_data_add').html(html);
                // window.location.reload();
            }
        });
    })

});