const editInventorybtn=document.querySelectorAll(".editInventorybtn");
editInventorybtn.forEach(btn=>{
    document.getElementById("editInventoryid").value=btn.dataset.id;
    document.getElementById("editInventorytitle").value=btn.dataset.title;
    document.getElementById("editInventoryamount").value=btn.dataset.cost;
    document.getElementById("editInventorydate").value=btn.dataset.date;
    document.getElementById("editInventoryentrydate").value=btn.dataset.entrydate;
})
document.querySelectorAll('.dlt-btn-cat').forEach(btn => {
    btn.addEventListener('click', function() {
        const id = this.getAttribute('data-id');
        if (confirm("Are you sure you want to delete this category?")) {
            fetch('delete.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'id=' + id
            })
            .then(response => response.text())
            .then(data => {
                location.reload();
            });
        }
    });
});