محاسبهگر انتخاب پمپ فلورانbody{font-family: Vazirmatn,sans-serif;background:#f0f4f8;margin:0;padding:20px;direction:rtl;}
.pump-widget-container{display:flex;flex-wrap:wrap;gap:20px;justify-content:center;}
.pump-widget-form, .pump-widget-preview{
flex:1; min-width:320px; padding:20px; border-radius:20px; box-shadow:0 10px 30px rgba(0,0,0,0.08); background:#fff; transition:0.3s;
}
.pump-widget-form:hover{box-shadow:0 15px 40px rgba(0,0,0,0.15);}
.form-header{display:flex;align-items:center;font-size:24px;font-weight:bold;margin-bottom:20px;}
.form-header img{margin-left:10px;}
label{display:block;margin-top:12px;font-weight:bold;}
input, select{width:100%;padding:10px;margin-top:4px;border-radius:8px;border:1px solid #ccc;text-align:right;transition:0.3s;}
input:focus, select:focus{border-color:#0ea5a4;outline:none;}
button{margin-top:15px;padding:12px 18px;background:#16a34a;color:#fff;border:none;border-radius:10px;cursor:pointer;transition:0.3s;font-weight:bold;}
button:hover{background:#15803d;}
.preview-header{font-weight:bold;font-size:18px;margin-bottom:12px;}
.preview-card{
background:#fff;padding:20px;border-radius:20px;box-shadow:0 8px 24px rgba(0,0,0,0.08);
transform:translateX(50px) scale(0.9); opacity:0; transition:all 0.6s ease, background 0.3s ease;
}
.preview-card.active{transform:translateX(0) scale(1); opacity:1; background:linear-gradient(135deg,#0ea5a4,#38bdf8); color:#fff;}
.pump-name{font-size:22px;font-weight:800;margin-bottom:8px;}
.pump-reason{font-size:14px;margin-bottom:12px;}
.pump-image{width:100%;height:250px;object-fit:contain;border-radius:12px;transition:transform 0.5s ease;}
#orderArea a{display:inline-block;margin-top:10px;padding:10px 14px;background:#16a34a;color:#fff;border-radius:10px;text-decoration:none;transition:0.3s;}
#orderArea a:hover{background:#15803d;}
@media(max-width:900px){.pump-widget-container{flex-direction:column;}}
.pump-widget-footer{width:100%;text-align:center;font-size:14px;margin-top:25px;color:#007BFF;font-weight:bold;}
(function(){
const phone = document.getElementById('phone');
const cityBlock = document.getElementById('cityBlock');
const city = document.getElementById('city');
const usage = document.getElementById('usage');
const resType = document.getElementById('resType');
const villaBlock = document.getElementById('villaBlock');
const apartmentBlock = document.getElementById('apartmentBlock');
const agriBlock = document.getElementById('agriBlock');
const SPDBlock = document.getElementById('SPDBlock');
const calcBtn = document.getElementById('calcBtn');
const resultName = document.getElementById('resultName');
const resultDesc = document.getElementById('resultDesc');
const resultImage = document.getElementById('resultImage');
const orderArea = document.getElementById('orderArea');
const resultCard = document.getElementById('resultCard');const northern = new Set(['Rasht','Anzali','Babolsar','Sari','Amol','Babol','Chalus','Noshahr','Ramsar','Gorgan']);const pumpData = {
'KPM50': {img:'https://ppsholding.co/wp-content/uploads/2025/12/KPM50-0.5hp.webp', order:'https://ppsholding.co/p696'},
'KPM100': {img:'https://ppsholding.co/wp-content/uploads/2025/12/KPM100-1hp.webp', order:'https://ppsholding.co/2uiq'},
'CM66': {img:'https://ppsholding.co/wp-content/uploads/2025/12/CM-66-0.5hp.webp', order:'https://ppsholding.co/8imy'},
'CM100': {img:'https://ppsholding.co/wp-content/uploads/2025/12/CM-100-1hp.webp', order:'https://ppsholding.co/6qek'},
'CAM100': {img:'https://ppsholding.co/wp-content/uploads/2025/12/CAM-100-1hp.webp', order:'https://ppsholding.co/khbg'},
'CB160': {img:'https://ppsholding.co/wp-content/uploads/2025/12/CB160-1.5hp.webp', order:'https://ppsholding.co/qrvq'},
'CB210': {img:'https://ppsholding.co/wp-content/uploads/2025/12/CB210-2hp.webp', order:'https://ppsholding.co/wdjl'},
'SPD_32M_2inch': {img:'https://ppsholding.co/wp-content/uploads/2025/12/SMALL-SDP1.webp', order:'https://ppsholding.co/upem'},
'SPD_32M_1inch': {img:'https://ppsholding.co/wp-content/uploads/2025/12/SMALL-SDP1.webp', order:'https://ppsholding.co/5is5'},
'SPD_22M_2inch': {img:'https://ppsholding.co/wp-content/uploads/2025/12/SMALL-SDP1.webp', order:'https://ppsholding.co/66d2'},
'SPD_22M_1inch': {img:'https://ppsholding.co/wp-content/uploads/2025/12/SMALL-SDP1.webp', order:'https://ppsholding.co/9fit'}
};phone.addEventListener('input', ()=>{cityBlock.style.display = phone.value.replace(/\D/g,'').length >= 10 ? 'block' : 'none';});
usage.addEventListener('change', updateSections);
resType.addEventListener('change', ()=>{villaBlock.style.display = resType.value==='villa'?'block':'none'; apartmentBlock.style.display = resType.value==='apartment'?'block':'none';});
function updateSections(){
const val = usage.value;
agriBlock.style.display = (val==='agriculture'||val==='garden')?'block':'none';
SPDBlock.style.display = (val==='SPD_pool')?'block':'none';
document.getElementById('residentialBlock').style.display = (val==='residential')?'block':'none';
}
updateSections();calcBtn.addEventListener('click', ()=>{
const phoneValue = phone.value.trim();
const phoneRegex = /^09\d{9}$/;// اعتبارسنجی شماره تماس
if(!phoneRegex.test(phoneValue)){
alert('لطفا جهت محاسبه پمپ شماره تلفن خود را به درستی وارد نمایید');
return;
}// اعتبارسنجی شهر
if(!city.value){
alert('لطفا شهر خود را انتخاب نمایید');
return;
}// ذخیره شماره تماس و شهر در دیتابیس
fetch('save_lead.php', {
method: 'POST',
headers: {'Content-Type':'application/x-www-form-urlencoded'},
body: 'phone=' + encodeURIComponent(phoneValue) + '&city=' + encodeURIComponent(city.value)
})
.then(res => res.json())
.then(data => console.log('Status:', data))
.catch(err => console.error(err));// ارسال ایمیل
const formData = new FormData(document.getElementById('pumpForm'));
fetch('https://ppsholding.co/wp-content/plugins/Save-Contact/send_email.php', {
method: 'POST',
body: formData
})
.then(res => res.text())
.then(res => console.log('Email status:', res))
.catch(err => console.error(err));// محاسبه پمپ
let name='نامشخص', reason='', orderLink='#';
const val = usage.value;
const cityIsNorth = northern.has(city.value);try {
if(val==='agriculture' || val==='garden'){
const area=Number(document.getElementById('agriArea').value || 0);
if(area>=0 && area200 && area=0 && area100 && area=0 && floors<=2){
if(units=2 && units=2 && floors<=4){
if(units=5 && units=4 && floors<=7){
if(units=8 && units 25){name=W==='full'?'SPD_32M_2inch':'SPD_32M_1inch';}
else{name=W==='full'?'SPD_22M_2inch':'SPD_22M_1inch';}
reason='چاه/استخر';
orderLink = pumpData[name].order;
}
else{name='نامشخص'; reason='لطفا جهت کسب اطلاعات بیشتر با دفتر مرکزی تماس بگیرید'; orderLink='#';}
} catch(e){
name='نامشخص'; reason='لطفا جهت کسب اطلاعات بیشتر با دفتر مرکزی تماس بگیرید'; orderLink='#';
}// نمایش نتیجه
resultName.textContent = name + (name==='نامشخص'?'':' — پیشنهاد فلوران با 18 ماه گارانتی تعویض');
resultDesc.textContent = reason + '\nمشاوران ما برای انتخاب دقیقتر با شما تماس خواهند گرفت';
resultImage.src = pumpData[name]?pumpData[name].img:'';
orderArea.innerHTML = `
همین الان سفارش بده`;
resultCard.classList.remove('active');
setTimeout(()=>{resultCard.classList.add('active');},50);
});
})();