const editExpensebtn=document.querySelectorAll(".editExpensebtn");
editExpensebtn.forEach(btn=>{
    btn.addEventListener("click",()=>{
        document.getElementById("editExpenseId").value=btn.dataset.id;
        document.getElementById("editExpenseTitle").value=btn.dataset.title;
        document.getElementById("editExpenseCost").value=btn.dataset.cost;
        document.getElementById("editExpenseDate").value=btn.dataset.date;
        document.getElementById("editExpenseCost").value=btn.dataset.cost})
});

document.querySelectorAll(".dlt_expense_btn").forEach(btn=>{
    btn.addEventListener("click",()=>{
        if(confirm("Are you sure you want to delete this expense?")){
            const id=btn.dataset.id;
            fetch("../pages/submissions/expensesSubmission.php",{
                method:"POST",
                headers:{"Content-Type":"application/x-www-form-urlencoded"},
                body:"id="+id
            }).then(res=>res.text())
            .then(data=>location.reload())
        }
    })
})