Offre spéciale !
Profitez de notre promotion en cours
}); } function toggleNews(id, btn) { const card = document.getElementById('news-' + id); const isCollapsed = card.classList.contains('collapsed'); card.classList.toggle('collapsed'); btn.querySelector('span').textContent = isCollapsed ? 'Réduire' : 'Lire la suite'; btn.querySelector('i').className = 'bi bi-chevron-' + (isCollapsed ? 'up' : 'down'); } function renderPagination(total, current) { const pages = Math.ceil(total / perPage); if (pages <= 1) { document.getElementById('newsPagination').innerHTML = ''; return; } let html = ''; html += ''; for (let i = 1; i <= Math.min(pages, 5); i++) { html += ''; } html += ''; document.getElementById('newsPagination').innerHTML = html; } function formatDate(dateStr) { if (!dateStr) return ''; try { const d = new Date(dateStr); return d.toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', year: 'numeric' }); } catch(e) { return dateStr; } } // ============================================= // LOAD PROMOTIONS // ============================================= function loadPromotions() { const fd = new FormData(); fd.append('action', 'get_promotions'); fetch('api_whmcs.php', { method: 'POST', body: fd }) .then(r => r.json()) .then(data => { if (data.result === 'success' && data.promotions.length > 0) { const promo = data.promotions[0]; // Premier code promo actif const banner = document.getElementById('promoBanner'); let desc = ''; if (promo.type === 'Percentage') desc = promo.value + '% de réduction'; else if (promo.type === 'Fixed Amount') desc = promo.value + ' DH de réduction'; else desc = 'Offre spéciale disponible'; document.getElementById('promoTitle').textContent = 'Promotion en cours !'; document.getElementById('promoText').textContent = desc + (promo.expires ? ' — Expire le ' + formatDate(promo.expires) : ''); document.getElementById('promoCode').textContent = promo.code || ''; banner.style.display = 'block'; } }) .catch(() => { /* silencieux */ }); } function formatDate(dateStr) { if (!dateStr) return ''; const d = new Date(dateStr); return d.toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', year: 'numeric' }); } // Initial load loadAnnouncements(1); loadPromotions();