`;
}).join('');
}
function filterServices(filterKey) {
document.querySelectorAll('.service-filter-btn').forEach(btn => {
const active = btn.dataset.filter === filterKey;
if (active) {
btn.className = 'service-filter-btn px-4 py-2.5 rounded-xl text-xs sm:text-sm font-bold bg-navy text-white shadow-sm transition-all';
} else {
btn.className = 'service-filter-btn px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold bg-white text-slate-700 border border-slate-200 hover:border-navy transition-all';
}
});
renderServices(filterKey);
}
// Ana Sayfa Hero Teklif Formu -> WhatsApp Yönlendirme
function submitHeroQuoteForm(event) {
event.preventDefault();
const branch = document.getElementById('heroBranch').value;
const fullName = document.getElementById('heroFullName').value.trim();
const phone = document.getElementById('heroPhone').value.trim();
const message =
`Merhaba Ünver Sigorta,\n` +
`Web siteniz üzerinden ücretsiz teklif talebi oluşturuyorum:\n\n` +
`• Branş: ${branch}\n` +
`• Ad Soyad: ${fullName}\n` +
`• Telefon: ${phone}`;
showToast('Teklif talebiniz hazırlandı, WhatsApp açılıyor...', 'success');
window.open(`https://wa.me/${WHATSAPP_NUMBER}?text=${encodeURIComponent(message)}`, '_blank', 'noopener,noreferrer');
}
// -----------------------------------------------------------------------
// 5. ANTALYA INSURANCE® ÇOK DİLLİ PORTAL (RU / UA / TR / EN)
// -----------------------------------------------------------------------
const EXPAT_TRANSLATIONS = {
ru: {
subtitle: 'Страхование для ВНЖ (Икамет) в Анталье — 100% соответствие требованиям Göç İdaresi',
heroTitle: 'Медицинская страховка для ВНЖ (İkamet İzni) за 10 минут!',
heroDesc: 'Официальный полис от лицензированного агентства Ünver Sigorta (с 2008 года). Полностью принимается Миграционной службой Турции (Göç İdaresi) для первичного получения и продления ВНЖ.',
badge1: 'Одобрение Göç İdaresi',
badge2: 'Готовый PDF в WhatsApp',
badge3: 'Поддержка RU / UA / EN',
imageCaption: 'Зарегистрированный товарный знак ANTALYA INSURANCE® (№ 2023 156556) — Офис в Анталье',
formTitle: 'Онлайн-заявка на страховку ВНЖ',
formSub: 'Заполните данные и прикрепите фото паспорта — мы рассчитаем лучшую цену и отправим полис.',
passportLabel: 'Фото первой страницы паспорта (необязательно, ускоряет расчет)',
uploadBtn: 'Выбрать / Сфотографировать паспорт',
nameLabel: 'Имя и Фамилия (латиницей) *',
passNoLabel: 'Номер паспорта *',
dobLabel: 'Дата рождения *',
durationLabel: 'Срок страховки *',
phoneLabel: 'Телефон / WhatsApp *',
submitBtn: 'Отправить заявку в WhatsApp',
waGreeting: 'Здравствуйте, ANTALYA INSURANCE®! Хочу оформить медицинскую страховку для ВНЖ (İkamet İzni):'
},
ua: {
subtitle: 'Страхування для Посвідки на проживання (İkamet) в Анталії — 100% відповідність Göç İdaresi',
heroTitle: 'Медичне страхування для ВНЖ (İkamet İzni) за 10 хвилин!',
heroDesc: 'Офіційний поліс від ліцензованого агентства Ünver Sigorta (з 2008 року). Повністю приймається Міграційною службою Туреччини (Göç İdaresi) для отримання та продовження посвідки.',
badge1: 'Схвалення Göç İdaresi',
badge2: 'Готовий PDF у WhatsApp',
badge3: 'Підтримка UA / RU / EN',
imageCaption: 'Зареєстрована торгова марка ANTALYA INSURANCE® (№ 2023 156556) — Офіс в Анталії',
formTitle: 'Онлайн-заявка на страхування для ВНЖ',
formSub: 'Заповніть дані та додайте фото паспорта — ми розрахуємо найкращу ціну та надішлемо поліс.',
passportLabel: 'Фото першої сторінки паспорта (необов’язково, прискорює оформлення)',
uploadBtn: 'Обрати / Сфотографувати паспорт',
nameLabel: 'Ім’я та Прізвище (латиницею) *',
passNoLabel: 'Номер паспорта *',
dobLabel: 'Дата народження *',
durationLabel: 'Термін страхування *',
phoneLabel: 'Телефон / WhatsApp *',
submitBtn: 'Надіслати заявку у WhatsApp',
waGreeting: 'Вітаю, ANTALYA INSURANCE®! Хочу оформити медичне страхування для посвідки на проживання (İkamet İzni):'
},
tr: {
subtitle: 'Antalya İkamet İzni Yabancı Sağlık Sigortası — Göç İdaresi Başvurularına %100 Uyumlu',
heroTitle: 'İkamet İzni Yabancı Sağlık Sigortanız 10 Dakikada PDF Olarak Hazır!',
heroDesc: '2008’den beri yetkili Ünver Sigorta güvencesiyle; Göç İdaresi ilk başvuru ve ikamet uzatma işlemlerinde %100 geçerli yabancı sağlık poliçenizi dakikalar içinde hazırlıyoruz.',
badge1: 'Göç İdaresi %100 Uyumlu',
badge2: '10 Dakikada PDF Teslimat',
badge3: 'Çok Dilli Destek (TR/RU/UA/EN)',
imageCaption: 'Türk Patent Tescilli ANTALYA INSURANCE® (Tescil No: 2023 156556) — Antalya Merkez Ofis',
formTitle: 'Yabancı Sağlık Sigortası Online Başvuru',
formSub: 'Bilgilerinizi girin ve pasaport fotoğrafınızı yükleyin; en uygun fiyatla poliçenizi düzenleyelim.',
passportLabel: 'Pasaport İlk Sayfa Fotoğrafı (İsteğe bağlı, işlemi hızlandırır)',
uploadBtn: 'Pasaport Fotoğrafı Seç / Çek',
nameLabel: 'Ad Soyad (Pasaporttaki gibi) *',
passNoLabel: 'Pasaport Numarası *',
dobLabel: 'Doğum Tarihi *',
durationLabel: 'Poliçe Süresi *',
phoneLabel: 'Telefon / WhatsApp *',
submitBtn: 'WhatsApp ile Başvuruyu Gönder',
waGreeting: 'Merhaba ANTALYA INSURANCE®, İkamet İzni Yabancı Sağlık Sigortası yaptırmak istiyorum:'
},
en: {
subtitle: 'Residence Permit (İkamet İzni) Health Insurance in Antalya — 100% Göç İdaresi Compliant',
heroTitle: 'Residence Permit Health Insurance Delivered as PDF in 10 Minutes!',
heroDesc: 'Official policy issued by licensed agency Ünver Sigorta (since 2008). 100% accepted by the Turkish Directorate General of Migration Management (Göç İdaresi) for new and renewal applications.',
badge1: '100% Göç İdaresi Approved',
badge2: '10-Min PDF Delivery',
badge3: 'Multilingual Support',
imageCaption: 'Registered Trademark ANTALYA INSURANCE® (Reg. No: 2023 156556) — Antalya Office',
formTitle: 'Online Residence Health Insurance Application',
formSub: 'Fill in your details and upload your passport photo — we will send your best quote & policy immediately.',
passportLabel: 'Passport First Page Photo (Optional, speeds up policy issuance)',
uploadBtn: 'Select / Take Passport Photo',
nameLabel: 'Full Name (as in Passport) *',
passNoLabel: 'Passport Number *',
dobLabel: 'Date of Birth *',
durationLabel: 'Policy Duration *',
phoneLabel: 'Phone / WhatsApp *',
submitBtn: 'Send Application via WhatsApp',
waGreeting: 'Hello ANTALYA INSURANCE®, I would like to apply for Residence Permit Health Insurance:'
}
};
function setExpatLang(lang) {
appState.expatLang = lang;
const t = EXPAT_TRANSLATIONS[lang] || EXPAT_TRANSLATIONS.ru;
document.querySelectorAll('.expat-lang-btn').forEach(btn => {
const active = btn.dataset.expatLang === lang;
if (active) {
btn.className = 'expat-lang-btn px-3.5 py-2 rounded-xl text-xs sm:text-sm font-bold bg-amberbrand text-navy shadow transition-all';
} else {
btn.className = 'expat-lang-btn px-3.5 py-2 rounded-xl text-xs sm:text-sm font-semibold text-white hover:bg-white/15 transition-all';
}
});
document.getElementById('expatSubtitle').textContent = t.subtitle;
document.getElementById('expatHeroTitle').textContent = t.heroTitle;
document.getElementById('expatHeroDesc').textContent = t.heroDesc;
document.getElementById('expatBadge1').textContent = t.badge1;
document.getElementById('expatBadge2').textContent = t.badge2;
document.getElementById('expatBadge3').textContent = t.badge3;
document.getElementById('expatImageCaption').textContent = t.imageCaption;
document.getElementById('expatFormTitle').textContent = t.formTitle;
document.getElementById('expatFormSub').textContent = t.formSub;
document.getElementById('expatPassportLabel').textContent = t.passportLabel;
document.getElementById('expatUploadBtnText').textContent = t.uploadBtn;
document.getElementById('expatNameLabel').textContent = t.nameLabel;
document.getElementById('expatPassNoLabel').textContent = t.passNoLabel;
document.getElementById('expatDobLabel').textContent = t.dobLabel;
document.getElementById('expatDurationLabel').textContent = t.durationLabel;
document.getElementById('expatPhoneLabel').textContent = t.phoneLabel;
document.getElementById('expatSubmitBtnText').textContent = t.submitBtn;
}
function submitExpatForm(event) {
event.preventDefault();
const t = EXPAT_TRANSLATIONS[appState.expatLang] || EXPAT_TRANSLATIONS.ru;
const fullName = document.getElementById('expatFullName').value.trim();
const passNo = document.getElementById('expatPassNo').value.trim();
const dob = document.getElementById('expatDob').value;
const duration = document.getElementById('expatDuration').value;
const phone = document.getElementById('expatPhone').value.trim();
const hasPassport = appState.uploadedDocs.passport ? 'Yes / Да (Attached)' : 'No / Нет';
const msg =
`${t.waGreeting}\n\n` +
`• Name / Имя: ${fullName}\n` +
`• Passport No: ${passNo}\n` +
`• Birth Date: ${dob}\n` +
`• Duration: ${duration}\n` +
`• Phone: ${phone}\n` +
`• Passport Photo: ${hasPassport}`;
showToast('WhatsApp açılıyor...', 'success');
window.open(`https://wa.me/${WHATSAPP_NUMBER}?text=${encodeURIComponent(msg)}`, '_blank', 'noopener,noreferrer');
}
// -----------------------------------------------------------------------
// 6. EVRAK FOTOĞRAFI YÜKLEME, ÖNİZLEME, LIGHTBOX VE KALDIRMA
// -----------------------------------------------------------------------
function handleDocumentUpload(event, docType) {
const file = event.target.files && event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function (e) {
const dataUrl = e.target.result;
appState.uploadedDocs[docType] = {
name: file.name,
dataUrl: dataUrl
};
if (docType === 'tc') {
document.getElementById('tcPreviewImg').src = dataUrl;
document.getElementById('tcFileName').textContent = file.name;
document.getElementById('tcPreviewBox').classList.remove('hidden');
} else if (docType === 'ruhsat') {
document.getElementById('ruhsatPreviewImg').src = dataUrl;
document.getElementById('ruhsatFileName').textContent = file.name;
document.getElementById('ruhsatPreviewBox').classList.remove('hidden');
} else if (docType === 'passport') {
document.getElementById('passportPreviewImg').src = dataUrl;
document.getElementById('passportFileName').textContent = file.name;
document.getElementById('passportPreviewBox').classList.remove('hidden');
}
showToast('Görsel başarıyla yüklendi.', 'success');
};
reader.readAsDataURL(file);
}
function removeDocument(docType) {
appState.uploadedDocs[docType] = null;
if (docType === 'tc') {
document.getElementById('tcKimlikInput').value = '';
document.getElementById('tcPreviewImg').src = '';
document.getElementById('tcPreviewBox').classList.add('hidden');
} else if (docType === 'ruhsat') {
document.getElementById('ruhsatInput').value = '';
document.getElementById('ruhsatPreviewImg').src = '';
document.getElementById('ruhsatPreviewBox').classList.add('hidden');
} else if (docType === 'passport') {
document.getElementById('expatPassportInput').value = '';
document.getElementById('passportPreviewImg').src = '';
document.getElementById('passportPreviewBox').classList.add('hidden');
}
}
function openLightbox(src, caption) {
if (!src) return;
document.getElementById('lightboxImg').src = src;
document.getElementById('lightboxCaption').textContent = caption || 'Evrak Önizleme';
document.getElementById('imageLightbox').classList.remove('hidden');
}
function closeLightbox() {
document.getElementById('imageLightbox').classList.add('hidden');
}
// -----------------------------------------------------------------------
// 7. GALERİ & SAHA İŞLEM MERKEZİ (2 SEKME + DİNAMİK TAKSİT KURALLARI)
// -----------------------------------------------------------------------
function switchFieldTab(tabIndex) {
const btn1 = document.getElementById('fieldTabBtn1');
const btn2 = document.getElementById('fieldTabBtn2');
const panel1 = document.getElementById('fieldTabPanel1');
const panel2 = document.getElementById('fieldTabPanel2');
if (tabIndex === 1) {
btn1.className = 'px-5 py-3 rounded-xl text-xs sm:text-sm font-bold bg-amberbrand text-navy shadow-md transition-all flex items-center gap-2';
btn2.className = 'px-5 py-3 rounded-xl text-xs sm:text-sm font-semibold text-white hover:bg-white/15 transition-all flex items-center gap-2';
panel1.classList.remove('hidden');
panel2.classList.add('hidden');
} else {
btn2.className = 'px-5 py-3 rounded-xl text-xs sm:text-sm font-bold bg-amberbrand text-navy shadow-md transition-all flex items-center gap-2';
btn1.className = 'px-5 py-3 rounded-xl text-xs sm:text-sm font-semibold text-white hover:bg-white/15 transition-all flex items-center gap-2';
panel2.classList.remove('hidden');
panel1.classList.add('hidden');
}
}
function reloadQuoteIframe() {
const iframe = document.getElementById('hizliTeklifIframe');
iframe.src = iframe.src;
showToast('Online teklif ekranı yenileniyor...', 'info');
}
// Saha Temsilcisi Bilgilerini localStorage ile Kaydetme ve Yükleme
function saveRepToStorage() {
const repName = document.getElementById('repName').value;
const repPhone = document.getElementById('repPhone').value;
try {
localStorage.setItem('unver_field_rep', JSON.stringify({ repName, repPhone }));
if (repName.trim() || repPhone.trim()) {
document.getElementById('repSavedBadge').classList.remove('hidden');
}
} catch (e) {
// Storage erişim hatası yoksayılır
}
}
function loadRepFromStorage() {
try {
const raw = localStorage.getItem('unver_field_rep');
if (!raw) return;
const data = JSON.parse(raw);
if (data.repName) document.getElementById('repName').value = data.repName;
if (data.repPhone) document.getElementById('repPhone').value = data.repPhone;
if (data.repName || data.repPhone) {
document.getElementById('repSavedBadge').classList.remove('hidden');
}
} catch (e) {
// Hata yoksayılır
}
}
// Para Birimi Biçimlendirme (Binlik Ayırıcı Nokta)
function parseNumericTL(str) {
const digits = String(str || '').replace(/\D/g, '');
return digits ? parseInt(digits, 10) : 0;
}
function formatNumberTR(num) {
if (!num || num = 2000000) {
maxAllowedMonths = 12;
hintText = '2.000.000 TL ve üzeri: Yalnızca 1–12 ay taksit grubu açık (13–36 ay kilitli).';
} else if (kaskoValue >= 1000001) {
maxAllowedMonths = 24;
hintText = '1.000.001 – 1.999.999 TL arası: 24 aya kadar açık (25–36 ay kilitli).';
}
document.getElementById('kaskoRuleHint').textContent = hintText;
// Grup 2 (13-24 Ay) ve Grup 3 (25-36 Ay) Kilit Durumlarını Güncelle
updateTermGroupUI('termGroup1', 'termGroup1Status', true);
updateTermGroupUI('termGroup2', 'termGroup2Status', maxAllowedMonths >= 24);
updateTermGroupUI('termGroup3', 'termGroup3Status', maxAllowedMonths >= 36);
// Seçili vade yeni sınırın üstünde kaldıysa otomatik sıfırla ve uyarı göster
const warningBox = document.getElementById('installmentResetWarning');
const warningText = document.getElementById('installmentResetWarningText');
if (appState.selectedInstallment !== null && appState.selectedInstallment > maxAllowedMonths) {
const previousTerm = appState.selectedInstallment;
appState.selectedInstallment = null;
refreshInstallmentButtonsUI();
warningText.textContent = `Araç kasko değeri (${formatNumberTR(kaskoValue)} TL) nedeniyle daha önce seçilen ${previousTerm} ay vade sınır dışında kaldığı için otomatik sıfırlandı. Lütfen açık olan gruplardan (en fazla ${maxAllowedMonths} ay) yeniden seçim yapın.`;
warningBox.classList.remove('hidden');
showToast(`Vade sınırı değişti: ${previousTerm} ay seçimi sıfırlandı.`, 'warning');
} else {
warningBox.classList.add('hidden');
}
}
function updateTermGroupUI(groupId, statusId, isUnlocked) {
const groupEl = document.getElementById(groupId);
const statusEl = document.getElementById(statusId);
const buttons = groupEl.querySelectorAll('.term-btn');
if (isUnlocked) {
groupEl.classList.remove('border-slate-200', 'bg-slate-100/80', 'opacity-65');
groupEl.classList.add('border-emerald-200', 'bg-white');
statusEl.textContent = 'Açık';
statusEl.className = 'text-[11px] font-bold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-md';
buttons.forEach(btn => {
btn.disabled = false;
btn.classList.remove('cursor-not-allowed', 'bg-slate-100', 'text-slate-400');
});
} else {
groupEl.classList.remove('border-emerald-200', 'bg-white');
groupEl.classList.add('border-slate-200', 'bg-slate-100/80', 'opacity-65');
statusEl.textContent = '🔒 Kilitli';
statusEl.className = 'text-[11px] font-bold text-red-700 bg-red-50 px-2 py-0.5 rounded-md';
buttons.forEach(btn => {
btn.disabled = true;
btn.classList.add('cursor-not-allowed', 'bg-slate-100', 'text-slate-400');
});
}
}
function selectInstallment(months) {
appState.selectedInstallment = months;
document.getElementById('installmentResetWarning').classList.add('hidden');
refreshInstallmentButtonsUI();
}
function refreshInstallmentButtonsUI() {
const badge = document.getElementById('selectedInstallmentBadge');
if (appState.selectedInstallment) {
badge.textContent = `Seçili Vade: ${appState.selectedInstallment} Ay`;
badge.className = 'text-xs font-extrabold px-3.5 py-1 rounded-full bg-navy text-amberbrand';
} else {
badge.textContent = 'Seçili Vade: Henüz Seçilmedi';
badge.className = 'text-xs font-bold px-3 py-1 rounded-full bg-slate-200 text-slate-700';
}
document.querySelectorAll('.term-btn').forEach(btn => {
const m = parseInt(btn.dataset.months, 10);
if (m === appState.selectedInstallment) {
btn.classList.remove('border-slate-200', 'text-slate-700', 'bg-white');
btn.classList.add('bg-navy', 'text-white', 'border-navy', 'shadow-sm');
} else {
btn.classList.remove('bg-navy', 'text-white', 'border-navy', 'shadow-sm');
btn.classList.add('border-slate-200', 'text-slate-700');
}
});
}
function resetFieldCreditForm() {
document.getElementById('fieldCreditForm').reset();
loadRepFromStorage();
removeDocument('tc');
removeDocument('ruhsat');
appState.selectedInstallment = null;
refreshInstallmentButtonsUI();
evaluateInstallmentRules(0);
showToast('Form alanları temizlendi.', 'info');
}
// Başvuru Özeti Oluşturma ve Gönderim Modalını Açma
function submitFieldCreditForm(event) {
event.preventDefault();
if (!appState.selectedInstallment) {
showToast('Lütfen açık olan taksit gruplarından bir vade seçiniz.', 'warning');
document.getElementById('selectedInstallmentBadge').scrollIntoView({ behavior: 'smooth', block: 'center' });
return;
}
const repName = document.getElementById('repName').value.trim();
const repPhone = document.getElementById('repPhone').value.trim();
const appType = document.getElementById('appType').value;
const buyerTcNo = document.getElementById('buyerTcNo').value.trim();
const buyerDob = document.getElementById('buyerDob').value;
const buyerPhone = document.getElementById('buyerPhone').value.trim();
const sellerName = document.getElementById('sellerName').value.trim();
const sellerTaxTc = document.getElementById('sellerTaxTc').value.trim();
const sellerPhone = document.getElementById('sellerPhone').value.trim();
const brokerName = document.getElementById('brokerName').value.trim() || 'Belirtilmedi';
const brokerPhone = document.getElementById('brokerPhone').value.trim() || 'Belirtilmedi';
const carPlate = document.getElementById('carPlate').value.trim();
const ruhsatNo = document.getElementById('ruhsatNo').value.trim();
const kaskoVal = document.getElementById('kaskoValueInput').value.trim();
const creditAmt = document.getElementById('creditAmountInput').value.trim();
const downPay = document.getElementById('downPaymentInput').value.trim();
const termMonths = appState.selectedInstallment;
const tcStatus = appState.uploadedDocs.tc ? `Yüklendi (${appState.uploadedDocs.tc.name})` : 'Yüklenmedi';
const ruhsatStatus = appState.uploadedDocs.ruhsat ? `Yüklendi (${appState.uploadedDocs.ruhsat.name})` : 'Yüklenmedi';
const summaryText =
`ÜNVER SİGORTA — GALERİ & SAHA BAŞVURU ÖZETİ
==================================================
• Başvuru Türü: ${appType}
• Saha Temsilcisi: ${repName} (${repPhone})
[ALICI BİLGİLERİ]
• T.C. Kimlik No: ${buyerTcNo}
• Doğum Tarihi: ${buyerDob}
• Alıcı Tel: ${buyerPhone}
• T.C. Kimlik Görseli: ${tcStatus}
[SATICI & ARACI BİLGİLERİ]
• Satıcı (Galeri/Kişi): ${sellerName}
• Satıcı Vergi / T.C. No: ${sellerTaxTc}
• Satıcı Tel: ${sellerPhone}
• Aracı Bilgisi: ${brokerName} (${brokerPhone})
[ARAÇ & KREDİ DETAYLARI]
• Plaka: ${carPlate}
• Ruhsat Seri / No: ${ruhsatNo}
• Ruhsat Görseli: ${ruhsatStatus}
• Araç Kasko Değeri: ${kaskoVal} TL
• Başvurulan Kredi Tutarı: ${creditAmt} TL
• Peşinat Miktarı: ${downPay} TL
• Seçilen Vade: ${termMonths} Ay
==================================================`;
document.getElementById('fieldSummaryText').textContent = summaryText;
// Modal içindeki evrak önizlemelerini ayarla
const modalTcCard = document.getElementById('modalTcCard');
const modalRuhsatCard = document.getElementById('modalRuhsatCard');
if (appState.uploadedDocs.tc) {
document.getElementById('modalTcImg').src = appState.uploadedDocs.tc.dataUrl;
modalTcCard.classList.remove('hidden');
} else {
modalTcCard.classList.add('hidden');
}
if (appState.uploadedDocs.ruhsat) {
document.getElementById('modalRuhsatImg').src = appState.uploadedDocs.ruhsat.dataUrl;
modalRuhsatCard.classList.remove('hidden');
} else {
modalRuhsatCard.classList.add('hidden');
}
// E-Posta (mailto:unvermurataem@gmail.com) ve WhatsApp bağlantılarını hazırla
const emailSubject = encodeURIComponent(`Saha Başvurusu: ${carPlate} - ${appType} (${repName})`);
const emailBody = encodeURIComponent(summaryText + '\n\nNot: Yüklenen T.C. Kimlik ve Ruhsat fotoğraflarını e-postaya ekleyebilirsiniz.');
document.getElementById('modalMailtoBtn').href = `mailto:${TARGET_EMAIL}?subject=${emailSubject}&body=${emailBody}`;
const waUrl = `https://wa.me/${WHATSAPP_NUMBER}?text=${encodeURIComponent(summaryText)}`;
document.getElementById('modalWhatsappBtn').href = waUrl;
// Modalı aç
document.getElementById('fieldSummaryModal').classList.remove('hidden');
}
function closeFieldSummaryModal() {
document.getElementById('fieldSummaryModal').classList.add('hidden');
}
// Panoya Kopyalama (Iframe kısıtlamalarına karşı execCommand destekli)
function copyFieldSummary() {
const text = document.getElementById('fieldSummaryText').textContent;
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand('copy');
showToast('Başvuru özeti panoya kopyalandı!', 'success');
} catch (err) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
showToast('Başvuru özeti panoya kopyalandı!', 'success');
});
}
} finally {
document.body.removeChild(textarea);
}
}
// -----------------------------------------------------------------------
// 8. İLETİŞİM SAYFASI MESAJ FORMU
// -----------------------------------------------------------------------
function submitContactForm(event) {
event.preventDefault();
const name = document.getElementById('contactName').value.trim();
const phone = document.getElementById('contactPhone').value.trim();
const message = document.getElementById('contactMessage').value.trim();
const fullMsg =
`Merhaba Ünver Sigorta,\n` +
`İletişim sayfasından mesaj gönderiyorum:\n\n` +
`• Ad Soyad: ${name}\n` +
`• Telefon: ${phone}\n` +
`• Mesaj: ${message}`;
showToast('Mesajınız WhatsApp üzerinden iletiliyor...', 'success');
window.open(`https://wa.me/${WHATSAPP_NUMBER}?text=${encodeURIComponent(fullMsg)}`, '_blank', 'noopener,noreferrer');
}
// -----------------------------------------------------------------------
// 9. SAYFA YÜKLENDİĞİNDE BAŞLATMA
// -----------------------------------------------------------------------
document.addEventListener('DOMContentLoaded', () => {
renderServices('all');
loadRepFromStorage();
evaluateInstallmentRules(0);
});