1355 lines
65 KiB
PHP
1355 lines
65 KiB
PHP
<?php
|
|
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
// Show all errors except deprecation notices (these come from vendor libraries
|
|
// that aren't yet typed for newer PHP versions). Long-term fix: update
|
|
// dependencies to versions compatible with your PHP runtime.
|
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
|
|
// Add a higher memory limit
|
|
$baseDir = $_SERVER['DOCUMENT_ROOT'];
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" type="png" href="/intern/img/icon.png">
|
|
<title>Intern - Kampfrichter</title>
|
|
|
|
<link rel="stylesheet" href="/intern/css/kampfrichter.css">
|
|
<link rel="stylesheet" href="/intern/css/sidebar.css">
|
|
<link href="/files/fonts/fonts.css" rel="stylesheet">
|
|
<script src="/intern/js/jquery/jquery-3.7.1.min.js"></script>
|
|
<script src="/intern/js/custom-msg-display.js"></script>
|
|
<script>
|
|
(function () {
|
|
let lastWrite = 0;
|
|
const interval = 200;
|
|
|
|
window.addEventListener('scroll', function () {
|
|
const now = Date.now();
|
|
if (now - lastWrite >= interval) {
|
|
sessionStorage.setItem('scrollY', window.scrollY);
|
|
lastWrite = now;
|
|
}
|
|
}, { passive: true });
|
|
|
|
window.addEventListener('load', function () {
|
|
const scrollY = sessionStorage.getItem('scrollY');
|
|
if (scrollY !== null) {
|
|
window.scrollTo(0, parseInt(scrollY, 10));
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<?php
|
|
|
|
//ini_set('display_errors', 1);
|
|
//error_reporting(E_ALL);
|
|
|
|
$reldirbase = "/../";
|
|
|
|
require_once $baseDir . '/../scripts/session_functions.php';
|
|
|
|
ini_wkvs_session(true);
|
|
|
|
$csrf_token = $_SESSION['csrf_token'] ?? '';
|
|
|
|
$access_granted_kampfrichter = check_user_permission('kampfrichter', true) ?? false;
|
|
|
|
if (!$access_granted_kampfrichter) :
|
|
|
|
$logintype = 'kampfrichter';
|
|
|
|
require $baseDir . '/../scripts/login/login.php';
|
|
|
|
$logintype = '';
|
|
|
|
else :
|
|
|
|
|
|
require $baseDir . '/../scripts/db/db-functions.php';
|
|
require $baseDir . '/../scripts/db/db-tables.php';
|
|
require $baseDir . '/../scripts/websocket/ws-create-token.php';
|
|
|
|
|
|
$type = 'kr';
|
|
|
|
$dbconnection = require $baseDir . '/../scripts/db/db-verbindung-script.php';
|
|
|
|
if ($dbconnection['success'] !== true){
|
|
echo 'Critical DB Error.';
|
|
exit;
|
|
}
|
|
|
|
$currentPage = 'kampfrichter';
|
|
|
|
require $baseDir . '/intern/scripts/sidebar/sidebar.php';
|
|
|
|
$svgnichtbezahlt = '<div style="display: inline-flex; align-items: center; gap: 8px;"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="#dc3545"/><path d="M8 8l8 8M16 8l-8 8" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>';
|
|
|
|
|
|
require $baseDir . '/../scripts/kampfrichter/check-user-freigaben.php';
|
|
|
|
$disciplines = db_select($mysqli, $tableGeraete, '*', '', [], 'start_index ASC');
|
|
|
|
$maxsubabt = count($disciplines);
|
|
|
|
$current_year = date('Y'); // or you can set this dynamically as you want
|
|
$monat = date('n');
|
|
if ($monat > 6) {
|
|
$current_year = $current_year + 1;
|
|
}
|
|
|
|
$sortprio = ['ep', 'p1', 'p1 kader', 'p2', 'p2 kader'];
|
|
|
|
$programmes = db_select($mysqli, $tableProgramme, 'programm, `id`', 'aktiv = ?', ['1']);
|
|
|
|
$indexedProgrammes = array_column($programmes, 'id', 'programm');
|
|
|
|
$focus_view_admin = $_SESSION['abtViewAdmin'] ?? false;
|
|
$aktabtdb = db_get_var($mysqli, "SELECT value FROM $tableVar WHERE name = ?", ['wk_panel_current_abt']);
|
|
$aktabt = intval($aktabtdb);
|
|
$maxvalue = db_get_var($mysqli, "SELECT name FROM $tableAbt ORDER BY name DESC LIMIT 1");
|
|
|
|
$res = $mysqli->query("SELECT * FROM $tableNotenBezeichnungen");
|
|
|
|
$notenConfig = $res->fetch_all(MYSQLI_ASSOC);
|
|
|
|
$indexedNotenNames = array_column($notenConfig, 'name', 'id');
|
|
|
|
// var_dump($notenConfig);
|
|
|
|
//$dbprogramme = db_select($mysqli, $tableTurnerinnen, '*', 'abteilung = ? AND (bezahlt = ? OR bezahlt = ?)', [$aktabt, '2', '5'], 'id ASC');
|
|
|
|
$stmt = $mysqli->prepare("
|
|
SELECT
|
|
t.*,
|
|
agg.abteilung,
|
|
agg.geraete_index,
|
|
agg.start_index
|
|
FROM $tableTurnerinnen t
|
|
LEFT JOIN (
|
|
SELECT
|
|
ta.turnerin_id,
|
|
GROUP_CONCAT(DISTINCT a.name SEPARATOR ', ') AS abteilung,
|
|
GROUP_CONCAT(DISTINCT g.start_index SEPARATOR ', ') AS geraete_index,
|
|
ta.turnerin_index AS start_index
|
|
FROM $tableTurnerinnenAbt ta
|
|
INNER JOIN $tableAbt a
|
|
ON a.id = ta.abteilung_id
|
|
LEFT JOIN $tableGeraete g
|
|
ON g.id = ta.geraet_id
|
|
GROUP BY ta.turnerin_id
|
|
) agg ON agg.turnerin_id = t.id
|
|
WHERE (t.bezahlt = ? OR t.bezahltoverride = ?) AND agg.abteilung = ?
|
|
ORDER BY t.id DESC
|
|
");
|
|
|
|
|
|
|
|
$bezahlt = 2;
|
|
$bezahltoverride = 5;
|
|
|
|
$stmt->bind_param('sii', $bezahlt, $bezahltoverride, $aktabt);
|
|
|
|
|
|
$stmt->execute();
|
|
|
|
|
|
$result = $stmt->get_result();
|
|
$dbprogramme = $result->fetch_all(MYSQLI_ASSOC);
|
|
|
|
require $baseDir . '/../scripts/kampfrichter/post-handler.php';
|
|
|
|
|
|
|
|
$allprogrammeabt = [];
|
|
$allprogrammeabtstr = '';
|
|
$allprogrammeabtstrcleared = '';
|
|
|
|
if ($dbprogramme){
|
|
foreach ($dbprogramme as $ind => $singledbprogramm){
|
|
$sinleprogramm = $singledbprogramm['programm'];
|
|
if (!(in_array($sinleprogramm, $allprogrammeabt))){
|
|
$allprogrammeabt[] = $sinleprogramm;
|
|
$allprogrammeabtstr .= $sinleprogramm. ', ';
|
|
}
|
|
}
|
|
$pos = strrpos($allprogrammeabtstr, ' ');
|
|
if ($pos !== false) {
|
|
$allprogrammeabtstrcleared = substr_replace($allprogrammeabtstr, '', $pos, 1);
|
|
}
|
|
if (mb_strlen($allprogrammeabtstrcleared) > 1) {
|
|
$allprogrammeabtstrcleared = mb_substr($allprogrammeabtstrcleared, 0, mb_strlen($allprogrammeabtstrcleared) - 1);
|
|
}
|
|
}
|
|
|
|
$displayLogo = $_SESSION['logoDisplay'] ?? true;
|
|
|
|
if ($displayLogo !== false){
|
|
require $baseDir . '/intern/scripts/wkvs/wkvs.html';
|
|
$_SESSION['logoDisplay'] = false;
|
|
}
|
|
|
|
echo '<div class="internMenuDiv">
|
|
<div class="closeInternMenuMobileDiv"></div>
|
|
<div class="innerInternMenuDiv">
|
|
|
|
<div class="header-text-conatiner">';
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
$anzkampfrichter = 2;
|
|
|
|
function isAdmin() {
|
|
global $selecteduser;
|
|
if ($selecteduser === 'admin') {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if ($selecteduser === 'admin'){
|
|
$maxstyle = ($aktabt == $maxvalue) ? 'background-color: rgba(68, 68, 68, 0.27); pointer-events:none;': '';
|
|
$minstyle = ($aktabt == 1) ? 'background-color: rgba(68, 68, 68, 0.27); pointer-events:none;': '';
|
|
|
|
|
|
?>
|
|
<div class="gruppennav">
|
|
<p>Aktuelle Abt. </p>
|
|
<form action="/intern/kampfrichter" method="post" >
|
|
<input type="hidden" name="csrf_token" id="prev_abt_nonce" value="<?= $csrf_token ?>">
|
|
<input type="hidden" name="prev_abt" value="-1">
|
|
<input type="submit" style="<?php echo $minstyle; ?>" name="prev_abt_submit" class="button_gruppe" value="<">
|
|
</form>
|
|
<p><?php echo $aktabt;?></p>
|
|
<form action="/intern/kampfrichter" method="post">
|
|
<input type="hidden" name="csrf_token" id="next_abt_nonce" value="<?= $csrf_token ?>">
|
|
<input type="hidden" name="next_abt" value="1">
|
|
<input type="submit" style="<?php echo $maxstyle; ?>" name="next_abt_submit" class="button_gruppe" value=">">
|
|
</form>
|
|
<p> / <?php echo $maxvalue; ?></p>
|
|
|
|
</div>
|
|
<?php } else {
|
|
$aktsubabt = $_SESSION['currentsubabt'];
|
|
$maxstyle = ($aktsubabt == $maxsubabt) ? 'background-color: rgba(68, 68, 68, 0.27) !important; pointer-events:none !important;': '';
|
|
$minstyle = ($aktsubabt == 1) ? 'background-color: rgba(68, 68, 68, 0.27) !important; pointer-events:none !important;': '';
|
|
?>
|
|
<div class="gruppennav">
|
|
<?php
|
|
echo '<p>Aktuelle Gruppe </p>';
|
|
?>
|
|
<form action="/intern/kampfrichter" method="post" >
|
|
<input type="hidden" name="csrf_token" id="prev_subabt_nonce" value="<?= $csrf_token ?>">
|
|
<input type="hidden" name="prev_subabt" value="-1">
|
|
<input type="submit" style="<?php echo $minstyle; ?>" name="prev_subabt_submit" class="button_gruppe" value="<">
|
|
</form>
|
|
<p><?php echo $aktsubabt;?></p>
|
|
<form action="/intern/kampfrichter" method="post">
|
|
<input type="hidden" name="csrf_token" id="next_subabt_nonce" value="<?= $csrf_token ?>">
|
|
<input type="hidden" name="next_subabt" value="1">
|
|
<input type="submit" style="<?php echo $maxstyle; ?>" name="next_subabt_submit" class="button_gruppe" value=">">
|
|
</form>
|
|
<p> / <?php echo $maxsubabt; ?></p>
|
|
</div>
|
|
<?php
|
|
$selecteduserNormalized = ucfirst(strtolower($selecteduser));
|
|
|
|
$indexuser = null;
|
|
|
|
foreach ($disciplines as $index => $discipline) {
|
|
if (isset($discipline['name']) && $discipline['name'] === $selecteduserNormalized) {
|
|
$indexuser = $index;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
// Find mathematical 0-based array index of starting apparatus for the group
|
|
$startGeraetArrayIndex = ($indexuser - $aktsubabt + 1) % $maxsubabt;
|
|
if ($startGeraetArrayIndex < 0) {
|
|
$startGeraetArrayIndex += $maxsubabt;
|
|
}
|
|
// Look up corresponding actual start_index from database
|
|
$startgeindex = $disciplines[$startGeraetArrayIndex]['start_index'];
|
|
|
|
$option_name1 = $aktabt . 'namekr' . $selecteduser . '1';
|
|
$option_name2 = $aktabt . 'namekr' . $selecteduser . '2';
|
|
|
|
|
|
$selectedKampfrichterDB = db_select($mysqli, $tableKrProtokoll, ['name', 'aufgabe'], 'geraet = ? AND abteilung = ?', [strtolower($selecteduser), $aktabt], 'aufgabe ASC');
|
|
|
|
|
|
$selectedKampfrichter = [];
|
|
|
|
// Corrected version
|
|
for ($i = 1; $i <= $anzkampfrichter; $i++) {
|
|
$found = false;
|
|
|
|
foreach ($selectedKampfrichterDB as $kr) {
|
|
if ($kr['aufgabe'] == $i) {
|
|
$selectedKampfrichter[$i] = $kr['name'];
|
|
$found = true;
|
|
break; // stop searching once found
|
|
}
|
|
}
|
|
|
|
if (!$found) {
|
|
$selectedKampfrichter[$i] = 'nan';
|
|
}
|
|
}
|
|
|
|
$kampfrichter = db_select($mysqli, $tableInternUsers, 'id, name_person, freigabe', '', [], 'name_person ASC' );
|
|
|
|
$filteredKampfrichter = [];
|
|
|
|
foreach ($kampfrichter as $kr) {
|
|
$freigaben = json_decode($kr['freigabe'], true) ?? [];
|
|
$freigabenTypes = $freigaben['types'] ?? [];
|
|
$freigabenKampfrichter = $freigaben['freigabenKampfrichter'] ?? [];
|
|
$isAdmin = in_array('admin', $freigabenKampfrichter);
|
|
if (in_array('kampfrichter', $freigabenTypes) && !$isAdmin) {
|
|
$filteredKampfrichter[] = $kr;
|
|
}
|
|
}
|
|
|
|
|
|
if (count($filteredKampfrichter) > 0) {
|
|
//if (in_array('admin', $arrayfreigaben)) {
|
|
|
|
for ($i = 1; $i <= $anzkampfrichter; $i++) {
|
|
|
|
$label = ($i === 1)
|
|
? 'Name Kampfrichterin E'.$i.' Note + D-Note: '
|
|
: 'Name Kampfrichterin E'.$i.' Note';
|
|
|
|
echo '<label class="labelnamekr">'.$label.'</label>
|
|
<select class="ajax-input-namekr inputnamekr"
|
|
data-id="'.$i.'"
|
|
data-abt="' . $aktabt . '"
|
|
data-user="' . $selecteduser . '">';
|
|
echo '<option hidden selected>---</option>';
|
|
foreach ($filteredKampfrichter as $person) {
|
|
$selected = $selectedKampfrichter[$i] === $person['name_person']
|
|
? 'selected'
|
|
: '';
|
|
|
|
echo '<option id="'.$selectedKampfrichter[$i].'" value="'.$person['name_person'].'" '.$selected.'>'.$person['name_person'].'</option>';
|
|
}
|
|
|
|
echo '</select>';
|
|
}
|
|
//}
|
|
}
|
|
|
|
}
|
|
if ($selecteduser === 'admin'){
|
|
$valuetogglemodeadmin = ($focus_view_admin == true) ? 'nach Programmen sortieren (Admin)' : 'nach Abteilungen sortieren (Admin)';
|
|
$styletoggleadmin = ($focus_view_admin == true) ? 'background-color: #003;' : 'background-color: #030;';
|
|
|
|
?>
|
|
|
|
<form method="post" style="margin-bottom: 1em;">
|
|
<input type="hidden" name="csrf_token" id="toggle_advanced_mode_admin_nonce" value="<?= $csrf_token ?>">
|
|
<input type="hidden" name="togle_advanced_mode_admin" value="-1">
|
|
<input type="submit" style="<?= $styletoggleadmin ?>" name="togle_advanced_mode_admin_submit" class="buttonNewAdminStyle" value="<?= $valuetogglemodeadmin ?>">
|
|
</form>
|
|
|
|
<?php
|
|
}
|
|
if ($selecteduser !== 'admin'){
|
|
echo '<p class="text_akt_abt">Aktuelle Abteilung '.$aktabt.' von '.$maxvalue.' ('.htmlspecialchars(strtoupper($allprogrammeabtstrcleared)).')</p><a class="text_akt_abt" href="https://www.gymnastics.sport/publicdir/rules/files/en_1.1.%20WAG%20Code%20of%20Points%202025-2028.pdf" target="_blank">CoP 2025-2028</a><a class="text_akt_abt" href="https://www.stv-fsg.ch/fileadmin/user_upload/Wettkampfprogramm_2025-2028_13.11.2025.pdf" target="_blank">STV 2025-2028</a>';
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="menuBg"></div>
|
|
|
|
<section class="bgSection">
|
|
<div class="headerDivKampfrichter">
|
|
<div class="headingPanelDiv">
|
|
<h2 class="headingPanel">Kampfrichterpanel</h2>
|
|
<h3 class="headingPanelGeraet"><?= ucfirst($selecteduser) ?></h3>
|
|
</div>
|
|
<div class="menuWrapper">
|
|
<div class="kampfrichterBurgerMenuDiv">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>
|
|
</svg>
|
|
</div>
|
|
<?php sidebarRender('button') ?>
|
|
</div>
|
|
|
|
<?php if ($selectedfreigabe !== 'admin') { ?>
|
|
<script>
|
|
|
|
const currentsubabt = <?php echo $aktsubabt ?>;
|
|
const maxsubabt = <?php echo $maxsubabt ?>;
|
|
|
|
|
|
document.addEventListener("keydown", (e) => {
|
|
// Example: Arrow Left = previous, Arrow Right = next
|
|
const isOptionOrAlt = e.altKey || e.metaKey;
|
|
|
|
if (e.key === "ArrowLeft" && currentsubabt > 1 && isOptionOrAlt) {
|
|
sendSubAbt("prev_subabt");
|
|
} else if (e.key === "ArrowRight" && currentsubabt < maxsubabt && isOptionOrAlt) {
|
|
sendSubAbt("next_subabt");
|
|
}
|
|
});
|
|
|
|
function sendSubAbt(action) {
|
|
const formData = new FormData();
|
|
formData.append(action, 1); // mimics your PHP check
|
|
formData.append(action + "_submit", 1); // required by PHP
|
|
|
|
fetch("/intern/kampfrichter", {
|
|
method: "POST",
|
|
body: formData,
|
|
credentials: "same-origin" // send session cookies
|
|
})
|
|
.then(() => {
|
|
// Reload page to reflect session change
|
|
location.reload();
|
|
})
|
|
.catch(err => console.error("POST failed:", err));
|
|
}
|
|
|
|
</script>
|
|
<?php } ?>
|
|
<script>
|
|
const menuburger = document.querySelector('.kampfrichterBurgerMenuDiv');
|
|
const menudiv = document.querySelector('.internMenuDiv');
|
|
const menubg = document.querySelector('.menuBg');
|
|
const content = document.querySelector('.bgSection');
|
|
const closeMenuMobile = document.querySelector('.closeInternMenuMobileDiv');
|
|
|
|
const storageKey = "kampfrichterInternMenuOpen";
|
|
|
|
const isOpen = localStorage.getItem(storageKey) === "true";
|
|
|
|
document.addEventListener('keydown', function (e) {
|
|
// Mac = Option, Windows/Linux = Alt
|
|
const isOptionOrAlt = e.altKey || e.metaKey;
|
|
|
|
if (e.key.toLowerCase() === 'm') {
|
|
menuburger.classList.add("menuTransition");
|
|
menudiv.classList.add("menuTransition");
|
|
menubg.classList.add("menuTransition");
|
|
content.classList.add("menuTransition");
|
|
|
|
menuburger.classList.toggle("open");
|
|
menudiv.classList.toggle("open");
|
|
menubg.classList.toggle("open");
|
|
content.classList.toggle("open");
|
|
|
|
const isOpenEl =
|
|
menudiv.classList.contains("open") &&
|
|
menuburger.classList.contains("open") &&
|
|
menubg.classList.contains("open");
|
|
|
|
localStorage.setItem(storageKey, isOpenEl);
|
|
}
|
|
});
|
|
|
|
if (isOpen) {
|
|
menuburger.classList.add("open");
|
|
menudiv.classList.add("open");
|
|
menubg.classList.add("open");
|
|
content.classList.add("open");
|
|
}
|
|
|
|
/*menubg.addEventListener("click", function () {
|
|
menuburger.classList.add("menuTransition");
|
|
menudiv.classList.add("menuTransition");
|
|
menubg.classList.add("menuTransition");
|
|
content.classList.add("menuTransition");
|
|
|
|
menuburger.classList.remove("open");
|
|
menudiv.classList.remove("open");
|
|
menubg.classList.remove("open");
|
|
content.classList.remove("open");
|
|
|
|
localStorage.setItem(storageKey, false);
|
|
});*/
|
|
|
|
menuburger.addEventListener("click", function () {
|
|
menuburger.classList.add("menuTransition");
|
|
menudiv.classList.add("menuTransition");
|
|
menubg.classList.add("menuTransition");
|
|
content.classList.add("menuTransition");
|
|
|
|
menuburger.classList.toggle("open");
|
|
menudiv.classList.toggle("open");
|
|
menubg.classList.toggle("open");
|
|
content.classList.toggle("open");
|
|
|
|
const isOpenEl =
|
|
menudiv.classList.contains("open") &&
|
|
menuburger.classList.contains("open") &&
|
|
menubg.classList.contains("open");
|
|
|
|
localStorage.setItem(storageKey, isOpenEl);
|
|
});
|
|
|
|
closeMenuMobile.addEventListener("click", function () {
|
|
const isOpenEl =
|
|
menudiv.classList.contains("open") &&
|
|
menuburger.classList.contains("open") &&
|
|
menubg.classList.contains("open");
|
|
|
|
if (isOpenEl) {
|
|
menuburger.classList.remove("open");
|
|
menudiv.classList.remove("open");
|
|
menubg.classList.remove("open");
|
|
content.classList.remove("open");
|
|
|
|
localStorage.setItem(storageKey, false);
|
|
}
|
|
});
|
|
|
|
|
|
</script>
|
|
</div>
|
|
<?php
|
|
|
|
echo sidebarRender('modal');
|
|
|
|
$bezahlt = '2';
|
|
$bezahltoverride = '5';
|
|
|
|
if ($selecteduser === 'admin' && $focus_view_admin == true){
|
|
$whereClause = '(t.bezahlt = ? OR t.bezahltoverride = ?) AND agg.abteilung > 0';
|
|
$params = [$bezahlt, $bezahltoverride];
|
|
$orderBy = 't.rang ASC';
|
|
} elseif ($selecteduser !== 'admin'){
|
|
$whereClause = '(t.bezahlt = ? OR t.bezahltoverride = ?) AND agg.abteilung = ? AND agg.startgeraet = ?';
|
|
$params = [$bezahlt, $bezahltoverride, $aktabt, $startgeindex];
|
|
$orderBy = 'agg.startIndex ASC';
|
|
} else {
|
|
$whereClause = 't.bezahlt = ? OR t.bezahltoverride = ?';
|
|
$params = [$bezahlt, $bezahltoverride];
|
|
$orderBy = 't.rang ASC';
|
|
}
|
|
|
|
$stmt = $mysqli->prepare("
|
|
SELECT
|
|
t.*,
|
|
agg.abteilung,
|
|
agg.startgeraet,
|
|
agg.startIndex,
|
|
agg.abtId,
|
|
agg.geraetId
|
|
FROM $tableTurnerinnen t
|
|
LEFT JOIN (
|
|
SELECT
|
|
ta.turnerin_id,
|
|
GROUP_CONCAT(DISTINCT a.name SEPARATOR ', ') AS abteilung,
|
|
GROUP_CONCAT(DISTINCT g.start_index SEPARATOR ', ') AS startgeraet,
|
|
ta.turnerin_index AS startIndex,
|
|
ta.abteilung_id AS abtId,
|
|
ta.geraet_id AS geraetId
|
|
FROM $tableTurnerinnenAbt ta
|
|
INNER JOIN $tableAbt a
|
|
ON a.id = ta.abteilung_id
|
|
LEFT JOIN $tableGeraete g
|
|
ON g.id = ta.geraet_id
|
|
GROUP BY ta.turnerin_id
|
|
) agg ON agg.turnerin_id = t.id
|
|
WHERE $whereClause
|
|
ORDER BY $orderBy
|
|
");
|
|
|
|
|
|
|
|
$bezahlt = 2;
|
|
$bezahltoverride = 5;
|
|
|
|
if (!empty($params)) {
|
|
$types = str_repeat("s", count($params)); // simple: treat everything as string
|
|
$stmt->bind_param($types, ...$params);
|
|
}
|
|
|
|
$stmt->execute();
|
|
|
|
|
|
$result = $stmt->get_result();
|
|
$entries = $result->fetch_all(MYSQLI_ASSOC);
|
|
|
|
|
|
// Define sort priority
|
|
$sortprio = ['ep', 'p1', 'p1 kader', 'p2', 'p2 kader'];
|
|
// Group entries by programm
|
|
$grouped = [];
|
|
if (($selecteduser !== 'admin') || ($selecteduser === 'admin' && $focus_view_admin == true)){
|
|
foreach ($entries as $entry) {
|
|
$key = strtolower($entry['abteilung']);
|
|
$grouped[$key][] = $entry;
|
|
}
|
|
|
|
ksort($grouped, SORT_STRING | SORT_FLAG_CASE);
|
|
} else {
|
|
foreach ($entries as $entry) {
|
|
$key = strtolower($entry['programm']);
|
|
$grouped[$key][] = $entry;
|
|
}
|
|
|
|
// Sort the grouped keys by defined priority
|
|
uksort($grouped, function ($a, $b) use ($sortprio) {
|
|
$a_index = array_search($a, $sortprio);
|
|
$b_index = array_search($b, $sortprio);
|
|
$a_index = $a_index === false ? PHP_INT_MAX : $a_index;
|
|
$b_index = $b_index === false ? PHP_INT_MAX : $b_index;
|
|
return $a_index <=> $b_index;
|
|
});
|
|
}
|
|
|
|
$disabledDNote = '';
|
|
|
|
$disabledNA = '';
|
|
|
|
if ($selecteduser !== 'admin') {
|
|
$disabledDNote = ($selectedKampfrichter[1] !== $username && !in_array('admin', $arrayfreigaben)) ? 'disabled' : '';
|
|
$disabledNA = (!in_array($username, $selectedKampfrichter) && !in_array('admin', $arrayfreigaben)) ? 'disabled' : '';
|
|
}
|
|
|
|
$itemsToLoop = [];
|
|
|
|
if ($selecteduser === 'admin') {
|
|
foreach ($disciplines as $sd) {
|
|
$itemsToLoop[] = ['name' => $sd['name'], 'id' => $sd['id']];
|
|
}
|
|
} else {
|
|
$arrayNameMap = array_change_key_case(array_column($disciplines, 'id', 'name'), CASE_LOWER);
|
|
$itemsToLoop[] = ['name' => $selecteduser, 'id' => $arrayNameMap[$selecteduser] ?? null];
|
|
}
|
|
|
|
$indexedDisciplines = array_column($disciplines, 'name', 'id');
|
|
?>
|
|
|
|
<div class="div_edit_values_user_outer">
|
|
<div class="div_edit_values_user" style="display: none;">
|
|
<h3 class="heading_fv_selturnerin" tabindex="-1">
|
|
Aktuelle Turnerin:
|
|
<span class="current-turnerin-name"></span>
|
|
</h3>
|
|
<div class="div_edit_values_all_gereate">
|
|
<?php foreach ($itemsToLoop as $d) :
|
|
if ($d['id'] === null) { continue; } ?>
|
|
|
|
<div class="all_vaules_div">
|
|
<?php if (isAdmin()) : ?>
|
|
<h4><?= $d['name'] ?></h4>
|
|
<?php endif; ?>
|
|
<div class="allNotentable">
|
|
<div class="singleNotentable">
|
|
<?php foreach ($notenConfig as $nc) :
|
|
$isProGeraet = (intval($nc['pro_geraet']) === 1);
|
|
$allowedGeraete = !empty($nc['geraete_json']) ? json_decode($nc['geraete_json'], true) : [];
|
|
|
|
if (!$isProGeraet && !in_array($d['id'], $allowedGeraete)) { continue; }
|
|
|
|
$disabled = ($nc['type'] === 'berechnung') ? 'disabled' : '';
|
|
?>
|
|
|
|
<table class="titleWidthNormalInput editkampfrichter_user note-container" data-note-id="<?= $nc['id'] ?>" data-runs-config='<?= htmlspecialchars($nc['anzahl_laeufe_json'] ?? '{"default":1}') ?>'>
|
|
<thead>
|
|
<tr>
|
|
<th class="<?= $nc['id'] ?>-field-th note-name-header"><?= $nc['name'] ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr class="inputs-row">
|
|
<td class="nopadding input-cell-run-1">
|
|
<input type="number" class="ajax-input fullinput changebleValue"
|
|
data-person-id=""
|
|
data-field-type-id="<?= $nc['id'] ?>"
|
|
data-geraet-id="<?= $d['id'] ?>"
|
|
data-run="1"
|
|
value=""
|
|
min="0" max="20" step="0.005" <?= $disabled ?>>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<?php endforeach ?>
|
|
</div>
|
|
</div>
|
|
<?php if (!isAdmin()) : ?>
|
|
<p class="editkampfrichter_user_text">Die Endnote wird wie folgt automatisch berrechnet: Endnote <?= $d['name'] ?> = 10 - E<sub>Ø</sub> Note + D Note - Neutrale Abzüge</p>
|
|
<?php endif; ?>
|
|
|
|
<div class="editUserButtons"><input type="button" class="submit-display-turnerin"
|
|
data-person-id=""
|
|
data-geraet-id="<?= $d['id'] ?>"
|
|
value="Turnerin anzeigen">
|
|
|
|
<div class="div-submit-display-start">
|
|
<input type="button" class="submit-display-start start"
|
|
data-person-id=""
|
|
data-geraet-id="<?= $d['id'] ?>"
|
|
data-type="1"
|
|
value="Startfreigabe erteilen">
|
|
<input type="button" class="submit-display-start stopp"
|
|
data-person-id=""
|
|
data-geraet-id="<?= $d['id'] ?>"
|
|
data-type="0"
|
|
value="Startfreigabe enziehen">
|
|
</div>
|
|
|
|
<div class="div-submit-display-result">
|
|
<input type="button" class="submit-display-result"
|
|
data-person-id=""
|
|
data-geraet-id="<?= $d['id'] ?>"
|
|
data-run="1"
|
|
value="Ergebnis anzeigen">
|
|
</div>
|
|
|
|
<?php if (strtolower($d["name"]) === 'boden') : ?>
|
|
<div class="playcontrolDiv">
|
|
<input type="button" class="submit-musik-start"
|
|
data-id=""
|
|
data-geraet="<?= $d['id'] ?>"
|
|
value="Musik starten">
|
|
<input type="button" class="submit-musik-stopp"
|
|
data-geraet="<?= $d['id'] ?>"
|
|
value="Musik stoppen">
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php if (!isAdmin()) : ?>
|
|
<h5 class="heading_fv_nextturnerin">Nächste Turnerin:</h5>
|
|
<a class="fv_nextturnerin editTurnerin" data-person-id="" data-geraet-id="<?= $d['id'] ?>"></a>
|
|
<?php endif; ?>
|
|
|
|
|
|
</div>
|
|
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="allTurnerinenDiv">
|
|
|
|
<?php if (!(!empty($programmes) && is_array($programmes))) {
|
|
echo '<h3>Eingabetool noch nicht freigeschalten</h3>';
|
|
}
|
|
echo '<h3 class="heading_fv_alleturnerinnen">Alle Turnerinnen:</h3>';
|
|
$total_count = 0;
|
|
|
|
if (!empty($grouped)) :
|
|
|
|
// Extract all 'id' values into a flat array
|
|
$ids = array_column($entries, 'id');
|
|
|
|
if (!empty($ids)) {
|
|
// Create placeholders: ?,?,?
|
|
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
|
|
|
$sql = "SELECT `person_id`, `note_bezeichnung_id`, `geraet_id`, `run_number`, `value`
|
|
FROM $tableNoten
|
|
WHERE `jahr` = ? AND `person_id` IN ($placeholders)";
|
|
|
|
$stmt = $mysqli->prepare($sql);
|
|
|
|
// In PHP 8.1+, you can simply pass an array to execute()
|
|
// We merge the year with the IDs into one flat array
|
|
$params = array_merge([$current_year], $ids);
|
|
|
|
$stmt->execute($params);
|
|
$noten = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
|
|
}
|
|
|
|
$notenIndexed = [];
|
|
|
|
foreach ($noten as $sn) {
|
|
$notenIndexed[$sn['person_id']][$sn['geraet_id']][$sn['note_bezeichnung_id']][$sn['run_number']] = $sn['value'];
|
|
}
|
|
|
|
$stmt->close();
|
|
|
|
// Extended Disciplines, contains the 0 disc
|
|
|
|
$disciplinesExtended = array_merge(
|
|
[["id" => 0, "name" => "None"]],
|
|
$disciplines
|
|
);
|
|
|
|
foreach ($grouped as $abteilung => $entries_group) :
|
|
// ... (PDF path and H3 tag)
|
|
|
|
|
|
// Nur sortieren, wenn der Benutzer nicht 'Admin' ist
|
|
if ($selecteduser !== 'admin') {
|
|
$entries_with_calculated_index = [];
|
|
|
|
// Optional: Vorab-Caching der MAX-Indices, um DB-Abfragen im Loop zu vermeiden
|
|
// (Nur aktivieren, wenn $entries_group sehr groß ist und Performance-Probleme auftreten)
|
|
$maxStartIndexCache = [];
|
|
|
|
foreach ($entries_group as $row) {
|
|
$rohstartindex = intval($row['startIndex']);
|
|
$geraetId = intval($row['geraetId']);
|
|
$abtId = intval($row['abtId']);
|
|
|
|
// Hole maxStartIndex (mit Caching-Logik optional)
|
|
if (!isset($maxStartIndexCache["$abtId-$geraetId"])) {
|
|
$maxStartIndexCache["$abtId-$geraetId"] = db_get_var($mysqli, "SELECT COUNT(*) FROM `$tableTurnerinnenAbt` WHERE abteilung_id = ? AND geraet_id = ?", [$abtId, $geraetId]);
|
|
}
|
|
|
|
$maxstartindex = $maxStartIndexCache["$abtId-$geraetId"];
|
|
|
|
// Sicherheit: Vermeiden Sie Division durch Null oder Modulo durch 0
|
|
if ($maxstartindex < 1) {
|
|
$maxstartindex = 1;
|
|
}
|
|
|
|
// Sicherstellen, dass $indexuser definiert ist (Falls nicht, auf 0 setzen oder Fehler werfen)
|
|
if (!isset($indexuser)) {
|
|
$indexuser = 0; // Fallback, sollte aber eigentlich definiert sein
|
|
}
|
|
|
|
// The order shift depends on the number of rotations the group has made
|
|
$rotation_shift = $aktsubabt - 1;
|
|
|
|
// Robuste Berechnung mit Modulo
|
|
// Ziel: (rohstartindex - rotation_shift - 1) % maxstartindex + 1
|
|
// -1 wird subtrahiert, weil Modulo oft 0-basiert ist, wir aber 1-basiert arbeiten
|
|
$calculedstartindex = (($rohstartindex - $rotation_shift - 1) % $maxstartindex) + 1;
|
|
|
|
// Sicherstellen, dass das Ergebnis positiv ist (PHP Modulo kann negative Ergebnisse liefern)
|
|
// Wenn das Ergebnis negativ ist, addieren wir maxstartindex
|
|
if ($calculedstartindex <= 0) {
|
|
$calculedstartindex += $maxstartindex;
|
|
}
|
|
|
|
// Kopie der Zeile erstellen, um Originaldaten nicht zu verändern
|
|
$row['calculedstartindex'] = $calculedstartindex;
|
|
$entries_with_calculated_index[] = $row;
|
|
}
|
|
|
|
// Sortieren nach dem berechneten Startindex
|
|
usort($entries_with_calculated_index, fn($a, $b) => $a['calculedstartindex'] <=> $b['calculedstartindex']);
|
|
|
|
$entries_to_display = $entries_with_calculated_index;
|
|
} else {
|
|
$entries_to_display = $entries_group;
|
|
}
|
|
|
|
// Table Header creator with run columns
|
|
|
|
$arrayIndexedNoten = [];
|
|
$arrayIndexedNotenHeader = [];
|
|
$uidN = 0;
|
|
|
|
foreach ($entries_group as $row) :
|
|
foreach ($disciplinesExtended as $discipline) :
|
|
|
|
// Check if the current user/admin is allowed to see this specific discipline
|
|
if ($discipline['id'] === 0 || $selecteduser === strtolower($discipline['name']) || $selecteduser === 'admin') :
|
|
|
|
// 2. Now iterate through the scoring configurations for this discipline
|
|
foreach ($notenConfig as $snC) {
|
|
$showAdmin = isAdmin() && intval($snC['zeige_in_tabelle_admin']) === 1;
|
|
$showPublic = !isAdmin() && intval($snC['zeige_in_tabelle']) === 1;
|
|
|
|
if (!($showAdmin || $showPublic)) { continue; }
|
|
|
|
if (intval($snC['pro_geraet']) === 1 && intval($discipline['id']) === 0) { continue; }
|
|
|
|
if (intval($snC['pro_geraet']) !== 1) {
|
|
$allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : [];
|
|
if (!in_array($discipline['id'], $allowedGeraete)) { continue; }
|
|
}
|
|
|
|
$mobile = (intval($snC['zeige_in_tabelle_mobile']) === 1) ? "" : "notMobile";
|
|
|
|
// Logic to fetch and format the value
|
|
$defaultValue = $snC['default_value'] ?? 0;
|
|
|
|
$runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
|
|
|
$runs = $runsJSON[$discipline['id']][$indexedProgrammes[$row['programm'] ?? ''] ?? ''] ?? $runsJSON["default"] ?? 1;
|
|
|
|
for ($r = 1; $r <= $runs; $r++) :
|
|
$note = $notenIndexed[$row['id']][$discipline['id']][$snC['id']][$r] ?? $defaultValue;
|
|
$normalizedNote = number_format($note, $snC['nullstellen'] ?? 2);
|
|
|
|
$arrayIndexedNoten[intval($row['id'])][intval($discipline['id'])][intval($snC['id'])][intval($r)] = ["value" => $normalizedNote, "mobile" => $mobile];
|
|
$arrayIndexedNotenHeader[intval($discipline['id'])][intval($snC['id'])][intval($r)] = ["mobile" => $mobile];
|
|
|
|
$uidN++;
|
|
endfor;
|
|
}
|
|
endif;
|
|
endforeach;
|
|
endforeach;
|
|
|
|
|
|
$localPath = $_SERVER['DOCUMENT_ROOT'] . "/wp-content/ergebnisse/KTBB_Ergebnisse_" . $abteilung . "_" . $current_year . ".pdf";
|
|
echo '<div class="singleAbtDiv">';
|
|
if ($selecteduser === 'admin') echo '<h2 class="titleSingleAbt">'. strtoupper($abteilung);
|
|
if ($selecteduser === 'admin' && file_exists($localPath)) { ?> - <span style="color:#378d37">Rangliste Online</span> <?php } ?></h2>
|
|
<div class="tableWraperOverflowY">
|
|
<table class="widefat striped wkvsTabelle">
|
|
<thead>
|
|
<tr>
|
|
<?php if ($selecteduser === 'admin') {
|
|
$textheadingrang = ($focus_view_admin === true) ? 'Rang':'Rang<br><span style="font-size: 50%; text-align: center; display: flex; margin-top: 5px;">je Programm</span>';
|
|
echo '<th>'.$textheadingrang.'</th>';
|
|
}
|
|
|
|
if (!isAdmin() || $focus_view_admin == true){
|
|
echo '<th>RF</th>';
|
|
}?>
|
|
<th>Name</th>
|
|
<?php if ($selecteduser === 'admin') { echo '<th>Jg.</th>'; } ?>
|
|
<th class="notMobile">Verein</th>
|
|
<th class="notMobile">Programm</th>
|
|
<?php if ($selecteduser === 'admin' || $selecteduser === 'boden'){ ?>
|
|
<th class="notMobile">Musik Boden</th>
|
|
<?php }
|
|
|
|
foreach ($arrayIndexedNotenHeader as $dis => $aNtypes) :
|
|
foreach ($aNtypes as $nType => $aRuns) :
|
|
$displayRunType = count($aRuns) > 1;
|
|
foreach ($aRuns as $run => $cArray) :
|
|
$displayRunString = $displayRunType ? '<sup>' . $run . '</sup>' : '';
|
|
$displayDisciplinesString = isset($indexedDisciplines[$dis]) ? ' ' . $indexedDisciplines[$dis] : '';
|
|
?>
|
|
<th class="<?= $cArray["mobile"] ?>">
|
|
<?= $indexedNotenNames[$nType] ?><?= $displayRunString ?><?= $displayDisciplinesString ?>
|
|
</th>
|
|
<?php endforeach;
|
|
endforeach;
|
|
endforeach;
|
|
|
|
|
|
/*// 1. Iterate through disciplines first
|
|
foreach ($disciplines as $discipline) {
|
|
$lowdiscipline = strtolower($discipline['name']);
|
|
|
|
// Check permissions for this specific discipline
|
|
if ($selecteduser === $lowdiscipline || $selecteduser === 'admin') :
|
|
|
|
// 2. Iterate through config types that are "pro Gerät"
|
|
foreach ($notenConfig as $snC) {
|
|
$showAdmin = isAdmin() && intval($snC['zeige_in_tabelle_admin']) === 1;
|
|
$showPublic = !isAdmin() && intval($snC['zeige_in_tabelle']) === 1;
|
|
|
|
if (!($showAdmin || $showPublic)) { continue; }
|
|
if (intval($snC['pro_geraet']) !== 1) {
|
|
$allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : [];
|
|
if (!in_array($discipline['id'], $allowedGeraete)) { continue; }
|
|
}
|
|
|
|
$runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
|
|
|
if (isset($runsJSON[$discipline['id']])) {
|
|
$runs = $runsJSON[$discipline['id']];
|
|
|
|
foreach ($runs as $r) : ?>
|
|
|
|
<th class="<?= $mobile ?>">
|
|
<?= $snC['name'] . ' ' . ucfirst($lowdiscipline) ?>
|
|
</th>
|
|
|
|
<?php endforeach;
|
|
} else {
|
|
$runs = $runsJSON["default"] ?? 1;
|
|
|
|
for ($r = 1; $r <= $runs; $r++) : ?>
|
|
|
|
<th class="<?= $mobile ?>">
|
|
<?= $snC['name'] . ' ' . ucfirst($lowdiscipline) ?>
|
|
</th>
|
|
|
|
<?php endfor;
|
|
}
|
|
|
|
$mobile = (intval($snC['zeige_in_tabelle_mobile']) === 1) ? "" : "notMobile";
|
|
|
|
|
|
}
|
|
endif;
|
|
}
|
|
|
|
// 3. Handle global columns (pro_geraet === 0)
|
|
// These usually appear at the end of the row (like "Total" or "Rank")
|
|
foreach ($notenConfig as $snC) {
|
|
$showAdmin = isAdmin() && intval($snC['zeige_in_tabelle_admin']) === 1;
|
|
$showPublic = !isAdmin() && intval($snC['zeige_in_tabelle']) === 1;
|
|
|
|
if (!($showAdmin || $showPublic)) { continue; }
|
|
if (intval($snC['pro_geraet']) !== 1) {
|
|
$allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : [];
|
|
if (!in_array(0, $allowedGeraete)) { continue; }
|
|
$mobile = (intval($snC['zeige_in_tabelle_mobile']) === 1) ? "" : "notMobile";
|
|
|
|
$runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
|
|
|
if (isset($runsJSON[0][$snC['id']])) {
|
|
$runs = $runsJSON[0][$snC['id']];
|
|
|
|
foreach ($runs as $r) : ?>
|
|
|
|
<th class="<?= $mobile ?>">
|
|
<?= $snC['name'] ?>
|
|
</th>
|
|
|
|
<?php endforeach;
|
|
} else {
|
|
$runs = $runsJSON["default"] ?? 1;
|
|
|
|
for ($r = 1; $r <= $runs; $r++) : ?>
|
|
|
|
<th class="<?= $mobile ?>">
|
|
<?= $snC['name'] ?>
|
|
</th>
|
|
|
|
<?php endfor;
|
|
}
|
|
?>
|
|
<?php
|
|
}
|
|
}*/
|
|
|
|
?>
|
|
<th>Edit</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php $count = 0; ?>
|
|
<?php foreach ($entries_to_display as $row) : ?>
|
|
<?php
|
|
$is_editing_this_row = isset($_GET['adminEditId']) && intval($_GET['adminEditId']) === intval($row['id']);
|
|
$editingAdminRow = ($is_editing_this_row && isAdmin()) ? 'editingAdminRow' : '' ;
|
|
$count += 1; ?>
|
|
<tr class="notHeaderRow">
|
|
<?php if ($selecteduser === 'admin') { echo '<td><input class="editableValue fullinput" type="number" value="' . htmlspecialchars($row['rang']) . '" data-id="'. intval($row['id']).'" data-discipline="all" data-type="rang" disabled></td>'; } ?>
|
|
|
|
<?php if (isAdmin() && $focus_view_admin) : ?>
|
|
<td><?= htmlspecialchars($row['startIndex']) ?>
|
|
<?php elseif (!isAdmin()) : ?>
|
|
<td style="width:25px; text-align: center;"><?= htmlspecialchars($row['calculedstartindex']) ?></td>
|
|
<?php endif; ?>
|
|
|
|
<td><b><?= htmlspecialchars($row['name']); ?></b><span class="notMobile">, <?= htmlspecialchars($row['vorname']); ?></span></td>
|
|
<?php if ($selecteduser === 'admin') { echo '<td>' . (new DateTime($row['geburtsdatum']))->format("Y") . '</td>'; } ?>
|
|
<td class="notMobile"><?php echo htmlspecialchars($row['verein']); ?></td>
|
|
<td class="notMobile"><?php echo htmlspecialchars($row['programm']); ?></td>
|
|
<?php if ($selecteduser === 'admin' || $selecteduser === 'boden'){
|
|
echo '<td class="notMobile" style="text-align: center;">';
|
|
$music = $row['bodenmusik'];
|
|
if ($music ==! '0'){
|
|
echo'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<circle cx="12" cy="12" r="10" fill="#28a745"></circle>
|
|
<path d="M7 12l3 3 7-7" stroke="white" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
</svg>';
|
|
} else {
|
|
echo $svgnichtbezahlt;
|
|
}
|
|
echo '</td>';
|
|
}
|
|
|
|
$disabledNotenFieldsEditAdmin = ($selecteduser !== 'admin' || $selecteduser === 'admin' && !$is_editing_this_row) ? 'readonly' : '';
|
|
$notMobileNotAdmin = ($selecteduser !== 'admin') ? 'notMobile' : '';
|
|
|
|
|
|
|
|
foreach ($arrayIndexedNotenHeader as $dis => $aNtypes) :
|
|
foreach ($aNtypes as $nType => $aRuns) :
|
|
foreach ($aRuns as $run => $cArray) :
|
|
if (isset($arrayIndexedNoten[intval($row['id'])][intval($dis)][intval($nType)][intval($run)])) : ?>
|
|
<td class="<?= $cArray["mobile"] ?> changebleValue"
|
|
data-field-type-id="<?= $nType ?>"
|
|
data-geraet-id="<?= $dis ?>"
|
|
data-person-id="<?= $row["id"] ?>"
|
|
data-run="<?= $run ?>">
|
|
<?= $arrayIndexedNoten[intval($row['id'])][intval($dis)][intval($nType)][intval($run)]["value"] ?>
|
|
</td>
|
|
<?php else: ?>
|
|
<td class="<?= $cArray["mobile"] ?>">
|
|
---
|
|
</td>
|
|
<?php endif;
|
|
endforeach;
|
|
endforeach;
|
|
endforeach;
|
|
|
|
|
|
/*foreach ($disciplines as $discipline) {
|
|
$lowdiscipline = strtolower($discipline['name']);
|
|
|
|
// Check if the current user/admin is allowed to see this specific discipline
|
|
if ($selecteduser === $lowdiscipline || $selecteduser === 'admin') :
|
|
|
|
// 2. Now iterate through the scoring configurations for this discipline
|
|
foreach ($notenConfig as $snC) {
|
|
$showAdmin = isAdmin() && intval($snC['zeige_in_tabelle_admin']) === 1;
|
|
$showPublic = !isAdmin() && intval($snC['zeige_in_tabelle']) === 1;
|
|
|
|
if (!($showAdmin || $showPublic)) { continue; }
|
|
|
|
if (intval($snC['pro_geraet']) !== 1) {
|
|
$allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : [];
|
|
if (!in_array($discipline['id'], $allowedGeraete)) { continue; }
|
|
}
|
|
|
|
$mobile = (intval($snC['zeige_in_tabelle_mobile']) === 1) ? "" : "notMobile";
|
|
|
|
// Logic to fetch and format the value
|
|
$defaultValue = $snC['default_value'] ?? 0;
|
|
|
|
|
|
$runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
|
|
|
$runs = $runsJSON[$discipline['id']][$indexedProgrammes[$row['programm'] ?? ''] ?? ''] ?? $runsJSON["default"] ?? 1;
|
|
|
|
for ($r = 1; $r <= $runs; $r++) :
|
|
$note = $notenIndexed[$row['id']][$discipline['id']][$snC['id']][$r] ?? $defaultValue;
|
|
$normalizedNote = number_format($note, $snC['nullstellen'] ?? 2);
|
|
?>
|
|
|
|
<td class="<?= $mobile ?> changebleValue"
|
|
data-field-type-id="<?= intval($snC['id']) ?>"
|
|
data-geraet-id="<?= intval($discipline['id']) ?>"
|
|
data-person-id="<?= intval($row['id']) ?>"
|
|
data-run="<?= intval($r) ?>">
|
|
<?= $normalizedNote ?>
|
|
</td>
|
|
|
|
<?php endfor;
|
|
}
|
|
endif;
|
|
}
|
|
|
|
foreach ($notenConfig as $snC) {
|
|
$showAdmin = isAdmin() && intval($snC['zeige_in_tabelle_admin']) === 1;
|
|
$showPublic = !isAdmin() && intval($snC['zeige_in_tabelle']) === 1;
|
|
|
|
if (!($showAdmin || $showPublic)) { continue; }
|
|
if (intval($snC['pro_geraet']) !== 1) {
|
|
$allowedGeraete = !empty($snC['geraete_json']) ? json_decode($snC['geraete_json'], true) : [];
|
|
if (!in_array(0, $allowedGeraete)) { continue; }
|
|
$mobile = (intval($snC['zeige_in_tabelle_mobile']) === 1) ? "" : "notMobile";
|
|
|
|
// Logic to fetch and format the value
|
|
$defaultValue = $snC['default_value'] ?? 0;
|
|
|
|
$runsJSON = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
|
|
|
$runs = $runsJSON[0][$indexedProgrammes[$row['programm'] ?? ''] ?? ''] ?? $runsJSON["default"] ?? 1;
|
|
|
|
for ($r = 1; $r <= $runs; $r++) :
|
|
$note = $notenIndexed[$row['id']][0][$snC['id']][1] ?? $defaultValue;
|
|
$normalizedNote = number_format($note, $snC['nullstellen'] ?? 2);
|
|
?>
|
|
|
|
<td class="<?= $mobile ?> changebleValue"
|
|
data-field-type-id="<?= intval($snC['id']) ?>"
|
|
data-geraet-id="0"
|
|
data-person-id="<?= intval($row['id']) ?>"
|
|
data-run="<?= intval($r) ?>">
|
|
<?= $normalizedNote ?>
|
|
</td>
|
|
|
|
<?php endfor;
|
|
}
|
|
}*/
|
|
|
|
|
|
/*if ($selecteduser === 'admin') {
|
|
echo '<td class="notMobile"><input type="number" class="fullinput editableValue nofield gesammtpunktzahl-field gesammtpunktzahl" data-id="'. intval($row['id']).'" data-discipline="all" data-type="gesamtpunktzahl"
|
|
'.$disabledNotenFieldsEditAdmin.'
|
|
value="'.number_format(floatval($row['gesamtpunktzahl']), 3).'"></td>';
|
|
}*/
|
|
|
|
?>
|
|
|
|
<td style="width:25px; text-align: center;">
|
|
|
|
<button class="editTurnerin" data-person-id="<?= intval($row['id']) ?>" data-geraet-id="<?= intval($itemsToLoop[0]['id']) ?>" aria-label="Bearbeiten" title="Bearbeiten">
|
|
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
<!-- Pen body -->
|
|
<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25z" fill="#536467ff"/>
|
|
|
|
<!-- Cap / eraser -->
|
|
<path d="M20.71 7.04a1.003 1.003 0 0 0 0-1.42l-2.34-2.34a1.003 1.003 0 0 0-1.42 0l-1.83 1.83 3.75 3.75 1.84-1.82z" fill="var(--bg-top)"/>
|
|
</svg>
|
|
|
|
</button>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php endforeach;
|
|
$total_count += $count; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php if ($selecteduser === 'admin'){ if ($count > 1) {
|
|
echo '<p>' .
|
|
$count . ' Turnerinnen</p>';
|
|
} else {
|
|
echo '<p>' . $count .
|
|
' Turnerin</p>';
|
|
}}
|
|
if ($selecteduser === 'admin') {
|
|
echo '<div class="adminButtonDiv">';
|
|
if ($focus_view_admin == false) {
|
|
|
|
echo '<input type="submit" data-field_type="export_programm" data-id="' . $abteilung . '" class="button button-secondary ranglisteExport" value="Rangliste (PDF) herunterladen">';
|
|
|
|
echo '<input type="submit" data-field_type="export_programm_bm" data-id="' . $abteilung . '" class="button button-secondary ranglisteExport ranglisteExportBMDesktop" value="Rangliste (PDF) mit "Meistertitel Beider Basel" herunterladen">';
|
|
echo '<input type="submit" data-field_type="export_programm_bm" data-id="' . $abteilung . '" class="button button-secondary ranglisteExport ranglisteExportBMMobile" value="Rangliste (PDF) mit "MbB" herunterladen">';
|
|
$disabled = !file_exists($localPath) ? 'laden' : 'updaten';
|
|
|
|
echo '<input type="submit" data-field_type="upload_programm" data-id="' . $abteilung . '" class="button button-secondary ranglisteExport" value="Rangliste (PDF) auf Webseite '.$disabled.'">';
|
|
|
|
|
|
echo '<form method="post" style="margin-bottom: 1em;">';
|
|
echo '<input type="hidden" name="programm_remove_export" value="' . $abteilung . '">';
|
|
?>
|
|
<input class="admin-kampfrichter-berechnung-reset-button button button-secondary <?php echo $disabled ? 'disabled-btn' : ''; ?>" type="submit" name="upload_remove_pdf_for_programm" value="PDF von Webseite löschen">
|
|
<?php
|
|
|
|
echo '</form>';
|
|
|
|
} else {
|
|
echo '<input type="submit" name="generate_pdf_for_potocoll" data-abteilung="' . $abteilung . '" class="button button-secondary protokollExport" value="Protokoll herunterladen">';
|
|
|
|
}
|
|
echo '</div>';
|
|
}
|
|
echo '</div>';
|
|
endforeach;
|
|
$mehrzahl = $total_count > 1 ? 'Turnerinnen':'Turnerin';
|
|
if ($selecteduser === 'admin'){
|
|
echo '<p style="font-weight:600; margin: 0px;">Gesamt: '.$total_count.' '.$mehrzahl.'</p>';
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="noKampfrichterDiv"><h1>Keine Kampfrichterinnen ausgewählt</h1></div>
|
|
<?php else : ?>
|
|
<p>Noch keine Datensätze vorhanden.</p>
|
|
<?php endif;?>
|
|
<div class="divLiveSyncronisation"><h2 class="heading-pannel flexRow" id="wsInfo">Live Synchronsation: <span class="fullHeightRectangle" id="wsInfoRectangle"></span></h2></div>
|
|
</section>
|
|
|
|
<?php
|
|
$topBg = '#424242';
|
|
foreach ($disciplines as $d) {
|
|
if (strtolower($d['name']) === $selecteduser) $topBg = $d['color_kampfrichter'];
|
|
}
|
|
|
|
$hex = str_replace('#', '', $topBg);
|
|
|
|
$channels = str_split($hex, 2);
|
|
|
|
$rgb_no_commas = hexdec($channels[0]) . ' ' . hexdec($channels[1]) . ' ' . hexdec($channels[2]);
|
|
|
|
?>
|
|
<style>
|
|
:root {
|
|
--bg-top: <?php echo $topBg; ?>;
|
|
--bg-top-raw: <?php echo $rgb_no_commas; ?>;
|
|
<?php if (isAdmin()) {
|
|
foreach ($disciplines as $d) {
|
|
echo '--color-'.$d['name'].': '.$d['color_kampfrichter'].'10;';
|
|
}
|
|
}?>
|
|
}
|
|
|
|
<?php if (isAdmin()) {
|
|
foreach ($disciplines as $d) {
|
|
echo '
|
|
.field'.ucfirst($d['name']).' {
|
|
position: relative;
|
|
}
|
|
|
|
.field'.ucfirst($d['name']).':before {
|
|
content: "";
|
|
display: block;
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0px;
|
|
height: 100%;
|
|
width: 100%;
|
|
background-color: var(--color-'.$d['name'].');
|
|
z-index: 0;
|
|
pointer-events: none;
|
|
}';
|
|
}
|
|
}
|
|
?>
|
|
</style>
|
|
|
|
<script>
|
|
window.FREIGABE = "<?php echo $selectedfreigabe; ?>";
|
|
window.CSDR_TOKEN = "<?= $csrf_token; ?>";
|
|
window.WS_ACCESS_TOKEN = "<?= generateWSToken('kampfrichter') ?>";
|
|
window.AKTUELLES_JAHR = "<?= $current_year ?>";
|
|
</script>
|
|
|
|
<script src="/intern/scripts/kampfrichter/js/js-kampfrichter-normal.js"></script>
|
|
|
|
<?php if ($selecteduser === 'admin') {
|
|
echo '<script src="/intern/scripts/kampfrichter/js/js-kampfrichter-admin.js"></script>';
|
|
?>
|
|
<script>
|
|
document.querySelectorAll('.saveRowBtn').forEach(btn=>{
|
|
btn.addEventListener('click',()=>{
|
|
const tr = btn.closest('tr');
|
|
const form = document.getElementById('rowSubmitForm');
|
|
|
|
// Clear previous inputs
|
|
document.getElementById('rowInputsContainer').innerHTML = '';
|
|
|
|
// Set row_id
|
|
form.querySelector('input[name="row_id"]').value = tr.dataset.rowId;
|
|
|
|
// Clone all input elements from the row into hidden form
|
|
tr.querySelectorAll('input').forEach(inp=>{
|
|
const hidden = document.createElement('input');
|
|
hidden.type = 'hidden';
|
|
hidden.name = inp.name;
|
|
hidden.value = inp.value;
|
|
document.getElementById('rowInputsContainer').appendChild(hidden);
|
|
});
|
|
|
|
form.submit();
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
} elseif (!in_array('admin', $arrayfreigaben)) {
|
|
echo '<script src="/intern/scripts/kampfrichter/js/js-kampfrichter-not-admin-freigabe.js"></script>';
|
|
} ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
if (isset($form_message) && $form_message !== '') {
|
|
echo '<script>displayMsg(1, "'.$form_message.'");</script>';
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|