load(); $db = getDbConnection(); // Handle form submissions if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['create_template'])) { $stmt = $db->prepare(" INSERT INTO block_templates (channel, name, day_of_week, default_start_time, default_end_time, is_active) VALUES (?, ?, ?, ?, ?, 1) "); $stmt->execute([ $_POST['channel'], $_POST['name'], $_POST['day_of_week'], $_POST['default_start_time'], $_POST['default_end_time'] ?: null ]); header('Location: blocks.php?success=created'); exit; } if (isset($_POST['update_template'])) { $stmt = $db->prepare(" UPDATE block_templates SET channel = ?, name = ?, day_of_week = ?, default_start_time = ?, default_end_time = ? WHERE id = ? "); $stmt->execute([ $_POST['channel'], $_POST['name'], $_POST['day_of_week'], $_POST['default_start_time'], $_POST['default_end_time'] ?: null, $_POST['template_id'] ]); header('Location: blocks.php?success=updated'); exit; } if (isset($_POST['toggle_active'])) { $stmt = $db->prepare("UPDATE block_templates SET is_active = NOT is_active WHERE id = ?"); $stmt->execute([$_POST['template_id']]); header('Location: blocks.php'); exit; } if (isset($_POST['delete_template'])) { $stmt = $db->prepare("DELETE FROM block_templates WHERE id = ?"); $stmt->execute([$_POST['template_id']]); header('Location: blocks.php?success=deleted'); exit; } } // Get all templates $templates = $db->query("SELECT * FROM block_templates ORDER BY channel, day_of_week, default_start_time")->fetchAll(); // Get template for editing $editTemplate = null; if (isset($_GET['edit'])) { $stmt = $db->prepare("SELECT * FROM block_templates WHERE id = ?"); $stmt->execute([$_GET['edit']]); $editTemplate = $stmt->fetch(); } $dayNames = [ 'all' => 'Alle dagen', 'ma' => 'Maandag', 'di' => 'Dinsdag', 'wo' => 'Woensdag', 'do' => 'Donderdag', 'vr' => 'Vrijdag', 'za' => 'Zaterdag', 'zo' => 'Zondag' ]; ?>
Nog geen templates aangemaakt
| Zender | Naam | Dag | Starttijd | Eindtijd | Status | Acties |
|---|---|---|---|---|---|---|
| = htmlspecialchars($template['channel']) ?> | = htmlspecialchars($template['name']) ?> | = $dayNames[$template['day_of_week']] ?> | = substr($template['default_start_time'], 0, 5) ?> | = $template['default_end_time'] ? substr($template['default_end_time'], 0, 5) : '-' ?> | Actief Inactief |
Blok templates definiƫren terugkerende tijdslots voor uitzendingen. Bijvoorbeeld: