$(document).ready(function () {
    DeuBill();
});

$("#due-bill-btn").on('click', function () { 
    DeuBill();
 });

$("#all-bill-btn").on('click', function () { 
    AllBillList();
 });

function btn(all = false) { 
    var dueBillBtn = document.querySelector("#due-bill-btn");
    var allBillBtn = document.querySelector("#all-bill-btn");

    if (all) {
        dueBillBtn.classList.remove("btn-success");
        dueBillBtn.classList.add("btn-outline-success");
        allBillBtn.classList.remove("btn-outline-success");
        allBillBtn.classList.add("btn-success");
    }else{
        dueBillBtn.classList.remove("btn-outline-success");
        dueBillBtn.classList.add("btn-success");
        allBillBtn.classList.remove("btn-success");
        allBillBtn.classList.add("btn-outline-success");
    }
}

function DeuBill() {
    btn();
    $('#reportTitle').html('Due Bill List');

    $("#reportBody").html('');

    $.ajax({
        type: "post",
        url: "cust_bill_list_due.php",
        success: function (response) {
            $("#reportBody").append(response);
        }
    });
}

function AllBillList() {
    btn(true);
    $('#reportTitle').html('All Bill List');

    $("#reportBody").html('');

    $.ajax({
        type: "post",
        url: "cust_bill_list_all.php",
        success: function (response) {
            $("#reportBody").append(response);
        }
    });
}