<?php
session_start();
require_once 'config.php';
require_once 'functions.php';
requireLogin();
$user = getConnectedUser($pdo);
requireAdmin($user);

header('Content-Type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename="evenements_modele.csv"');

$out = fopen('php://output', 'w');
fprintf($out, chr(0xEF).chr(0xBB).chr(0xBF)); // BOM UTF-8 pour Excel

// En-têtes
fputcsv($out, ['title','description','event_date','location','type','language','importance','url','is_active']);

// Exemples
fputcsv($out, ['Canadiens vs Maple Leafs','Match NHL au Centre Bell','2026-06-15 19:00:00','Centre Bell, Montréal','sport','CA-FR','3','https://www.nhl.com','1']);
fputcsv($out, ['Festival de Jazz','Festival annuel de jazz','2026-07-01 18:00:00','Quartier des spectacles','artistique','CA-FR','3','https://montrealjazzfest.com','1']);
fputcsv($out, ['Tournoi local','Tournoi de balle molle','2026-06-20 09:00:00','Parc Jarry, Montréal','local','CA-FR','1','','1']);

fclose($out);
exit;
?>
