<?php
/**
 * Ziyaretçi ve Kullanıcılar İçin - Deneme ve Sınav Takvimi
 * Konum: /magaza/deneme-sinav-takvimi.php
 */

require_once 'includes/db.php';
require_once 'includes/functions.php';

$kok_dizin = "/magaza/";

// Türkçe Aylar için Yardımcı Dizi
$aylar_tr = [
    '01' => 'Ocak', '02' => 'Şubat', '03' => 'Mart', '04' => 'Nisan',
    '05' => 'Mayıs', '06' => 'Haziran', '07' => 'Temmuz', '08' => 'Ağustos',
    '09' => 'Eylül', '10' => 'Ekim', '11' => 'Kasım', '12' => 'Aralık'
];

// Mevcut Yıl ve Ay
$current_year = date('Y');
$current_month = date('m');

// Takvim Verilerini Çek (Tüm aktif sınavlar, geçmiş ve gelecek dahil)
$sql = "
    SELECT 
        ec.title, 
        ec.exam_type, 
        ec.exam_date, 
        ec.application_start_date, 
        ec.application_end_date, 
        1 as is_official, 
        ec.description,
        NULL as product_id, 
        NULL as slug, 
        NULL as price, 
        NULL as stock_quantity, 
        NULL as brand_name,
        'assets/img/no-image.jpg' as main_image,
        1 as product_status
    FROM exam_calendar ec
    WHERE ec.status = 1 AND ec.is_official = 1

    UNION ALL

    SELECT 
        p.name as title, 
        p.exam_type, 
        p.exam_date, 
        NULL as application_start_date, 
        NULL as application_end_date, 
        0 as is_official, 
        p.description,
        p.id as product_id, 
        p.slug, 
        p.price, 
        p.stock_quantity, 
        b.name as brand_name,
        COALESCE(
            (SELECT image_path FROM product_images WHERE product_id = p.id AND is_main = 1 LIMIT 1),
            b.default_cover,
            'assets/img/no-image.jpg'
        ) as main_image,
        p.status as product_status
    FROM products p
    LEFT JOIN brands b ON p.brand_id = b.id
    WHERE p.type = 'single_exam' AND p.exam_date IS NOT NULL

    ORDER BY exam_date ASC
";

$stmt = $db->query($sql);
$raw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Verileri "Yıl - Ay" Şeklinde Gruplama ve Filtre Seçenekleri Çıkarma
$takvim_gruplu = [];
$turler = [];
$yillar = [];

foreach($raw_data as $item) {
    $tarihObj = new DateTime($item['exam_date']);
    $ay_no = $tarihObj->format('m');
    $yil = $tarihObj->format('Y');
    
    // Veriyi HTML içinde gruplamak için Yıl-Ay bazlı key oluşturuyoruz (Örn: 2026-04)
    $grup_key = $yil . '-' . $ay_no;
    
    $takvim_gruplu[$grup_key][] = $item;

    if(!empty($item['exam_type']) && !in_array($item['exam_type'], $turler)) {
        $turler[] = $item['exam_type'];
    }
    if(!in_array($yil, $yillar)) {
        $yillar[] = $yil;
    }
}
sort($turler);
sort($yillar); 

// Eğer mevcut yıl veritabanında yoksa bile filtrede görünsün
if(!in_array($current_year, $yillar)) {
    $yillar[] = $current_year;
    sort($yillar);
}

$bugun = new DateTime('midnight'); 

$page_title = "Sınav ve Türkiye Geneli Deneme Takvimi | SINAVKOCU Mağaza";
$meta_description = "YKS, LGS resmi sınav tarihleri, başvuru süreçleri ve Türkiye geneli yayın denemelerinin takvimi. Tarihleri kaçırma!";

// DÜZELTİLMİŞ KISIM: Değişken adı $page_og_image yapıldı ve URL düzeltildi
$page_og_image = "https://www.sinavkocu.tr/magaza/uploads/deneme-sinav-takvimi.png";

require_once 'header.php';
?>

<style>
    .calendar-card { transition: all 0.3s ease; border-left: 5px solid transparent; }
    .calendar-card:hover { transform: translateX(5px); box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important; }
    .official-border { border-left-color: #dc3545 !important; } 
    .trial-border { border-left-color: #0d6efd !important; } 
    
    /* Sadece resmi sınavlar geçmişteyse soluklassın. Satışta olan yayın denemeleri canlı kalsın! */
    .past-official-event { opacity: 0.6; filter: grayscale(50%); } 
    
    .date-box { min-width: 90px; }
    .blink-icon { animation: blinker 1.5s linear infinite; }
    @keyframes blinker { 50% { opacity: 0; } }
    .month-divider { position: relative; text-align: center; margin: 2rem 0 1.5rem 0; z-index: 1; }
    .month-divider::before { content: ""; position: absolute; left: 0; top: 50%; width: 100%; height: 2px; background: #e9ecef; z-index: -1; }
    .month-divider span { background: #fff; padding: 0 15px; font-weight: 800; color: #6c757d; font-size: 1.1rem; border-radius: 20px; border: 2px solid #e9ecef;}
</style>

<main class="container py-5 text-dark">
    
    <div class="text-center mb-5">
        <span class="badge bg-danger bg-opacity-10 text-danger px-3 py-2 rounded-pill mb-3 fs-6 shadow-sm">
            <i class="bi bi-calendar2-event-fill me-1"></i> Güncel Deneme Takvimi ve Sınav Takvimi
        </span>
        <h1 class="display-5 fw-bold text-dark mb-3">Sınav ve Deneme Takvimi</h1>
        <p class="text-muted lead mx-auto" style="max-width: 800px;">
            ÖSYM/MEB sınavlarına kaç gün kaldığını takip et, başvuruları kaçırma ve Türkiye geneli yayın denemelerini tarihleri geçmeden sipariş ver.
        </p>
    </div>

    <div class="row g-4">
        
        <div class="col-lg-3">
            <div class="card shadow-sm border-0 rounded-4 sticky-top" style="top: 120px; z-index: 100;">
                <div class="card-header bg-dark text-white rounded-top-4 py-3">
                    <h5 class="card-title mb-0 fw-bold fs-6 text-uppercase"><i class="bi bi-funnel-fill me-2 text-warning"></i>Takvimi Filtrele</h5>
                </div>
                <div class="card-body p-4">
                    
                    <div class="mb-4">
                        <label class="form-label fw-bold small text-muted text-uppercase">Sınav / Yayın Ara</label>
                        <div class="input-group">
                            <span class="input-group-text bg-light border-end-0"><i class="bi bi-search text-muted"></i></span>
                            <input type="text" id="searchFilter" class="form-control border-start-0 bg-light" placeholder="Örn: YKS, 345...">
                        </div>
                    </div>

                    <div class="mb-4">
                        <div class="row g-2">
                            <div class="col-6">
                                <label class="form-label fw-bold small text-muted text-uppercase">Yıl</label>
                                <select id="yearFilter" class="form-select border-2">
                                    <?php foreach($yillar as $y): ?>
                                        <option value="<?= $y ?>" <?= ($y == $current_year) ? 'selected' : '' ?>><?= $y ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class="col-6">
                                <label class="form-label fw-bold small text-muted text-uppercase">Ay</label>
                                <select id="monthFilter" class="form-select border-2">
                                    <?php foreach($aylar_tr as $num => $name): ?>
                                        <option value="<?= $num ?>" <?= ($num == $current_month) ? 'selected' : '' ?>><?= $name ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="mb-4">
                        <label class="form-label fw-bold small text-muted text-uppercase">Nitelik</label>
                        <select id="officialFilter" class="form-select border-2">
                            <option value="all">Tüm Kayıtlar</option>
                            <option value="1">Sadece Resmi Sınavlar (ÖSYM/MEB)</option>
                            <option value="0">Sadece Yayın Denemeleri</option>
                        </select>
                    </div>

                    <div class="mb-0">
                        <label class="form-label fw-bold small text-muted text-uppercase">Sınav Türü</label>
                        <div class="d-flex flex-column gap-2">
                            <div class="form-check">
                                <input class="form-check-input type-filter" type="radio" name="typeFilter" value="all" id="typeAll" checked>
                                <label class="form-check-label fw-bold" for="typeAll">Tüm Türler</label>
                            </div>
                            <?php foreach($turler as $t): ?>
                            <div class="form-check">
                                <input class="form-check-input type-filter" type="radio" name="typeFilter" value="<?= htmlspecialchars($t) ?>" id="type_<?= htmlspecialchars($t) ?>">
                                <label class="form-check-label" for="type_<?= htmlspecialchars($t) ?>"><?= htmlspecialchars($t) ?></label>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    </div>

                </div>
            </div>
        </div>

        <div class="col-lg-9">
            <div id="calendarList">
                <?php if(count($takvim_gruplu) > 0): ?>
                    <?php foreach($takvim_gruplu as $grup_key => $items): 
                        // Grup key'den Yıl ve Ay bilgisini çıkaralım
                        $p = explode('-', $grup_key);
                        $grup_yil = $p[0];
                        $grup_ay = $p[1];
                        $grup_basligi = $aylar_tr[$grup_ay] . " " . $grup_yil;
                    ?>
                        
                        <div class="month-group-container" data-group-year="<?= $grup_yil ?>" data-group-month="<?= $grup_ay ?>">
                            <div class="month-divider month-group-header">
                                <span><?= $grup_basligi ?></span>
                            </div>

                            <?php foreach($items as $item): 
                                $tarihObj = new DateTime($item['exam_date']);
                                $gun = $tarihObj->format('d');
                                
                                $gecmis_mi = ($tarihObj < $bugun);
                                $is_official = $item['is_official'] == 1;
                                $border_class = $is_official ? 'official-border' : 'trial-border';
                                
                                // SATIŞTA OLAN YAYIN DENEMESİ GEÇMİŞ OLSA BİLE SOLUKLAŞMAZ! SADECE RESMİ SINAV SOLUKLAŞIR.
                                $past_class = ($gecmis_mi && $is_official) ? 'past-official-event' : '';
                                
                                $app_badge = '';
                                if($is_official && !empty($item['application_start_date']) && !empty($item['application_end_date'])) {
                                    $appStart = new DateTime($item['application_start_date']);
                                    $appEnd = new DateTime($item['application_end_date']);
                                    $appEnd->modify('+23 hours 59 minutes 59 seconds'); 
                                    
                                    if($bugun < $appStart) {
                                        $app_badge = '<div class="alert alert-secondary py-1 px-2 mb-3 small fw-bold text-center border-secondary"><i class="bi bi-info-circle me-1"></i> Başvurular: ' . $appStart->format('d.m.Y') . ' başlıyor</div>';
                                    } elseif($bugun >= $appStart && $bugun <= $appEnd) {
                                        $diff = $bugun->diff($appEnd);
                                        $kalan_gun = $diff->days;
                                        $app_badge = '<div class="alert alert-warning py-1 px-2 mb-3 small fw-bold text-center border-warning text-dark"><i class="bi bi-bell-fill text-danger blink-icon me-1"></i> Başvuru Devam Ediyor (Son '.$kalan_gun.' Gün)</div>';
                                    } else {
                                        $app_badge = '<div class="alert alert-danger py-1 px-2 mb-3 small fw-bold text-center opacity-75 border-danger"><i class="bi bi-x-circle me-1"></i> Başvurular Sona Erdi</div>';
                                    }
                                }

                                $share_text = urlencode($item['title'] . " tarihi: " . $gun . " " . $aylar_tr[$grup_ay] . " " . $grup_yil . " 👉 SINAVKOCU Takviminde incele!");
                                $share_url = "https://api.whatsapp.com/send?text=" . $share_text;
                            ?>
                                <div class="card shadow-sm border-0 rounded-4 mb-3 calendar-card <?= $border_class ?> <?= $past_class ?> calendar-item"
                                     data-title="<?= mb_strtolower($item['title'] . ' ' . $item['brand_name']) ?>"
                                     data-type="<?= htmlspecialchars($item['exam_type']) ?>"
                                     data-official="<?= $item['is_official'] ?>">
                                     
                                    <div class="row g-0 align-items-center h-100">
                                        
                                        <div class="col-md-2 text-center p-3 border-end bg-light rounded-start-4 date-box d-flex flex-column justify-content-center h-100" style="min-height: 160px;">
                                            <span class="display-5 fw-bold text-dark mb-0 lh-1"><?= $gun ?></span>
                                            <span class="text-uppercase fw-bold text-primary mt-1"><?= $aylar_tr[$grup_ay] ?></span>
                                            <span class="text-muted small"><?= $grup_yil ?></span>
                                        </div>
                                        
                                        <div class="col-md-7 p-4">
                                            <div class="d-flex align-items-center gap-2 mb-2">
                                                <span class="badge bg-secondary"><?= htmlspecialchars($item['exam_type'] ?? 'Genel') ?></span>
                                                <?php if($is_official): ?>
                                                    <span class="badge bg-danger"><i class="bi bi-bank me-1"></i>Resmi Sınav</span>
                                                <?php else: ?>
                                                    <span class="badge bg-info text-dark"><i class="bi bi-journal-bookmark me-1"></i>Türkiye Geneli</span>
                                                    <?php if($item['brand_name']): ?>
                                                        <span class="badge bg-light text-dark border"><?= htmlspecialchars($item['brand_name']) ?></span>
                                                    <?php endif; ?>
                                                <?php endif; ?>
                                            </div>
                                            
                                            <h4 class="fw-bold mb-2 text-dark"><?= htmlspecialchars($item['title']) ?></h4>
                                            
                                            <?php if(!empty($item['description'])): ?>
                                                <p class="text-muted small mb-3 mb-md-0 line-clamp-2"><?= htmlspecialchars($item['description']) ?></p>
                                            <?php endif; ?>
                                        </div>
                                        
                                        <div class="col-md-3 p-4 text-center rounded-end-4 d-flex flex-column justify-content-center border-start bg-light h-100">
                                            
                                            <?php if($is_official): ?>
                                                <?php if($gecmis_mi): ?>
                                                    <div class="text-muted fw-bold mb-2"><i class="bi bi-check2-circle fs-4 d-block text-success"></i> Sınav Tamamlandı</div>
                                                <?php else: ?>
                                                    <?= $app_badge ?>
                                                    <div class="countdown-wrapper mb-2" data-date="<?= $item['exam_date'] ?>T00:00:00">
                                                        <span class="d-block small text-muted fw-bold mb-1">Sınava Kalan Zaman</span>
                                                        <div class="d-flex justify-content-center gap-2 fw-bold text-danger">
                                                            <div><span class="fs-4 d-block lh-1 days">00</span><small style="font-size:0.6rem;">GÜN</small></div>
                                                            <div><span class="fs-4 d-block lh-1 hours">00</span><small style="font-size:0.6rem;">SAAT</small></div>
                                                        </div>
                                                    </div>
                                                <?php endif; ?>
                                                
                                            <?php else: ?>
                                                <?php if($item['product_id'] && $item['stock_quantity'] > 0 && $item['product_status'] == 1): ?>
                                                    <div class="fs-5 fw-bold text-primary mb-2"><?= number_format($item['price'], 2, ',', '.') ?> ₺</div>
                                                    <a href="<?= $kok_dizin ?>urun/<?= $item['slug'] ?>" class="btn btn-success btn-sm rounded-pill fw-bold w-100 shadow-sm">
                                                        <i class="bi bi-cart-plus me-1"></i> İncele / Al
                                                    </a>
                                                <?php elseif($item['product_id']): ?>
                                                    <div class="text-danger fw-bold small mb-2"><i class="bi bi-x-circle me-1"></i><?= ($item['product_status'] == 0) ? 'Satışa Kapalı' : 'Stok Tükendi' ?></div>
                                                    <button class="btn btn-warning btn-sm rounded-pill w-100 fw-bold btn-notify" data-product="<?= $item['product_id'] ?>"><i class="bi bi-bell"></i> Gelince Haber Ver</button>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                            
                                            <a href="<?= $share_url ?>" target="_blank" class="text-decoration-none text-success small mt-3 d-inline-block fw-bold">
                                                <i class="bi bi-whatsapp"></i> Arkadaşınla Paylaş
                                            </a>
                                            
                                        </div>
                                    </div>
                                </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endforeach; ?>
                <?php else: ?>
                    <div class="alert alert-warning text-center border-0 shadow-sm rounded-4 py-5">
                        <i class="bi bi-calendar-x fs-1 d-block mb-3 text-warning opacity-75"></i>
                        <h4 class="fw-bold">Takvim Boş</h4>
                        <p class="text-muted">Bu aya ait bir sınav bulunamadı.</p>
                    </div>
                <?php endif; ?>
            </div>
            
            <div id="noMonthDataMsg" style="display:none;" class="alert alert-warning text-center border-0 shadow-sm rounded-4 py-5 mt-3">
                <i class="bi bi-calendar-x fs-1 d-block mb-3 text-warning opacity-75"></i>
                <h4 class="fw-bold">Takvim Kaydı Yok</h4>
                <p class="text-muted">Seçtiğiniz Yıl ve Ay'a ait herhangi bir sınav veya deneme bulunamadı.</p>
            </div>

            <div id="noResultMsg" style="display:none;" class="text-center py-5 mt-3">
                <i class="bi bi-search fs-1 text-muted opacity-25"></i>
                <h5 class="fw-bold mt-3 text-muted">Aramanıza uygun sonuç bulunamadı.</h5>
            </div>

        </div>
    </div>
</main>

<script>
const isUserLoggedIn = <?= isset($_SESSION['user_id']) ? 'true' : 'false' ?>;

document.addEventListener("DOMContentLoaded", function() {
    
    const searchInput = document.getElementById('searchFilter');
    const officialSelect = document.getElementById('officialFilter');
    const yearSelect = document.getElementById('yearFilter');
    const monthSelect = document.getElementById('monthFilter');
    const typeRadios = document.querySelectorAll('.type-filter');
    const noResultMsg = document.getElementById('noResultMsg');
    const noMonthDataMsg = document.getElementById('noMonthDataMsg');
    const monthGroups = document.querySelectorAll('.month-group-container');

    function applyFilters() {
        const searchTerm = searchInput.value.toLowerCase().trim();
        const selectedOfficial = officialSelect.value;
        const selectedYear = yearSelect.value;
        const selectedMonth = monthSelect.value;
        const selectedType = document.querySelector('.type-filter:checked').value;
        
        let hasAnyVisibleMonth = false;
        let hasAnyMatchInVisibleMonth = false;

        monthGroups.forEach(group => {
            const groupYear = group.getAttribute('data-group-year');
            const groupMonth = group.getAttribute('data-group-month');
            
            if(selectedYear === groupYear && selectedMonth === groupMonth) {
                group.style.display = 'block';
                hasAnyVisibleMonth = true;
                
                let itemsInGroup = group.querySelectorAll('.calendar-item');
                let groupHasMatch = false;

                itemsInGroup.forEach(item => {
                    const title = item.getAttribute('data-title');
                    const type = item.getAttribute('data-type');
                    const isOfficial = item.getAttribute('data-official');
                    
                    const matchSearch = title.includes(searchTerm);
                    const matchOfficial = (selectedOfficial === 'all') || (isOfficial === selectedOfficial);
                    const matchType = (selectedType === 'all') || (type === selectedType);
                    
                    if (matchSearch && matchOfficial && matchType) {
                        item.style.display = 'block'; 
                        groupHasMatch = true;
                        hasAnyMatchInVisibleMonth = true;
                    } else {
                        item.style.display = 'none';
                    }
                });

                if(!groupHasMatch) {
                    group.querySelector('.month-divider').style.display = 'none';
                } else {
                    group.querySelector('.month-divider').style.display = 'block';
                }

            } else {
                group.style.display = 'none';
            }
        });
        
        if(!hasAnyVisibleMonth) {
            noMonthDataMsg.style.display = 'block';
            noResultMsg.style.display = 'none';
        } else if (!hasAnyMatchInVisibleMonth) {
            noMonthDataMsg.style.display = 'none';
            noResultMsg.style.display = 'block';
        } else {
            noMonthDataMsg.style.display = 'none';
            noResultMsg.style.display = 'none';
        }
    }

    searchInput.addEventListener('input', applyFilters);
    officialSelect.addEventListener('change', applyFilters);
    yearSelect.addEventListener('change', applyFilters);
    monthSelect.addEventListener('change', applyFilters);
    typeRadios.forEach(radio => radio.addEventListener('change', applyFilters));

    // Sayfa ilk açıldığında doğrudan Mevcut Ay ve Yılı uygular
    applyFilters();

    const countdownElements = document.querySelectorAll('.countdown-wrapper');
    function updateCountdowns() {
        const now = new Date().getTime();
        countdownElements.forEach(wrapper => {
            const targetDate = new Date(wrapper.getAttribute('data-date')).getTime();
            const distance = targetDate - now;
            if (distance < 0) {
                wrapper.innerHTML = '<span class="text-success fw-bold"><i class="bi bi-check2-circle"></i> Sınav Başladı/Bitti!</span>';
                return;
            }
            const days = Math.floor(distance / (1000 * 60 * 60 * 24));
            const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            wrapper.querySelector('.days').innerText = days.toString().padStart(2, '0');
            wrapper.querySelector('.hours').innerText = hours.toString().padStart(2, '0');
        });
    }
    updateCountdowns();
    setInterval(updateCountdowns, 60000); 

    // GELİNCE HABER VER BUTONU VE FORMU
    document.querySelectorAll('.btn-notify').forEach(btn => {
        btn.addEventListener('click', function() {
            const productId = this.getAttribute('data-product');
            if (isUserLoggedIn) {
                sendNotifyRequest(productId, '', '', '');
            } else {
                Swal.fire({
                    title: 'Gelince Haber Ver',
                    html: `
                        <div class="text-start px-3">
                            <label class="small fw-bold">Ad Soyad *</label>
                            <input type="text" id="notifyName" class="form-control mb-2" placeholder="Adınız Soyadınız">
                            <label class="small fw-bold">E-posta *</label>
                            <input type="email" id="notifyEmail" class="form-control mb-2" placeholder="E-posta adresiniz">
                            <label class="small fw-bold">Telefon</label>
                            <input type="text" id="notifyPhone" class="form-control mb-3" placeholder="Telefon numaranız (Opsiyonel)">
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" id="kvkkCheck">
                                <label class="form-check-label small text-muted" for="kvkkCheck">
                                    <a href="<?= $kok_dizin ?>sayfa/gizlilik-ve-kisisel-verilerinin-korunmasi-politikasi" target="_blank" class="text-primary text-decoration-none">KVKK Aydınlatma Metni</a>'ni okudum, onaylıyorum.
                                </label>
                            </div>
                        </div>
                    `,
                    showCancelButton: true,
                    confirmButtonText: 'Kaydet',
                    cancelButtonText: 'İptal',
                    preConfirm: () => {
                        const name = document.getElementById('notifyName').value.trim();
                        const email = document.getElementById('notifyEmail').value.trim();
                        const phone = document.getElementById('notifyPhone').value.trim();
                        const kvkk = document.getElementById('kvkkCheck').checked;
                        
                        if (!name) { Swal.showValidationMessage('Lütfen ad soyad giriniz.'); return false; }
                        if (!email && !phone) { Swal.showValidationMessage('Lütfen e-posta veya telefon giriniz.'); return false; }
                        if (!kvkk) { Swal.showValidationMessage('Lütfen KVKK metnini onaylayınız.'); return false; }
                        
                        return { name: name, email: email, phone: phone };
                    }
                }).then((result) => {
                    if (result.isConfirmed) { 
                        sendNotifyRequest(productId, result.value.name, result.value.email, result.value.phone); 
                    }
                });
            }
        });
    });

    function sendNotifyRequest(productId, name, email, phone) {
        let formData = new FormData();
        formData.append('product_id', productId);
        formData.append('name', name);
        formData.append('email', email);
        formData.append('phone', phone);
        
        fetch('<?= $kok_dizin ?>ajax-haber-ver.php', { method: 'POST', body: formData })
        .then(response => response.json())
        .then(data => {
            Swal.fire({
                icon: data.status === 'error' ? 'error' : (data.status === 'info' ? 'info' : 'success'),
                title: data.status === 'success' ? 'Harika!' : 'Bilgi',
                text: data.message,
                confirmButtonColor: '#0d6efd'
            });
        });
    }
});
</script>

<?php require_once 'footer.php'; ?>