Processadores Mais Buscados
Seu case especial em todos os estilos
Placas Gráficas, Eleve sua Experiência Visual
152) {
$('.header').addClass('fixed h-shadow');
$('.main').css('margin-top', '194px');
} else {
$('.header').removeClass('fixed h-shadow');
$('.main').css('margin-top', '7px');
}
});
$("img.lazy").lazyload();
$('.owl-prev, .owl-next').on('click', function() {
$("img.lazy").lazyload();
});
$('.owl-carousel').on('dragged.owl.carousel', function(event) {
$("img.lazy").lazyload();
});
ListDisplayCart();
});
function reload(){ location.reload(); }
function popup(mypage, myname, w, h, scroll){
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=no,scrollbars='+scroll+''
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// carrinho de orcamentos
function addItem() {
const productCode = document.getElementById("productCode").value;
const productName = document.getElementById("productName").value;
const productPrice = parseFloat(document.getElementById("productPrice").value);
const productQuantity = parseInt(document.getElementById("productQuantity").value);
const productImg = document.getElementById("productImg").value;
if (productCode && productName && !isNaN(productPrice) && !isNaN(productQuantity) && productQuantity > 0) {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const newItem = { code: productCode, name: productName, price: productPrice, img: productImg, quantity: productQuantity };
// Verificar se o item já existe no carrinho
const existingItem = cartItems.find(item => item.code === productCode);
if (existingItem) {
existingItem.quantity += productQuantity;
} else {
cartItems.push(newItem);
}
sessionStorage.setItem("cartItems", JSON.stringify(cartItems));
ListDisplayCart(); tremor();
} else {
alert("Informe uma quantidade válida.");
}
}
function displayCart() {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const cartList = document.getElementById("cartItems");
let totalPrice = 0;
let totalQuantity = 0;
cartList.innerHTML = "";
if (cartItems.length === 0) {
const elements = document.querySelectorAll(".is-msg-cart-off");
elements.forEach(element => {
element.style.display = "block";
});
} else {
cartItems.forEach(item => {
const div = document.createElement("div");
div.className = "list-group-cart-item";
const itemTotal = item.price * item.quantity;
const formattedPrice = item.price.toLocaleString('pt-BR', { style: 'currency', currency: 'USD' });
totalPrice += itemTotal;
const imageWidth = window.innerWidth < 600 ? 80 : 120;
const itemInfo = `
`;
div.innerHTML = itemInfo;
cartList.appendChild(div);
totalQuantity += item.quantity;
});
}
if (totalQuantity > 0) {
$(".lista-cart-empty").hide();
$(".offcanvas-footer").show();
$(".is-cart-total").html(totalQuantity);
// Criar uma div para exibir o total
const totalDiv = document.createElement("div");
totalDiv.className = "py-2";
totalDiv.innerHTML = `
`;
// Adicionar a div do total à lista de carrinho
cartList.appendChild(totalDiv);
}else{
$(".lista-cart-empty").show();
$(".offcanvas-footer, .is-cart-list").hide();
}
}
function ListDisplayCart() {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
let totalQuantity = 0;
$.each(cartItems, function(index, item) {
totalQuantity += item.quantity;
});
if(totalQuantity > 0){ $( ".cart-count" ).show(); $( ".is-cart-total" ).html(totalQuantity); }
}
function incrementQuantity(itemCode) {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const updatedCartItems = cartItems.map(item => {
if (item.code === itemCode) {
item.quantity += 1;
}
return item;
});
sessionStorage.setItem("cartItems", JSON.stringify(updatedCartItems));
ListDisplayCart(); displayCart();
}
function decrementQuantity(itemCode) {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const updatedCartItems = cartItems.map(item => {
if (item.code === itemCode && item.quantity > 1) {
item.quantity -= 1;
}
return item;
});
sessionStorage.setItem("cartItems", JSON.stringify(updatedCartItems));
ListDisplayCart(); displayCart();
}
function updateQuantity(code, newQuantity) {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const item = cartItems.find(item => item.code === code);
if (item) {
item.quantity = parseInt(newQuantity);
sessionStorage.setItem("cartItems", JSON.stringify(cartItems));
ListDisplayCart(); displayCart();
}
}
function removeItem(code) {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const newCartItems = cartItems.filter(item => item.code !== code);
sessionStorage.setItem("cartItems", JSON.stringify(newCartItems));
ListDisplayCart(); displayCart();
}
function sendWhatsApp() {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
let message = "SEGUE MINHA LISTA DE ORÇAMENTO:\n\n";
// Construir a mensagem com os itens do carrinho
cartItems.forEach(item => {
message += `${item.name} (SKU: ${item.code}) - Quantidade: ${item.quantity} - Preço Unitário: U$ ${item.price.toFixed(2)}\n\n`;
});
const userName = document.getElementById("userName").value;
if (!userName) {
const storedUserName = getUserNameFromCookie();
if (storedUserName) {
document.getElementById("userName").value = storedUserName;
}
}
const phoneNumber = "+595975548086";
message = encodeURIComponent(message);
const whatsappURL = `https://wa.me/${phoneNumber}?text=${message}`;
window.open(whatsappURL, "_blank");
sessionStorage.removeItem("cartItems");
const formattedTotalPrice = totalPrice.toLocaleString('pt-BR', { style: 'currency', currency: 'USD' });
const totalElement = document.createElement("div");
totalElement.innerHTML = `Total: ${formattedTotalPrice}`;
cartList.appendChild(totalElement);
// Limpar a sessão se o carrinho
if (cartItems.length === 0) {
//sessionStorage.removeItem("cartItems");
}
}
function getUserNameFromCookie() {
const cookies = document.cookie.split(';');
for (const cookie of cookies) {
const [name, value] = cookie.trim().split('=');
if (name === 'userName') {
return decodeURIComponent(value);
}
}
return null;
}
function formatCurrency(number) {
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'USD' }).format(number);
}
function saveToDatabase() { printInvoice(); }
function printInvoice() {
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const userName = document.getElementById("userName").value;
let invoiceText = `Orçamento - Topdek Informática ');
printWindow.document.write(invoiceText);
printWindow.document.write('');
printWindow.document.close();
setTimeout(function () { saveToDatabase(); }, 500);
setTimeout(function () { printWindow.print(); }, 3000);
printWindow.onafterprint = function() {
printWindow.close();
};
}
function saveToDatabase(){
const cartItems = JSON.parse(sessionStorage.getItem("cartItems")) || [];
const budgetData = {
userName: document.getElementById("userName").value,
chave: document.getElementById("chave").value,
items: cartItems
};
var jsonBudgetData = JSON.stringify(budgetData, null, 2);
var iframe = document.getElementById("postcart");
var url = "carrinho/";
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
form.setAttribute("style", "display: none;");
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "cartData");
input.setAttribute("value", jsonBudgetData);
form.appendChild(input);
document.body.appendChild(form);
form.setAttribute("target", "postcart");
form.submit();
document.body.removeChild(form);
}
function tremor() {
$('.jsscard').animate({
left: '-=10px'
}, 50)
.animate({
left: '+=20px'
}, 50)
.animate({
left: '-=20px'
}, 50)
.animate({
left: '+=20px'
}, 50)
.animate({
left: '-=10px'
}, 50);
}
remover?
`;
invoiceText += ``;
invoiceText += ``;
invoiceText += `
`;
const currentDate = new Date();
const formattedDate = currentDate.toLocaleDateString();
const formattedTime = currentDate.toLocaleTimeString();
invoiceText += `
`;
const printWindow = window.open('', '', 'width=800,height=600');
printWindow.document.open();
printWindow.document.write('LISTA DE ORÇAMENTO
`; invoiceText += `Produto | Código | Quantidade | Preço Unitário |
---|---|---|---|
${item.name} | ${item.code} | ${item.quantity} | ${formatCurrency(item.price)} |
Valor Total: | ${formatCurrency(totalPrice)} |
Data: ${formattedDate} ${formattedTime}
`; invoiceText += `Os preços apresentados não incluem o Imposto sobre o Valor Acrescentado (IVA) e são aplicáveis apenas a residentes no Paraguai e podem variar sem aviso. A lista de orçamentos não garante estoque, apenas auxilia na compra em nossa loja física.
`; invoiceText += ``; invoiceText += `