Files
intranet/web/intranet_repo/projects/intranet/index.php
T

152 lines
9.2 KiB
PHP

<?php /* Name: index.php
Beschreibung: Intranet: Hauptseite */
// Initialisierung
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/general_files/initialise.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/brandschutz/util/brandschutz_helpers.php';
?>
<!DOCTYPE html>
<html lang="de" dir="ltr">
<head>
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/html_head.php'; ?>
</head>
<body class="theme-darkblue">
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/header.php'; ?>
<?php include $g_phpSnippetsPath.'overlay_message.php'; ?>
<div class="header_title ht_darkblue text_white" id="header_title">
<span class="header_title_text">Hauptmenü</span>
</div>
<?php if (isset($_GET["kalli_success"]) && $_GET["kalli_success"] == 1): ?>
<div style="position:fixed;top:calc(var(--header-height) + 8px);left:50%;transform:translateX(-50%);z-index:2000;padding:12px 28px;background:hsl(145,50%,93%);color:hsl(145,50%,28%);font-weight:600;font-size:var(--font-size-sm);box-shadow:var(--shadow-md);white-space:nowrap;" id="kalliSuccessMsg">
Eintragung erfolgreich! Kalli wird Ihren Termin direkt vermerken.
</div>
<script>setTimeout(function(){var el=document.getElementById('kalliSuccessMsg');if(el)el.style.display='none';},5000);</script>
<?php endif; ?>
<div class="mainpage" id="mainpage">
<div class="mainpage_container">
<?php
$mainpageNotices = [];
try {
$noticeStmt = $pdo->prepare(
"SELECT id, title, message, type
FROM mainpage_notices
WHERE is_active = TRUE
AND (starts_at IS NULL OR starts_at <= CURRENT_TIMESTAMP)
AND (ends_at IS NULL OR ends_at > CURRENT_TIMESTAMP)
ORDER BY sort_order ASC, created_at ASC, id ASC"
);
$noticeStmt->execute();
$mainpageNotices = $noticeStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$mainpageNotices = [];
}
$allowedNoticeTypes = ['info', 'warning', 'success', 'error'];
foreach ($mainpageNotices as $mainpageNotice):
$noticeType = in_array($mainpageNotice['type'], $allowedNoticeTypes, true) ? $mainpageNotice['type'] : 'info';
?>
<div class="mainpage_notice mainpage_notice--<?= htmlspecialchars($noticeType, ENT_QUOTES, 'UTF-8') ?>" role="status">
<div class="mainpage_notice_title"><?= htmlspecialchars($mainpageNotice['title'], ENT_QUOTES, 'UTF-8') ?></div>
<div class="mainpage_notice_text"><?= nl2br(htmlspecialchars($mainpageNotice['message'], ENT_QUOTES, 'UTF-8')) ?></div>
</div>
<?php endforeach; ?>
<?php if (isset($groups["Brandschutz"]) && $groups["Brandschutz"] == 1) {
$bsStmt = $pdo->prepare("SELECT last_training_date FROM brandschutz_training WHERE user_id = ?");
$bsStmt->execute([$_SESSION['user_id']]);
$bsLastTraining = $bsStmt->fetchColumn();
$bsTrainingStatus = brandschutz_training_status($bsLastTraining === false ? null : (string) $bsLastTraining);
$bsOverdue = (bool) $bsTrainingStatus['is_due'];
?>
<?php if ($bsOverdue): ?>
<div class="mainpage_notice mainpage_notice--warning" role="status">
<div class="mainpage_notice_title">Brandschutzunterweisung fällig!</div>
<div class="mainpage_notice_text">Bitte führen Sie zeitnah die <strong><a href="/intranet_repo/projects/brandschutz/brandschutz.php">Online-Brandschutzunterweisung</a></strong> durch. Die Schulung dauert nur ca. 15 bis 20 Minuten. Eine regelmäßige Durchführung ist gesetzlich vorgeschrieben. Vielen Dank!</div>
</div>
<?php endif; ?>
<?php
$kalliRoles = ["Amtsgeschwister", "Allgemein", "Musik", "Kinderunterrichte", "Jugend", "Technik", "Brandschutz", "Abwesenheiten"];
$hasKalliRole = false;
foreach ($kalliRoles as $role) {
if (isset($groups[$role]) && $groups[$role] == 1) { $hasKalliRole = true; break; }
}
if ($hasKalliRole): ?>
<button class="button_mainpage unselectable bg_blue" onclick="window.location.href='/intranet_repo/projects/kalli/kalli.php'">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"/></svg>
<div class="text">Kalli</div>
</button>
<?php endif; ?>
<button class="button_mainpage unselectable bg_darkblue" onclick="window.open('/pdf/terminuebersicht.pdf', '_blank');">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z"/></svg>
<div class="text">Monatsplan</div>
</button>
<?php if ($groups["Amtsgeschwister"] == 1) { ?>
<button class="button_mainpage unselectable bg_purple" onclick="window.location.href='/intranet_repo/projects/seelsorge/seelsorge.php'">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/></svg>
<div class="text">Seelsorge</div>
</button>
<?php } ?>
<button class="button_mainpage unselectable bg_orange" onclick="window.location.href='/intranet_repo/projects/brandschutz/brandschutz.php';" style="position:relative;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M12 12.9l-2.13 2.09C9.31 15.55 9 16.28 9 17.06 9 18.68 10.35 20 12 20s3-1.32 3-2.94c0-.78-.31-1.52-.87-2.07L12 12.9z M16 6l-.44.55C14.38 8.02 12 7.19 12 5.3V2S4 6 4 13c0 4.42 3.58 8 8 8s8-3.58 8-8c0-2.96-1.61-5.62-4-7z"/></svg>
<div class="text">Brandschutz</div>
<?php if ($bsOverdue): ?>
<span style="position:absolute;top:6px;right:6px;min-width:26px;height:26px;padding:0 6px;border-radius:9999px;background:var(--nak-red);color:#FFF;font-size:0.85em;font-weight:700;display:flex;align-items:center;justify-content:center;">!</span>
<?php endif; ?>
</button>
<?php } ?>
<button class="button_mainpage unselectable bg_teal" onclick="window.location.href='/intranet_repo/projects/intranet/profile.php'">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
<div class="text">Konto</div>
</button>
<?php if (isset($groups["Allgemein"]) && $groups["Allgemein"] == 1) { ?>
<button class="button_mainpage unselectable bg_raspberry" onclick="window.location.href='/intranet_repo/projects/contentpanel/insertion/insert.php'">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>
<div class="text">Schwarzes Brett</div>
</button>
<?php } ?>
<?php if ($groups["Admin"] == 1) {
// Unbearbeitete Nachrichten zählen
$badgeStmt = $pdo->prepare("SELECT COUNT(*) FROM admin_messages WHERE status = 'pending'");
$badgeStmt->execute();
$unreadCount = $badgeStmt->fetchColumn();
?>
<button class="button_mainpage unselectable bg_black" id="spin" onclick="window.location.href='/intranet_repo/projects/adminpanel/admin.php'" style="position:relative;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/></svg>
<div class="text">Admin</div>
<?php if ($unreadCount > 0): ?>
<span style="position:absolute;top:6px;right:6px;min-width:26px;height:26px;padding:0 6px;border-radius:9999px;background:var(--nak-red);color:#FFF;font-size:0.85em;font-weight:700;display:flex;align-items:center;justify-content:center;"><?= $unreadCount ?></span>
<?php endif; ?>
</button>
<?php } ?>
<?php if ($groups["Entwickler"] == 1) { ?>
<button class="button_mainpage unselectable bg_green" id="spin" onclick="window.location.href='/intranet_repo/projects/developerpanel/developer.php'">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="32" height="32"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>
<div class="text">Entwickler</div>
</button>
<?php } ?>
</div>
</div>
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/intranet_repo/projects/_central/php/footer.php'; ?>
</body>
</html>