Semi-stable version with old variable names
This commit is contained in:
@@ -14,13 +14,6 @@ check_user_permission('kampfrichter');
|
||||
|
||||
verify_csrf();
|
||||
|
||||
|
||||
|
||||
if (!verify_csrf()) {
|
||||
echo json_encode(['success' => false, 'message' => 'Forbidden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Validate editId from POST
|
||||
if (isset($_POST['editId'])) {
|
||||
$editId = intval($_POST['editId']);
|
||||
@@ -37,8 +30,6 @@ if ($editId === false) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
require $baseDir . '/../scripts/db/db-functions.php';
|
||||
require $baseDir . '/../scripts/db/db-tables.php';
|
||||
|
||||
@@ -51,21 +42,41 @@ if (!($data['success'] ?? false)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$isAdmin = (($_SESSION['selectedFreigabeKampfrichter'] ?? '') === 'admin') ? true : false;
|
||||
$is_payed = db_get_var($mysqli, "SELECT 1 FROM $tableTeilnehmende WHERE id = ? AND ((bezahltoverride = ?) OR (bezahlt = ? AND bezahltoverride != ? AND bezahltoverride != ?))", [$editId, 5, 2, 3, 4]);
|
||||
|
||||
if ($is_payed != '1') {
|
||||
echo json_encode(['success'=> false, 'message'=> 'Startgebühr nicht bezahlt']);
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
$isAdmin = (($_SESSION['selectedFreigabeIdKampfrichter'] ?? '') === 'A') ? true : false;
|
||||
|
||||
$disciplines = db_select($mysqli, $tableGeraete, 'id', '', [], 'start_index ASC');
|
||||
|
||||
$disciplines = array_column($disciplines, "id");
|
||||
|
||||
if (!$isAdmin) {
|
||||
$requested_discipline = trim($_POST['geraet'] ?? '');
|
||||
|
||||
$discipline = intval($_POST['geraet']) ?? 0;
|
||||
$all_disciplines = false;
|
||||
|
||||
if (!in_array($discipline, $disciplines)) {
|
||||
if ($isAdmin && $requested_discipline === 'A') {
|
||||
$all_disciplines = true;
|
||||
} else {
|
||||
$requested_discipline = (int) $requested_discipline;
|
||||
|
||||
if (!in_array($requested_discipline, $disciplines)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Falsche Geräte ID']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$discipline = $requested_discipline;
|
||||
}
|
||||
|
||||
if ($all_disciplines) {
|
||||
$stmt = $mysqli->prepare("SELECT t.`name`, t.`vorname`, t.`programm`, p.id as programm_id FROM $tableTeilnehmende t LEFT JOIN $tableProgramme p ON p.programm = t.programm WHERE t.id = ?");
|
||||
} else {
|
||||
|
||||
$disciplines = [$discipline];
|
||||
|
||||
|
||||
@@ -78,7 +89,7 @@ if (!$isAdmin) {
|
||||
agg.abteilung,
|
||||
agg.geraeteIndex,
|
||||
agg.startIndex
|
||||
FROM $tableTurnerinnen t
|
||||
FROM $tableTeilnehmende t
|
||||
LEFT JOIN $tableProgramme p ON p.programm = t.programm
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
@@ -86,7 +97,7 @@ if (!$isAdmin) {
|
||||
GROUP_CONCAT(DISTINCT a.name SEPARATOR ', ') AS abteilung,
|
||||
GROUP_CONCAT(DISTINCT g.start_index SEPARATOR ', ') AS geraeteIndex,
|
||||
ta.turnerin_index AS startIndex
|
||||
FROM $tableTurnerinnenAbt ta
|
||||
FROM $tableTeilnehmendeAbt ta
|
||||
INNER JOIN $tableAbt a
|
||||
ON a.id = ta.abteilung_id
|
||||
LEFT JOIN $tableGeraete g
|
||||
@@ -96,10 +107,7 @@ if (!$isAdmin) {
|
||||
WHERE t.id = ?
|
||||
");
|
||||
|
||||
} else {
|
||||
$stmt = $mysqli->prepare("SELECT t.`name`, t.`vorname`, t.`programm`, p.id as programm_id FROM $tableTurnerinnen t LEFT JOIN $tableProgramme p ON p.programm = t.programm WHERE t.id = ?");
|
||||
}
|
||||
|
||||
$stmt->bind_param('i', $editId);
|
||||
|
||||
$stmt->execute();
|
||||
@@ -118,7 +126,7 @@ $now = new DateTime();
|
||||
|
||||
$jahr = ($now->format('n') > 6) ? $now->modify('+1 year')->format('Y') : $now->format('Y');
|
||||
|
||||
if ($isAdmin) {
|
||||
if ($all_disciplines) {
|
||||
$stmt = $mysqli->prepare("SELECT `note_bezeichnung_id`, `value`, `geraet_id`, `run_number` FROM $tableNoten WHERE `person_id` = ? AND `jahr` = ?");
|
||||
|
||||
$stmt->bind_param('ss', $editId, $jahr);
|
||||
@@ -177,7 +185,7 @@ foreach ($disciplines as $d) {
|
||||
// Determine number of runs for this program
|
||||
$anzRunsConfig = !empty($snC['anzahl_laeufe_json']) ? json_decode($snC['anzahl_laeufe_json'], true) : [];
|
||||
|
||||
$runs = $anzRunsConfig[$d][$programm_id] ?? $anzRunsConfig['default'] ?? 1;
|
||||
$runs = $anzRunsConfig[$d][$programm_id] ?? $anzRunsConfig[$d]["all"] ?? $anzRunsConfig['default'] ?? 1;
|
||||
|
||||
if (isset($displayNoten) && array_key_exists($snC['id'], $displayNoten)) {
|
||||
$displayNoten[$snC['id']] = $runs;
|
||||
@@ -199,10 +207,9 @@ if (isset($displayNoten)) {
|
||||
|
||||
$titel = $row['vorname'].' '.$row['name'].', '.$row['programm'];
|
||||
|
||||
if (!$isAdmin) {
|
||||
|
||||
// $entries = db_select($mysqli, $tableTurnerinnen, 'name, vorname, programm, id', 'abteilung = ? AND startgeraet = ?', [$row['abteilung'], $row['startgeraet']]);
|
||||
if (!$all_disciplines) {
|
||||
|
||||
|
||||
$stmt = $mysqli->prepare("
|
||||
SELECT
|
||||
t.name,
|
||||
@@ -212,14 +219,14 @@ if (!$isAdmin) {
|
||||
agg.abteilung,
|
||||
agg.geraeteIndex,
|
||||
agg.startIndex
|
||||
FROM $tableTurnerinnen t
|
||||
FROM $tableTeilnehmende t
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ta.turnerin_id,
|
||||
GROUP_CONCAT(DISTINCT a.name SEPARATOR ', ') AS abteilung,
|
||||
GROUP_CONCAT(DISTINCT g.start_index SEPARATOR ', ') AS geraeteIndex,
|
||||
ta.turnerin_index AS startIndex
|
||||
FROM $tableTurnerinnenAbt ta
|
||||
FROM $tableTeilnehmendeAbt ta
|
||||
INNER JOIN $tableAbt a
|
||||
ON a.id = ta.abteilung_id
|
||||
LEFT JOIN $tableGeraete g
|
||||
|
||||
Reference in New Issue
Block a user