prepare( "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = 'hospital_ads' AND COLUMN_NAME = ?" ); $stmt->execute([DB_NAME, $column]); return $cache[$column] = ((int) $stmt->fetchColumn() > 0); } $activeAds = []; try { $pdo = db(); $hasMediaType = qh_display_ads_column_exists($pdo, 'media_type'); $hasMediaPath = qh_display_ads_column_exists($pdo, 'media_path'); if ($hasMediaType && $hasMediaPath) { $stmt = $pdo->query( "SELECT id, title, COALESCE(NULLIF(media_type, ''), 'video') AS media_type, COALESCE(NULLIF(media_path, ''), NULLIF(video_path, '')) AS media_path FROM hospital_ads WHERE is_active = 1 ORDER BY sort_order ASC, id DESC" ); } elseif ($hasMediaPath) { $stmt = $pdo->query( "SELECT id, title, 'video' AS media_type, COALESCE(NULLIF(media_path, ''), NULLIF(video_path, '')) AS media_path FROM hospital_ads WHERE is_active = 1 ORDER BY sort_order ASC, id DESC" ); } else { $stmt = $pdo->query( "SELECT id, title, 'video' AS media_type, video_path AS media_path FROM hospital_ads WHERE is_active = 1 ORDER BY sort_order ASC, id DESC" ); } if ($stmt) { foreach ($stmt->fetchAll() as $ad) { $mediaPath = (string) ($ad['media_path'] ?? ''); if ($mediaPath === '') { continue; } $activeAds[] = [ 'id' => (int) ($ad['id'] ?? 0), 'title' => (string) ($ad['title'] ?? ''), 'type' => (($ad['media_type'] ?? 'video') === 'image') ? 'image' : 'video', 'path' => $mediaPath, 'duration' => 10, ]; } } } catch (Throwable $e) { // Table might not exist yet, safe to ignore } $activeNews = []; try { $stmt = db()->query("SELECT phrase FROM hospital_news WHERE is_active = 1 ORDER BY sort_order ASC, id DESC"); if ($stmt) { $activeNews = $stmt->fetchAll(PDO::FETCH_COLUMN); } } catch (Throwable $e) { // Table might not exist yet } qh_page_start( 'display', qh_t('General display board', 'لوحة العرض العامة'), qh_t('Public queue display.', 'شاشة طوابير عامة.') ); ?>
<?= qh_h(qh_hospital_name()) ?>

<?= qh_h(qh_t('Hospital advertisement', 'إعلان المستشفى')) ?>