
        <tr>
            <td colspan="4" class="text-center text-warning">
                No matching records found.
            </td>
        </tr>
<script>

$(document).on('click', '.approve-btn', function () {

    let btn = $(this);

    let doc_no = btn.data('doc');
    let ttype = btn.data('type');

    $.ajax({

        url: '../includes/approve_bank_transaction.php',

        type: 'POST',

        dataType: 'json',

        data: {
            doc_no: doc_no,
            ttype: ttype
        },

        beforeSend: function () {

            btn.prop('disabled', true)
               .text('Approving...');
        },

        success: function (response) {

            if (response.status === 'success') {

                let amount = parseFloat(
                    btn.data('amount')
                ) || 0;

                let currentRow = btn.closest('tr');

                let group = currentRow.data('group');

                let totalRow = $(
                    '.daily-total-row[data-group="' + group + '"]'
                ).last();

                let totalSpan = totalRow.find(
                    '.daily-total-amount'
                );

                let currentTotal = parseFloat(
                    totalSpan.text()
                        .replace(/,/g, '')
                        .trim()
                ) || 0;

                let newTotal = currentTotal + amount;

                totalSpan.text(
                    newTotal.toLocaleString()
                );

                btn.fadeOut(300, function () {
                    $(this).remove();
                });

            } else {

                alert(response.message || 'Approval failed');

                btn.prop('disabled', false)
                   .text('Approve');
            }
        },

        error: function () {

            alert('Server error');

            btn.prop('disabled', false)
               .text('Approve');
        }
    });

});

</script>