93 lines
3.4 KiB
JavaScript
Vendored
93 lines
3.4 KiB
JavaScript
Vendored
let checked_rad = () =>{
|
|
const radios = document.querySelectorAll('input[name="radpembayaran"]');
|
|
// let rad_payment = document.getElementById('radpembayaran');
|
|
let btn_payment = document.getElementById('bayarsbmt');
|
|
let btn_payment_phone = document.getElementById('bayarsbmt-phone');
|
|
|
|
|
|
if(radios.checked){
|
|
btn_payment.disabled = false;
|
|
btn_payment_phone.disabled = false;
|
|
}else{
|
|
btn_payment.disabled = true;
|
|
btn_payment_phone.disabled = true;
|
|
}
|
|
}
|
|
|
|
const radios = document.querySelectorAll('input[name="radpembayaran"]');
|
|
|
|
radios.forEach((radio) => {
|
|
radio.addEventListener('change', function () {
|
|
let btn_payment = document.getElementById('bayarsbmt');
|
|
let btn_payment_phone = document.getElementById('bayarsbmt-phone');
|
|
let content1 = document.getElementById('divpkb');
|
|
let content2 = document.getElementById('divkopkb');
|
|
let whole_total = document.getElementById('spanjumlah');
|
|
let whole_total_phone = document.getElementById('spanjumlah-phone');
|
|
let inputs = document.querySelectorAll(`#div${this.value} input[type="number"]`);
|
|
let values = Array.from(inputs).map(input => parseFloat(input.value) || 0).reduce((sum,value) => sum + value, 0);
|
|
|
|
if (this.checked) {
|
|
if(this.value == 'kopkb'){
|
|
let inputsdisabled = document.querySelectorAll(`#divpkb input:not([type="radio"])`);
|
|
let inputenabled = document.querySelectorAll(`#divkopkb input`);
|
|
inputsdisabled.forEach(input => {
|
|
input.disabled = true;
|
|
});
|
|
inputenabled.forEach(input =>{
|
|
input.disabled = false;
|
|
});
|
|
content1?.classList.add('blurred');
|
|
content2?.classList.remove('blurred');
|
|
btn_payment.disabled = false;
|
|
btn_payment_phone.disabled = false;
|
|
whole_total.innerHTML = formatter.format(values + 1);
|
|
whole_total_phone.innerHTML = formatter.format(values + 1);
|
|
|
|
}else{
|
|
let inputsdisabled = document.querySelectorAll(`#divkopkb input:not([type="radio"])`);
|
|
let inputenabled = document.querySelectorAll(`#divpkb input`);
|
|
|
|
inputsdisabled.forEach(input => {
|
|
input.disabled = true;
|
|
});
|
|
inputenabled.forEach(input =>{
|
|
input.disabled = false;
|
|
});
|
|
content2?.classList.add('blurred');
|
|
content1?.classList.remove('blurred');
|
|
btn_payment.disabled = false;
|
|
btn_payment_phone.disabled = false;
|
|
whole_total.innerHTML = formatter.format(values + 1);
|
|
whole_total_phone.innerHTML = formatter.format(values + 1);
|
|
}
|
|
}
|
|
|
|
});
|
|
});
|
|
|
|
let deleteCarts = () => {
|
|
const loader = document.getElementById('load-arrahn');
|
|
if(loader)
|
|
loader.classList.remove('d-none');
|
|
|
|
fetch('/deletecarts')
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('HTTP error ' + response.status);
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
if (data) {
|
|
redirect_home();
|
|
}
|
|
})
|
|
.catch(error => console.error(error));
|
|
}
|
|
|
|
let redirect_home = () => {
|
|
window.location.href = redirect_home_var;
|
|
}
|
|
|