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

$("#year-month-btn").on('click', function () { 
    YearMonthList();
 });

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

function btn(all = false) { 
    var yearMonthBtn = document.querySelector("#year-month-btn");
    var allBtn = document.querySelector("#all-btn");

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

function YearMonthList() {
    btn();
    $('#reportTitle').html('Year Month Group');

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

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

function AllList() {
    btn(true);
    $('#reportTitle').html('All Quotations');

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

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