The evaluation window for $title is now open.
You have $deadline_hours hours to submit your final production rating.
"; sendSystemEmail($member_emails, $subject, $emailBody); } $success = "Evaluation window opened and committee notified for $title."; } // --- 3. HANDLE DELETE TELEDRAMA --- if (isset($_GET['delete_drama'])) { $delete_id = (int)$_GET['delete_drama']; try { $pdo->beginTransaction(); $pdo->prepare("DELETE FROM production_rating_values WHERE production_rating_id IN (SELECT id FROM production_ratings WHERE drama_id = ?)")->execute([$delete_id]); $pdo->prepare("DELETE FROM production_ratings WHERE drama_id = ?")->execute([$delete_id]); $pdo->prepare("DELETE FROM episodes WHERE drama_id = ?")->execute([$delete_id]); $pdo->prepare("DELETE FROM watch_logs WHERE drama_id = ?")->execute([$delete_id]); $pdo->prepare("DELETE FROM dramas WHERE id = ?")->execute([$delete_id]); $pdo->commit(); $success = "Teledrama and all related data purged."; } catch (Exception $e) { $pdo->rollBack(); $error = "Delete failed: " . $e->getMessage(); } } // --- 4. HANDLE NEW TELEDRAMA REGISTRATION --- if (isset($_POST['add_drama'])) { $title = htmlspecialchars($_POST['title']); $desc = htmlspecialchars($_POST['description']); $pdo->prepare("INSERT INTO dramas (title, description) VALUES (?, ?)")->execute([$title, $desc]); $success = "Production registered successfully."; } // --- 5. HANDLE EPISODE UPLOAD --- if (isset($_POST['submit_episodes'])) { $drama_id = (int)$_POST['drama_id']; $ep_numbers = $_POST['ep_numbers']; $iframes = $_POST['iframes']; try { $pdo->beginTransaction(); $stmt = $pdo->prepare("INSERT INTO episodes (drama_id, ep_number, iframe_code) VALUES (?, ?, ?)"); foreach ($ep_numbers as $idx => $num) { if (!empty($num) && !empty($iframes[$idx])) { $stmt->execute([$drama_id, (int)$num, $iframes[$idx]]); } } $pdo->commit(); $success = "Episodes uploaded successfully."; } catch (Exception $e) { $pdo->rollBack(); $error = "Upload failed: " . $e->getMessage(); } } $dramas = $pdo->query("SELECT * FROM dramas ORDER BY created_at DESC")->fetchAll(); include '../includes/header.php'; ?>= substr(htmlspecialchars($drama['description']), 0, 100) ?>...