const editVoucherbtn=document.querySelectorAll('.editVoucherbtn');
editVoucherbtn.forEach(btn=>{
    btn.addEventListener('click',()=>{
        document.getElementById('editVoucherid').value=btn.dataset.id;
        document.getElementById('editVouchername').value=btn.dataset.name;
        document.getElementById('editVoucherdiscount').value=btn.dataset.discount;
        document.getElementById('editVoucherStatus').value=btn.dataset.active;
       document.getElementById('editVoucherdiscounttype').value=btn.dataset.discounttype;
    })
});

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