Compare commits
129
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a84b13a5c2 | ||
|
|
5ebed74e12 | ||
|
|
b80e44fd32 | ||
|
|
5d027879ba | ||
|
|
854e6d03cb | ||
|
|
66eb55d264 | ||
|
|
26f5519888 | ||
|
|
405b9c27e7 | ||
|
|
6ad068c940 | ||
|
|
ecea3fe741 | ||
|
|
e570dcce25 | ||
|
|
951253c559 | ||
|
|
8f84260186 | ||
|
|
448bffd2f5 | ||
|
|
db392d915d | ||
|
|
584f168074 | ||
|
|
ce0d16c1ed | ||
|
|
b1416aa933 | ||
|
|
c8f4f47439 | ||
|
|
86c20a63bf | ||
|
|
1fba004b9b | ||
|
|
9622e35ca3 | ||
|
|
2748349060 | ||
|
|
ebbb6551f7 | ||
|
|
992ac5eb6a | ||
|
|
d37937f4d8 | ||
|
|
523400ac0e | ||
|
|
2064546b19 | ||
|
|
d71e2c1e2d | ||
|
|
62dadd175c | ||
|
|
3c9eb7091f | ||
|
|
7abcac5f04 | ||
|
|
7d03579d31 | ||
|
|
742c5d5b56 | ||
|
|
0952d6de13 | ||
|
|
5a9a08421f | ||
|
|
ffcc8821ed | ||
|
|
72f188e239 | ||
|
|
6ec159f75c | ||
|
|
d6e70a08eb | ||
|
|
52446cc019 | ||
|
|
10472843a7 | ||
|
|
771f9e7bf6 | ||
|
|
a066c59576 | ||
|
|
388f9b8f0d | ||
|
|
b08857a4cd | ||
|
|
6d68fbc25d | ||
|
|
dceb02a3de | ||
|
|
cd325270f0 | ||
|
|
efa9584baf | ||
|
|
ac202be4a7 | ||
|
|
24e11e14a3 | ||
|
|
5305fcabb6 | ||
|
|
3f7c840c39 | ||
|
|
378c462b1c | ||
|
|
5f1aa1c6fc | ||
|
|
5ac4fa4ac6 | ||
|
|
3eb451069b | ||
|
|
caf62ea701 | ||
|
|
82fe6e85d8 | ||
|
|
40c26e625b | ||
|
|
2901a5e362 | ||
|
|
2231d65465 | ||
|
|
4558a717fa | ||
|
|
b2b4ac2124 | ||
|
|
f7fd4ed183 | ||
|
|
a73b2ec13f | ||
|
|
dce0a0caed | ||
|
|
3d8c4291be | ||
|
|
a0afeabb27 | ||
|
|
96c27a8722 | ||
|
|
4478f7e82f | ||
|
|
c1f3c3ea4e | ||
|
|
2a8564d3bf | ||
|
|
14f4143207 | ||
|
|
53b4bd3423 | ||
|
|
386bef9094 | ||
|
|
4e52aa468f | ||
|
|
f4b65903f7 | ||
|
|
29a1be5d22 | ||
|
|
51bc1f7876 | ||
|
|
4e0fcfea3f | ||
|
|
63373ac90c | ||
|
|
966ed2690c | ||
|
|
51ce63b0f0 | ||
|
|
d9f98176c5 | ||
|
|
2aa48a2601 | ||
|
|
2bd315efcd | ||
|
|
d862ed1102 | ||
|
|
5cc4fd0d10 | ||
|
|
24cb1be31f | ||
|
|
955744ee7e | ||
|
|
88f01fe156 | ||
|
|
0c189487c6 | ||
|
|
50934501ab | ||
|
|
54c77e4651 | ||
|
|
351ec88131 | ||
|
|
7ac6a3cd49 | ||
|
|
236fe1fd7f | ||
|
|
4b30f00872 | ||
|
|
e0a4f9ff77 | ||
|
|
ae5beb7ff3 | ||
|
|
614531394d | ||
|
|
773d48f6dd | ||
|
|
b98c8f39d7 | ||
|
|
c286ec3aa2 | ||
|
|
05086a12f5 | ||
|
|
9f76387eec | ||
|
|
d2e076e683 | ||
|
|
80184ed2f0 | ||
|
|
8e2270c674 | ||
|
|
53eb3d4bc2 | ||
|
|
527e783c75 | ||
|
|
6bcdf3f9e3 | ||
|
|
e58bfb6bb1 | ||
|
|
fc665213b3 | ||
|
|
d9ae978837 | ||
|
|
0559317875 | ||
|
|
865320a75c | ||
|
|
35dcb96e5d | ||
|
|
037396fec0 | ||
|
|
d916632d1b | ||
|
|
182997b3fb | ||
|
|
306e3b9c28 | ||
|
|
24a36b020d | ||
|
|
e3dae4c853 | ||
|
|
66fd469c3a | ||
|
|
0846dea367 | ||
|
|
2511b94616 |
No files matched your search
@@ -1,2 +1,3 @@
|
|||||||
WEBROOT/config_backups/*
|
WEBROOT/config_backups/*
|
||||||
WEBROOT/static/*
|
WEBROOT/static/*
|
||||||
|
WEBROOT/sitemap.xml
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"workbench.colorTheme": "Default Dark Modern",
|
"workbench.colorTheme": "Dark Modern",
|
||||||
"workbench.colorCustomizations": {
|
"workbench.colorCustomizations": {
|
||||||
"activityBar.background": "#ff000075",
|
"activityBar.background": "#ff000075",
|
||||||
"activityBar.foreground": "#000000",
|
"activityBar.foreground": "#000000",
|
||||||
|
|||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "============================="
|
|
||||||
echo " Git Management Script"
|
|
||||||
echo "============================="
|
|
||||||
echo ""
|
|
||||||
echo "1) Geänderte Dateien anzeigen"
|
|
||||||
echo "2) Einzelne Dateien zum Commit auswählen"
|
|
||||||
echo "3) Alles stagen"
|
|
||||||
echo "4) Commit & Push"
|
|
||||||
echo "5) Alte Stände anzeigen"
|
|
||||||
echo "6) Aktueller Branch"
|
|
||||||
echo "7) Änderungen"
|
|
||||||
echo "99) Programm beenden"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
read -p "Auswahl: " auswahl
|
|
||||||
|
|
||||||
case $auswahl in
|
|
||||||
|
|
||||||
1)
|
|
||||||
echo "Geänderte Dateien:"
|
|
||||||
git status -s
|
|
||||||
;;
|
|
||||||
|
|
||||||
2)
|
|
||||||
echo "Geänderte Dateien:"
|
|
||||||
git status -s
|
|
||||||
echo ""
|
|
||||||
read -p "Welche Datei soll gestaged werden? (Pfad eingeben): " file
|
|
||||||
git add "$file"
|
|
||||||
echo ">> Datei '$file' wurde gestaged."
|
|
||||||
;;
|
|
||||||
|
|
||||||
3)
|
|
||||||
echo ">> Alle Dateien werden gestaged..."
|
|
||||||
git add -A
|
|
||||||
;;
|
|
||||||
|
|
||||||
4)
|
|
||||||
read -p "Commit Nachricht: " commitmsg
|
|
||||||
git commit -m "$commitmsg"
|
|
||||||
echo ">> Pushen..."
|
|
||||||
git push
|
|
||||||
;;
|
|
||||||
|
|
||||||
5)
|
|
||||||
echo ">> Alte Commits:"
|
|
||||||
git log --oneline --graph --decorate --all
|
|
||||||
;;
|
|
||||||
6)
|
|
||||||
echo "Aktueller Branch"
|
|
||||||
git branch
|
|
||||||
;;
|
|
||||||
7)
|
|
||||||
echo "Änderungen"
|
|
||||||
git status
|
|
||||||
;;
|
|
||||||
|
|
||||||
99)
|
|
||||||
echo "Beendet."
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Ungültige Auswahl!"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
RewriteRule ^(Commands|config_backups|controller|modules)($|/.*) - [F,L,NC]
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||||
|
|
||||||
|
# -----------------------------------
|
||||||
|
# .php entfernen
|
||||||
|
# -----------------------------------
|
||||||
|
|
||||||
|
# browser requestet datei.php -> redirect zu /datei
|
||||||
|
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
|
||||||
|
RewriteRule ^ /%1 [R=301,L]
|
||||||
|
|
||||||
|
# /datei -> datei.php
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
|
||||||
|
RewriteRule ^(.+)$ $1.php [L]
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
// loginTest.php
|
||||||
|
|
||||||
|
$loginUrl = "https://backend.mrhossa.de/login.php"; // URL zu deinem Login-Script
|
||||||
|
|
||||||
|
// Testfälle
|
||||||
|
$tests = [
|
||||||
|
[
|
||||||
|
'username' => 'Bruno', // korrektes Testkonto
|
||||||
|
'password' => 'bBHofurUJWKzPE8Z', // korrektes Passwort
|
||||||
|
'expected' => true,
|
||||||
|
'description' => 'Erfolgreiches Login'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'username' => 'admin',
|
||||||
|
'password' => 'falschespasswort',
|
||||||
|
'expected' => false,
|
||||||
|
'description' => 'Fehlerhaftes Login'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($tests as $test) {
|
||||||
|
$ch = curl_init();
|
||||||
|
|
||||||
|
curl_setopt($ch, CURLOPT_URL, $loginUrl);
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
|
||||||
|
'username' => $test['username'],
|
||||||
|
'password' => $test['password']
|
||||||
|
]));
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HEADER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // Wichtige Info: redirect erkennen
|
||||||
|
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||||
|
$body = substr($response, $headerSize);
|
||||||
|
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
// Prüfen, ob Login erfolgreich war: Redirect auf index.php oder Session gesetzt
|
||||||
|
if (strpos($response, "Location: index.php") !== false || strpos($body, "Login fehlgeschlagen") === false) {
|
||||||
|
$success = true;
|
||||||
|
} else {
|
||||||
|
$success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($success === $test['expected']) {
|
||||||
|
echo "[PASS] {$test['description']}\n";
|
||||||
|
} else {
|
||||||
|
echo "[FAIL] {$test['description']}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . "/../controller/DatabaseController.php");
|
||||||
|
include_once(__DIR__ . "/../modules/Mail.php");
|
||||||
|
|
||||||
|
date_default_timezone_set("Europe/Berlin");
|
||||||
|
|
||||||
|
$jetzt = new DateTime();
|
||||||
|
$heute = $jetzt->format("Y-m-d");
|
||||||
|
|
||||||
|
// Alle heutigen Termine laden
|
||||||
|
$termine = DatabaseShow(
|
||||||
|
"Termine",
|
||||||
|
"*",
|
||||||
|
"DATUM = ? AND ERINNERUNG_AM IS NULL",
|
||||||
|
$heute
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($termine as $termin) {
|
||||||
|
|
||||||
|
$terminZeit = new DateTime($termin["DATUM"] . " " . $termin["ZEIT"]);
|
||||||
|
$sekundenBisTermin = $terminZeit->getTimestamp() - $jetzt->getTimestamp();
|
||||||
|
|
||||||
|
// Nur Termine innerhalb der nächsten 30 Minuten
|
||||||
|
if ($sekundenBisTermin > 0 && $sekundenBisTermin <= 1800) {
|
||||||
|
|
||||||
|
// Benutzer laden
|
||||||
|
$benutzer = DatabaseShow(
|
||||||
|
"Benutzer",
|
||||||
|
"*",
|
||||||
|
"NAME = ?",
|
||||||
|
$termin["ERSTELLT_VON"]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (empty($benutzer)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$benutzer = $benutzer[0];
|
||||||
|
|
||||||
|
if (empty($benutzer["EMAIL"])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject = "Terminerinnerung";
|
||||||
|
|
||||||
|
$message = "Hallo {$benutzer["NAME"]},\n\n";
|
||||||
|
$message .= "Du hast in weniger als 30 Minuten einen Termin.\n\n";
|
||||||
|
$message .= "Termin: {$termin["NAME"]}\n";
|
||||||
|
$message .= "Datum: {$termin["DATUM"]}\n";
|
||||||
|
$message .= "Uhrzeit: {$termin["ZEIT"]}\n";
|
||||||
|
|
||||||
|
if (!empty($termin["NOTIZ"])) {
|
||||||
|
$notizClean = mb_convert_encoding($termin["NOTIZ"], "UTF-8", "auto");
|
||||||
|
$message .= "Notiz: {$notizClean}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMail(
|
||||||
|
$subject,
|
||||||
|
$message,
|
||||||
|
$_SERVER['SCRIPT_NAME'] ?? 'CLI/Unbekannt',
|
||||||
|
true,
|
||||||
|
$benutzer["EMAIL"],
|
||||||
|
);
|
||||||
|
|
||||||
|
print_r("{$benutzer["EMAIL"]}\n{$message}");
|
||||||
|
|
||||||
|
DatabaseUpdate(
|
||||||
|
"Termine",
|
||||||
|
"ERINNERUNG_AM = ?",
|
||||||
|
"ID = ?",
|
||||||
|
date('d-m-Y H:i:s'),
|
||||||
|
$termin["ID"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
include_once(__DIR__ . '/../../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
$deniedTables = [];
|
||||||
|
|
||||||
|
$validOperations = ['=', '!=', '<', '>', '<=', '>=', 'LIKE'];
|
||||||
|
|
||||||
|
function isValidEntry(string $name): bool {
|
||||||
|
return (bool) preg_match('/^[a-zA-Z0-9_]+$/', $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function PermittedSchemas(array $deniedTables): array {
|
||||||
|
static $cache = null;
|
||||||
|
if ($cache !== null) {
|
||||||
|
return $cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
$alleSchemas = DatabaseShowAllSchemas(); // 1 Query statt N+1
|
||||||
|
$schema = [];
|
||||||
|
|
||||||
|
foreach ($alleSchemas as $table => $columns) {
|
||||||
|
if (!isValidEntry($table)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (in_array($table, $deniedTables, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$schema[$table] = $columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache = $schema;
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
$erlaubteSchema = PermittedSchemas($deniedTables);
|
||||||
|
|
||||||
|
function isValidTable(string $table, array $schema): void {
|
||||||
|
if (!isValidEntry($table) || !isset($schema[$table])) {
|
||||||
|
throw new InvalidArgumentException("Tabelle nicht erlaubt: $table");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidColumn(string $table, array $columns, array $schema): void {
|
||||||
|
foreach ($columns as $col) {
|
||||||
|
if (!isValidEntry($col) || !in_array($col, $schema[$table], true)) {
|
||||||
|
throw new InvalidArgumentException("Spalte nicht erlaubt: $col");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildWhere(array $conditions, string $table, array $schema, array $validOperations): array {
|
||||||
|
$parts = [];
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
foreach ($conditions as $cond) {
|
||||||
|
$col = $cond['column'] ?? '';
|
||||||
|
$op = $cond['operator'] ?? '=';
|
||||||
|
$val = $cond['value'] ?? null;
|
||||||
|
|
||||||
|
isValidColumn($table, [$col], $schema);
|
||||||
|
|
||||||
|
if (!in_array($op, $validOperations, true)) {
|
||||||
|
throw new InvalidArgumentException("Ungültiger Operator: $op");
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts[] = "`$col` $op ?";
|
||||||
|
$values[] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [implode(' AND ', $parts), $values];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request einlesen
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
$table = $daten['table'] ?? '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
isValidTable($table, $erlaubteSchema);
|
||||||
|
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
case 'insert': {
|
||||||
|
$columns = $daten['columns'] ?? [];
|
||||||
|
$values = $daten['values'] ?? [];
|
||||||
|
|
||||||
|
isValidColumn($table, $columns, $erlaubteSchema);
|
||||||
|
|
||||||
|
if (count($columns) !== count($values)) {
|
||||||
|
throw new InvalidArgumentException('Anzahl der Werte passt nicht zu den Spalten');
|
||||||
|
}
|
||||||
|
|
||||||
|
$columnsSql = implode(', ', array_map(fn($c) => "`$c`", $columns));
|
||||||
|
$result = DatabaseInsert($table, $columnsSql, ...$values);
|
||||||
|
echo json_encode(['success' => $result]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'show': {
|
||||||
|
$columns = $daten['columns'] ?? [];
|
||||||
|
$conditions = $daten['conditions'] ?? [];
|
||||||
|
|
||||||
|
if (empty($columns)) {
|
||||||
|
$columns = $erlaubteSchema[$table];
|
||||||
|
} else {
|
||||||
|
isValidColumn($table, $columns, $erlaubteSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
$columnsSql = implode(', ', array_map(fn($c) => "`$c`", $columns));
|
||||||
|
[$whereSql, $values] = buildWhere($conditions, $table, $erlaubteSchema, $validOperations);
|
||||||
|
|
||||||
|
$result = DatabaseShow($table, $columnsSql, $whereSql, ...$values);
|
||||||
|
echo json_encode(['success' => true, 'entries' => array_values($result ?? [])]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'update': {
|
||||||
|
$updates = $daten['updates'] ?? [];
|
||||||
|
$conditions = $daten['conditions'] ?? [];
|
||||||
|
|
||||||
|
if (empty($conditions)) {
|
||||||
|
throw new InvalidArgumentException('WHERE-Bedingung ist bei UPDATE Pflicht');
|
||||||
|
}
|
||||||
|
|
||||||
|
isValidColumn($table, array_keys($updates), $erlaubteSchema);
|
||||||
|
|
||||||
|
$setParts = [];
|
||||||
|
$setValues = [];
|
||||||
|
foreach ($updates as $col => $val) {
|
||||||
|
$setParts[] = "`$col` = ?";
|
||||||
|
$setValues[] = $val;
|
||||||
|
}
|
||||||
|
$setSql = implode(', ', $setParts);
|
||||||
|
|
||||||
|
[$whereSql, $whereValues] = buildWhere($conditions, $table, $erlaubteSchema, $validOperations);
|
||||||
|
|
||||||
|
$result = DatabaseUpdate($table, $setSql, $whereSql, ...array_merge($setValues, $whereValues));
|
||||||
|
echo json_encode(['success' => $result]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'delete': {
|
||||||
|
$conditions = $daten['conditions'] ?? [];
|
||||||
|
|
||||||
|
if (empty($conditions)) {
|
||||||
|
throw new InvalidArgumentException('WHERE-Bedingung ist bei DELETE Pflicht');
|
||||||
|
}
|
||||||
|
|
||||||
|
[$whereSql, $values] = buildWhere($conditions, $table, $erlaubteSchema, $validOperations);
|
||||||
|
|
||||||
|
$result = DatabaseDelete($table, $whereSql, ...$values);
|
||||||
|
echo json_encode(['success' => $result]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
$username = $_SESSION['username'] ?? 'Gast';
|
||||||
|
|
||||||
|
$erlaubteIntervalle = ['daily' => '+1 day', 'weekly' => '+1 week', 'monthly' => '+1 month'];
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
// ---------- Termine laden (nur die eigenen, serienweise gruppiert) ----------
|
||||||
|
case 'get_entries': {
|
||||||
|
$termine = DatabaseShow(
|
||||||
|
"Termine",
|
||||||
|
"MAX(ID) as ID, MIN(DATUM) as DATUM, ZEIT, NAME, NOTIZ, ERSTELLT_VON, SERIEN_ID, INTERVALL, SERIEN_ENDE",
|
||||||
|
"ERSTELLT_VON = ? GROUP BY IFNULL(SERIEN_ID, ID) ORDER BY DATUM ASC, ZEIT ASC",
|
||||||
|
$username
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'entries' => array_values($termine ?? [])]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Neuen Termin (einzeln oder als Serie) anlegen ----------
|
||||||
|
case 'add_termin': {
|
||||||
|
$datum = trim($daten['datum'] ?? '');
|
||||||
|
$zeit = trim($daten['zeit'] ?? '');
|
||||||
|
$name = trim($daten['name'] ?? '');
|
||||||
|
$notiz = trim($daten['notiz'] ?? '');
|
||||||
|
$wiederholung = $daten['wiederholung'] ?? 'none';
|
||||||
|
$enddatum = trim($daten['enddatum'] ?? '');
|
||||||
|
|
||||||
|
if ($datum === '' || $zeit === '' || $name === '') {
|
||||||
|
throw new InvalidArgumentException('Bitte alle Pflichtfelder ausfüllen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- Serientermin -----
|
||||||
|
if ($wiederholung !== 'none' && $enddatum !== '') {
|
||||||
|
|
||||||
|
if (!isset($erlaubteIntervalle[$wiederholung])) {
|
||||||
|
throw new InvalidArgumentException('Ungültiges Wiederholungsintervall.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentDate = new DateTime($datum);
|
||||||
|
$endDate = new DateTime($enddatum);
|
||||||
|
|
||||||
|
if ($endDate < $currentDate) {
|
||||||
|
throw new InvalidArgumentException('Das Enddatum darf nicht vor dem Startdatum liegen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$modifier = $erlaubteIntervalle[$wiederholung];
|
||||||
|
$serienId = uniqid('serie_', true);
|
||||||
|
$insertedCount = 0;
|
||||||
|
|
||||||
|
while ($currentDate <= $endDate) {
|
||||||
|
DatabaseInsert(
|
||||||
|
"Termine",
|
||||||
|
"DATUM, ZEIT, NAME, NOTIZ, ERSTELLT_VON, SERIEN_ID, INTERVALL, SERIEN_ENDE",
|
||||||
|
$currentDate->format('Y-m-d'),
|
||||||
|
$zeit,
|
||||||
|
$name,
|
||||||
|
$notiz,
|
||||||
|
$username,
|
||||||
|
$serienId,
|
||||||
|
$wiederholung,
|
||||||
|
$enddatum
|
||||||
|
);
|
||||||
|
$insertedCount++;
|
||||||
|
$currentDate->modify($modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => "Serientermin ($insertedCount Termine) erfolgreich eingetragen!"]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- Einzeltermin -----
|
||||||
|
DatabaseInsert(
|
||||||
|
"Termine",
|
||||||
|
"DATUM, ZEIT, NAME, NOTIZ, ERSTELLT_VON",
|
||||||
|
$datum,
|
||||||
|
$zeit,
|
||||||
|
$name,
|
||||||
|
$notiz,
|
||||||
|
$username
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Termin erfolgreich eingetragen!']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Einzelnen Termin löschen ----------
|
||||||
|
case 'delete_termin': {
|
||||||
|
$id = $daten['id'] ?? null;
|
||||||
|
|
||||||
|
if (!is_numeric($id)) {
|
||||||
|
throw new InvalidArgumentException('Ungültige ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zusätzlich ERSTELLT_VON prüfen, damit niemand fremde Termine per ID löschen kann
|
||||||
|
DatabaseDelete("Termine", "ID = ? AND ERSTELLT_VON = ?", (int)$id, $username);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Termin erfolgreich gelöscht!']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Komplette Serie löschen ----------
|
||||||
|
case 'delete_serie': {
|
||||||
|
$serienId = trim($daten['serienId'] ?? '');
|
||||||
|
|
||||||
|
if ($serienId === '') {
|
||||||
|
throw new InvalidArgumentException('Ungültige Serien-ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseDelete("Termine", "SERIEN_ID = ? AND ERSTELLT_VON = ?", $serienId, $username);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Komplette Terminserie erfolgreich gelöscht!']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
|
||||||
|
include_once(__DIR__ . '/../../../controller/RoutesController.php');
|
||||||
|
include_once(__DIR__ . '/../../../modules/Mail.php');
|
||||||
|
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
// ---------- Liste laden (nur eigene Tickets) ----------
|
||||||
|
case 'get_entries': {
|
||||||
|
$entries = DatabaseShow(
|
||||||
|
"Tickets",
|
||||||
|
"ID, TITEL, BESCHREIBUNG, STATUS",
|
||||||
|
"ERSTELLER = ?",
|
||||||
|
((new getSpecificData())->getUsername()),
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'entries' => array_values($entries ?? [])]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Neues Ticket anlegen ----------
|
||||||
|
case 'add_entry': {
|
||||||
|
foreach (['titel', 'beschreibung'] as $feld) {
|
||||||
|
if (empty($daten[$feld])) {
|
||||||
|
throw new InvalidArgumentException("Pflichtfeld fehlt: $feld");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$titel = $daten['titel'];
|
||||||
|
$beschreibung = $daten['beschreibung'];
|
||||||
|
$user = ucfirst(strtolower((new getSpecificData())->getUsername()));
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Tickets",
|
||||||
|
"TITEL, BESCHREIBUNG, STATUS, ERSTELLER",
|
||||||
|
$titel,
|
||||||
|
$beschreibung,
|
||||||
|
"OFFEN",
|
||||||
|
$user,
|
||||||
|
);
|
||||||
|
|
||||||
|
sendMail(
|
||||||
|
"Neues Ticket von $user",
|
||||||
|
"Titel: $titel\nBeschreibung: $beschreibung",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Ticket löschen ----------
|
||||||
|
case 'delete_entry': {
|
||||||
|
$id = $daten['id'] ?? null;
|
||||||
|
|
||||||
|
if (!is_numeric($id)) {
|
||||||
|
throw new InvalidArgumentException('Ungültige ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseDelete("Tickets", "ID = ?", (int)$id);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
session_set_cookie_params([
|
||||||
|
'lifetime' => 0,
|
||||||
|
'path' => '/',
|
||||||
|
'domain' => '',
|
||||||
|
'secure' => false,
|
||||||
|
'httponly' => true,
|
||||||
|
'samesite' => 'Lax'
|
||||||
|
]);
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
if (empty($_SESSION['user_logged_in'])) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode(['error' => 'Nicht eingeloggt']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
|
||||||
|
include_once(__DIR__ . '/../../../controller/RoutesController.php');
|
||||||
|
include_once(__DIR__ . '/../../../modules/Mail.php');
|
||||||
|
|
||||||
|
$allowedStatuses = ['OFFEN', 'DEPLOYED', 'ABGELEHNT', 'ANGENOMMEN'];
|
||||||
|
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
// ---------- Alle Tickets laden (Verwaltungsansicht) ----------
|
||||||
|
case 'get_entries': {
|
||||||
|
$entries = DatabaseShow(
|
||||||
|
"Tickets",
|
||||||
|
"ID, TITEL, BESCHREIBUNG, STATUS, ERSTELLER",
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'entries' => array_values($entries ?? [])]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Status ändern ----------
|
||||||
|
case 'edit_entry': {
|
||||||
|
$id = $daten['id'] ?? null;
|
||||||
|
$status = $daten['status'] ?? '';
|
||||||
|
|
||||||
|
if (!is_numeric($id)) {
|
||||||
|
throw new InvalidArgumentException('Ungültige ID');
|
||||||
|
}
|
||||||
|
if (!in_array($status, $allowedStatuses, true)) {
|
||||||
|
throw new InvalidArgumentException('Ungültiger Status');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseUpdate(
|
||||||
|
"Tickets",
|
||||||
|
"STATUS = ?",
|
||||||
|
"ID = ?",
|
||||||
|
$status,
|
||||||
|
(int)$id
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Ticket löschen ----------
|
||||||
|
case 'delete_entry': {
|
||||||
|
$id = $daten['id'] ?? null;
|
||||||
|
|
||||||
|
if (!is_numeric($id)) {
|
||||||
|
throw new InvalidArgumentException('Ungültige ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseDelete("Tickets", "ID = ?", (int)$id);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baut die WHERE-Klausel serverseitig. STATUS IS NULL ist FEST verdrahtet
|
||||||
|
* und niemals durch den Client beeinflussbar -- das ist die eigentliche
|
||||||
|
* Geschäftsregel dieser Seite (nur "aktive" Vergaben werden angezeigt).
|
||||||
|
*/
|
||||||
|
function baueVergabeWhere(string $searchWer, string $searchWas, array &$values): string {
|
||||||
|
$parts = ["STATUS IS NULL"];
|
||||||
|
|
||||||
|
if ($searchWer !== '') {
|
||||||
|
$parts[] = "WER LIKE ?";
|
||||||
|
$values[] = '%' . $searchWer . '%';
|
||||||
|
}
|
||||||
|
if ($searchWas !== '') {
|
||||||
|
$parts[] = "WAS LIKE ?";
|
||||||
|
$values[] = '%' . $searchWas . '%';
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' AND ', $parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
// ---------- Liste laden (mit optionalem Filter) ----------
|
||||||
|
case 'get_entries': {
|
||||||
|
$searchWer = trim($daten['searchWer'] ?? '');
|
||||||
|
$searchWas = trim($daten['searchWas'] ?? '');
|
||||||
|
|
||||||
|
$values = [];
|
||||||
|
$where = baueVergabeWhere($searchWer, $searchWas, $values);
|
||||||
|
|
||||||
|
$entries = DatabaseShow("Vergabe", "ID, WAS, WER, WANN, RUECKGABE", $where, ...$values);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'entries' => array_values($entries ?? [])]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Autocomplete-Vorschläge (alle bekannten WAS/WER, auch zurückgegebene) ----------
|
||||||
|
case 'get_suggestions': {
|
||||||
|
$alle = DatabaseShow("Vergabe");
|
||||||
|
|
||||||
|
$was = [];
|
||||||
|
$wer = [];
|
||||||
|
foreach ($alle as $entry) {
|
||||||
|
if (!empty($entry['WAS'])) $was[$entry['WAS']] = true;
|
||||||
|
if (!empty($entry['WER'])) $wer[$entry['WER']] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'was' => array_keys($was),
|
||||||
|
'wer' => array_keys($wer),
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Neue Vergabe anlegen ----------
|
||||||
|
case 'add_entry': {
|
||||||
|
foreach (['was', 'wer', 'wann', 'rueckgabe'] as $feld) {
|
||||||
|
if (empty($daten[$feld])) {
|
||||||
|
throw new InvalidArgumentException("Pflichtfeld fehlt: $feld");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Vergabe",
|
||||||
|
"WAS, WER, WANN, RUECKGABE",
|
||||||
|
$daten['was'],
|
||||||
|
$daten['wer'],
|
||||||
|
$daten['wann'],
|
||||||
|
$daten['rueckgabe']
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Vergabe als zurückgegeben markieren (Soft-Delete) ----------
|
||||||
|
case 'return_entry': {
|
||||||
|
$id = $daten['id'] ?? null;
|
||||||
|
|
||||||
|
if (!is_numeric($id)) {
|
||||||
|
throw new InvalidArgumentException('Ungültige ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseUpdate("Vergabe", "STATUS = ?", "ID = ?", 1, (int)$id);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
|
$daten = json_decode(file_get_contents('php://input'), true) ?? [];
|
||||||
|
$action = $daten['action'] ?? '';
|
||||||
|
|
||||||
|
$erlaubteGruende = ['Abbau', 'Aufbau', 'Anderes'];
|
||||||
|
|
||||||
|
function istBerechtigt(): bool {
|
||||||
|
$username = $_SESSION['username'] ?? '';
|
||||||
|
return strtolower($username) === 'bruno';
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch ($action) {
|
||||||
|
|
||||||
|
case 'get_stats': {
|
||||||
|
include_once(__DIR__ . '/../../../controller/DatabaseConnect.php');
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$minuten_berichte = 0;
|
||||||
|
$res1 = $conn->query("SELECT SUM(OVERTIME) AS summe FROM Firmenberichte");
|
||||||
|
if ($row = $res1->fetch_object()) { $minuten_berichte = intval($row->summe); }
|
||||||
|
|
||||||
|
$minuten_abbau = 0;
|
||||||
|
$res2 = $conn->query("SELECT SUM(MINUTEN) AS summe FROM Ueberstunden WHERE GRUND = 'Abbau'");
|
||||||
|
if ($row = $res2->fetch_object()) { $minuten_abbau = intval($row->summe); }
|
||||||
|
|
||||||
|
$minuten_aufbau = 0;
|
||||||
|
$res3 = $conn->query("SELECT SUM(MINUTEN) AS summe FROM Ueberstunden WHERE GRUND = 'Aufbau'");
|
||||||
|
if ($row = $res3->fetch_object()) { $minuten_aufbau = intval($row->summe); }
|
||||||
|
|
||||||
|
$gesamt_minuten = $minuten_berichte - $minuten_abbau + $minuten_aufbau;
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'gesamtMinuten' => $gesamt_minuten,
|
||||||
|
'istBerechtigt' => istBerechtigt(),
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'add_overtime': {
|
||||||
|
if (!istBerechtigt()) {
|
||||||
|
http_response_code(403);
|
||||||
|
echo json_encode(['error' => 'Keine Berechtigung für diese Aktion']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datum = trim($daten['datum'] ?? '');
|
||||||
|
$minuten = $daten['minuten'] ?? null;
|
||||||
|
$grund = trim($daten['grund'] ?? '');
|
||||||
|
|
||||||
|
if ($datum === '' || !is_numeric($minuten) || $grund === '') {
|
||||||
|
throw new InvalidArgumentException('Bitte alle Pflichtfelder korrekt ausfüllen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array($grund, $erlaubteGruende, true)) {
|
||||||
|
throw new InvalidArgumentException('Ungültiger Grund.');
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Ueberstunden",
|
||||||
|
"DATUM, MINUTEN, GRUND",
|
||||||
|
$datum,
|
||||||
|
intval($minuten),
|
||||||
|
$grund
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Eintrag erfolgreich gespeichert!']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidArgumentException("Unbekannte Aktion: $action");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
error_log($e->getMessage());
|
||||||
|
echo json_encode(['error' => 'Serverfehler']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
include_once( __DIR__ . '/../../controller/DatabaseController.php');
|
||||||
|
include_once( __DIR__ . '/../../controller/DataController.php');
|
||||||
|
include_once( __DIR__ . '/../../controller/ApiController.php');
|
||||||
|
include_once(__DIR__ . '/../../modules/Mail.php');
|
||||||
|
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
header("Access-Control-Allow-Headers: Authorization, Function, Content-Type");
|
||||||
|
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||||
|
http_response_code(200);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$validTokens = DatabaseShow(
|
||||||
|
"API_Credentials",
|
||||||
|
"TOKEN"
|
||||||
|
);
|
||||||
|
|
||||||
|
$validTokens = array_column($validTokens, 'TOKEN');
|
||||||
|
|
||||||
|
$headers = getallheaders();
|
||||||
|
$token = $headers['Authorization'] ?? $headers['authorization'] ?? $_SERVER['HTTP_AUTHORIZATION'] ?? '';
|
||||||
|
$function = $headers['Function'] ?? $headers['function'] ?? '';
|
||||||
|
|
||||||
|
if (!in_array($token, $validTokens)) {
|
||||||
|
http_response_code(401);
|
||||||
|
$error = json_encode([
|
||||||
|
"error" => "Unauthorized",
|
||||||
|
"debug_received_token" => $token,
|
||||||
|
"debug_all_headers" => $headers
|
||||||
|
]);
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"API_LOGS",
|
||||||
|
"CLIENT_IP, TOKEN, API, FUNKTION, JSON",
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
$token,
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
$function,
|
||||||
|
$error
|
||||||
|
);
|
||||||
|
|
||||||
|
errorMail(
|
||||||
|
"API Login failed",
|
||||||
|
$error,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(
|
||||||
|
[
|
||||||
|
"error" => "Unauthorized",
|
||||||
|
"Contact" => "bruno.eckhardt07@gmail.com",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = null;
|
||||||
|
|
||||||
|
if (in_array($token, $validTokens)) {
|
||||||
|
DatabaseInsert(
|
||||||
|
"API_LOGS",
|
||||||
|
"CLIENT_IP, TOKEN, API, FUNKTION",
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
$token,
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
$function
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($function === "IPs") {
|
||||||
|
$data = DatabaseShow(
|
||||||
|
"logs",
|
||||||
|
"CLIENT_IP"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($function === "Ueberstunden") {
|
||||||
|
$data = DatabaseShow(
|
||||||
|
"Ueberstunden",
|
||||||
|
"MINUTEN"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($function === "Berichte") {
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Berufsschulberichte",
|
||||||
|
$Berufsschulberichte,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(
|
||||||
|
[
|
||||||
|
"success" => true,
|
||||||
|
"data" => $data,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
include_once( __DIR__ . '/../../controller/DatabaseController.php' );
|
||||||
|
include_once( __DIR__ . '/../../controller/DataController.php' );
|
||||||
|
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
header("Access-Control-Allow-Headers: Authorization, Function, Content-Type");
|
||||||
|
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
|
||||||
|
|
||||||
|
$validTokens = [
|
||||||
|
"15a437d128c918633e57dc7d18118a073b807644f21731ed5a7ebcf3eca9e242",
|
||||||
|
];
|
||||||
|
$baseUploadDir = __DIR__ . "/../services/uploads/";
|
||||||
|
|
||||||
|
$headers = getallheaders();
|
||||||
|
$token = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
|
||||||
|
|
||||||
|
$token = trim($token);
|
||||||
|
|
||||||
|
if (!in_array($token, $validTokens, true)) {
|
||||||
|
http_response_code(401);
|
||||||
|
echo json_encode([
|
||||||
|
"error" => "Unauthorized",
|
||||||
|
"received_token" => $token
|
||||||
|
]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_FILES['files'])) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(["error" => "No files uploaded"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$folderName = null;
|
||||||
|
$readmeContent = null;
|
||||||
|
|
||||||
|
// Prüfen ob readme.md hochgeladen wurde
|
||||||
|
foreach ($_FILES['files']['name'] as $key => $name) {
|
||||||
|
if (strtolower($name) === "readme.md") {
|
||||||
|
$tmpName = $_FILES['files']['tmp_name'][$key];
|
||||||
|
$readmeContent = file_get_contents($tmpName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($readmeContent) {
|
||||||
|
// Erste Markdown-Überschrift extrahieren (# Titel)
|
||||||
|
if (preg_match('/^#\s*(.+)$/m', $readmeContent, $matches)) {
|
||||||
|
$rawName = $matches[1];
|
||||||
|
|
||||||
|
// Slug erzeugen (ordner-tauglich machen)
|
||||||
|
$folderName = strtolower($rawName);
|
||||||
|
$folderName = preg_replace("/[^a-z0-9]+/", "-", $folderName);
|
||||||
|
$folderName = trim($folderName, "-");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback falls keine readme oder kein Titel
|
||||||
|
if (!$folderName) {
|
||||||
|
$folderName = uniqid("upload_", true);
|
||||||
|
}
|
||||||
|
$uploadDir = $baseUploadDir . $folderName . "/";
|
||||||
|
|
||||||
|
if (!mkdir($uploadDir, 0755, true)) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(["error" => "Failed to create directory"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$uploadedFiles = [];
|
||||||
|
|
||||||
|
foreach ($_FILES['files']['tmp_name'] as $key => $tmpName) {
|
||||||
|
|
||||||
|
if ($_FILES['files']['error'][$key] !== UPLOAD_ERR_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$originalName = basename($_FILES['files']['name'][$key]);
|
||||||
|
|
||||||
|
$safeName = preg_replace("/[^a-zA-Z0-9._-]/", "", $originalName);
|
||||||
|
|
||||||
|
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||||
|
$mime = $finfo->file($tmpName);
|
||||||
|
|
||||||
|
if ($_FILES['files']['size'][$key] > 25 * 1024 * 1024) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetPath = $uploadDir . $safeName;
|
||||||
|
|
||||||
|
if (move_uploaded_file($tmpName, $targetPath)) {
|
||||||
|
$uploadedFiles[] = $safeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_encode([
|
||||||
|
"success" => true,
|
||||||
|
"folder" => $folderName,
|
||||||
|
"uploaded_files" => $uploadedFiles
|
||||||
|
]);
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"API",
|
||||||
|
"CLIENT_IP, TOKEN, API, FUNKTION, JSON",
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
$token,
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
"Upload",
|
||||||
|
$json
|
||||||
|
);
|
||||||
|
|
||||||
|
echo $json;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../../controller/DatabaseController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/ApiController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$api = (new ApiController());
|
||||||
|
|
||||||
|
if ($api->urlAuth($_GET['token']) == true ) {
|
||||||
|
|
||||||
|
if (isset($_GET['day'])) {
|
||||||
|
|
||||||
|
$day = $_GET['day'];
|
||||||
|
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Stundenplan",
|
||||||
|
$Stundenplan,
|
||||||
|
"ZEITEN, $day",
|
||||||
|
"$day IS NOT NULL AND $day != '' AND $day != '(NULL)' ORDER BY ZEITEN ASC"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Stundenplan",
|
||||||
|
$Stundenplan,
|
||||||
|
"ZEITEN, MO, DI, MO, DO, FR",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
echo $api->jsonSuccess($data);
|
||||||
|
$api->requestSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://localhost:9000/api/v2/lessons.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3
|
||||||
|
* http://localhost:9000/api/v2/lessons.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3&day=FR
|
||||||
|
*/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../../controller/DatabaseController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/ApiController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$api = (new ApiController());
|
||||||
|
|
||||||
|
if ($api->urlAuth($_GET['token']) == true ) {
|
||||||
|
|
||||||
|
if (isset($_GET['date'])) {
|
||||||
|
|
||||||
|
$date = $_GET['date'];
|
||||||
|
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Berufsschulberichte",
|
||||||
|
$Berufsschulberichte,
|
||||||
|
"*",
|
||||||
|
"DATUM = ?",
|
||||||
|
$date
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Berufsschulberichte",
|
||||||
|
$Berufsschulberichte,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
echo $api->jsonSuccess($data);
|
||||||
|
$api->requestSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://localhost:9000/api/v2/schoolReports.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3
|
||||||
|
* http://localhost:9000/api/v2/schoolReports.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3&date=2025-09-09
|
||||||
|
*/
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../../controller/DatabaseController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/../../controller/ApiController.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$api = (new ApiController());
|
||||||
|
|
||||||
|
if ($api->urlAuth($_GET['token']) == true ) {
|
||||||
|
|
||||||
|
if (isset($_GET['date'])) {
|
||||||
|
|
||||||
|
$date = $_GET['date'];
|
||||||
|
|
||||||
|
$data = DatabaseShow(
|
||||||
|
"Firmenberichte",
|
||||||
|
"DATUM, PROZESS_1, PROZESS_2, PROZESS_3, PROZESS_4, BEGINN, ENDE_PUBLIC",
|
||||||
|
"DATUM = ?",
|
||||||
|
$date
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$data = DatabaseShow(
|
||||||
|
"Firmenberichte",
|
||||||
|
"DATUM, PROZESS_1, PROZESS_2, PROZESS_3, PROZESS_4, BEGINN, ENDE_PUBLIC",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
echo $api->jsonSuccess($data);
|
||||||
|
$api->requestSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* http://localhost:9000/api/v2/workReports.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3
|
||||||
|
* http://localhost:9000/api/v2/workReports.php?token=f3a50684d7f0cc2d9b21601798ea48242fab7481a0d0407a2b8683b0b74a79e3&date=2025-09-09
|
||||||
|
*/
|
||||||
@@ -7,258 +7,3 @@ $superuser = array (
|
|||||||
'active' => true,
|
'active' => true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$serviceGroups = array (
|
|
||||||
'Info' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Home',
|
|
||||||
'defaultOpen' => true,
|
|
||||||
'services' =>
|
|
||||||
array (
|
|
||||||
0 => 'home_info',
|
|
||||||
1 => 'links',
|
|
||||||
2 => 'berichte_arbeit',
|
|
||||||
3 => 'berichte_arbeit_gen',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'Logs' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Webserver',
|
|
||||||
'defaultOpen' => true,
|
|
||||||
'services' =>
|
|
||||||
array (
|
|
||||||
0 => 'public_request_logs',
|
|
||||||
1 => 'public_request_chart',
|
|
||||||
2 => 'backend_request_logs',
|
|
||||||
3 => 'backend_request_chart',
|
|
||||||
4 => 'personal_request_logs',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'System' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Verwaltung',
|
|
||||||
'defaultOpen' => true,
|
|
||||||
'services' =>
|
|
||||||
array (
|
|
||||||
0 => 'services_control',
|
|
||||||
1 => 'user_control',
|
|
||||||
2 => 'variablen_control',
|
|
||||||
3 => 'data_info',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$services = array (
|
|
||||||
'home_info' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Home',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'data_info' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Data Info',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => true,
|
|
||||||
),
|
|
||||||
'links' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Externe Links',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'public_request_logs' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Public Logs',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'public_request_chart' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Public Statistik',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'backend_request_logs' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Backend Logs',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'backend_request_chart' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Backend Statistik',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'personal_request_logs' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Persönliche Logs',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'services_control' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Seiten',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => true,
|
|
||||||
),
|
|
||||||
'berichte_arbeit' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Arbeitsberichte',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'berichte_arbeit_gen' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Arbeitsberichte PDF',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'user_control' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Benutzer',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
),
|
|
||||||
'variablen_control' =>
|
|
||||||
array (
|
|
||||||
'name' => 'Variablen',
|
|
||||||
'active' => true,
|
|
||||||
'adminOnly' => true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$linkGroups = array (
|
|
||||||
'info' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Informationen',
|
|
||||||
'color' => '#3498db',
|
|
||||||
'defaultOpen' => false,
|
|
||||||
),
|
|
||||||
'tools' =>
|
|
||||||
array (
|
|
||||||
'label' => 'IoT',
|
|
||||||
'color' => '#2ecc71',
|
|
||||||
'defaultOpen' => false,
|
|
||||||
),
|
|
||||||
'admin' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Administration',
|
|
||||||
'color' => '#e74c3c',
|
|
||||||
'defaultOpen' => false,
|
|
||||||
),
|
|
||||||
'devices' =>
|
|
||||||
array (
|
|
||||||
'label' => 'Geräte',
|
|
||||||
'color' => '#b7db33',
|
|
||||||
'defaultOpen' => false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
$linkButtons = array (
|
|
||||||
0 =>
|
|
||||||
array (
|
|
||||||
'label' => 'Gitea',
|
|
||||||
'url' => 'http://gitea.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'admin',
|
|
||||||
),
|
|
||||||
1 =>
|
|
||||||
array (
|
|
||||||
'label' => 'HAProxy',
|
|
||||||
'url' => 'http://stats.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'admin',
|
|
||||||
),
|
|
||||||
2 =>
|
|
||||||
array (
|
|
||||||
'label' => 'Public',
|
|
||||||
'url' => 'https://blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'info',
|
|
||||||
),
|
|
||||||
3 =>
|
|
||||||
array (
|
|
||||||
'label' => 'NAS-1',
|
|
||||||
'url' => 'http://nas-1.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
4 =>
|
|
||||||
array (
|
|
||||||
'label' => 'NAS-2',
|
|
||||||
'url' => 'http://nas-2.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
5 =>
|
|
||||||
array (
|
|
||||||
'label' => 'FritzBox-1',
|
|
||||||
'url' => 'http://fritzbox-1.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
6 =>
|
|
||||||
array (
|
|
||||||
'label' => 'FritzBox-2',
|
|
||||||
'url' => 'http://fritzbox-2.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
7 =>
|
|
||||||
array (
|
|
||||||
'label' => 'GS1910-24',
|
|
||||||
'url' => 'http://switch.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'admin',
|
|
||||||
),
|
|
||||||
8 =>
|
|
||||||
array (
|
|
||||||
'label' => 'NWA5121-NI Innen',
|
|
||||||
'url' => 'http://ap-1.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
9 =>
|
|
||||||
array (
|
|
||||||
'label' => 'NWA5121-NI Aussen',
|
|
||||||
'url' => 'http://ap-2.blackpi.ipv64.net',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'devices',
|
|
||||||
),
|
|
||||||
10 =>
|
|
||||||
array (
|
|
||||||
'label' => 'ZyWALL 110',
|
|
||||||
'url' => 'http://10.233.1248',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'admin',
|
|
||||||
),
|
|
||||||
11 =>
|
|
||||||
array (
|
|
||||||
'label' => 'Ender 3 V3 KE',
|
|
||||||
'url' => 'http://10.233.1.52',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'tools',
|
|
||||||
),
|
|
||||||
12 =>
|
|
||||||
array (
|
|
||||||
'label' => 'Ubuntu NAS',
|
|
||||||
'url' => 'http://10.233.1.32:9000',
|
|
||||||
'newTab' => true,
|
|
||||||
'adminOnly' => false,
|
|
||||||
'group' => 'tools',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/DatabaseController.php');
|
||||||
|
|
||||||
|
class ApiController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method for pretty jsonsuccess output
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonSuccess($data)
|
||||||
|
{
|
||||||
|
return json_encode(
|
||||||
|
[
|
||||||
|
'status' => 'success',
|
||||||
|
'data' => $data,
|
||||||
|
],
|
||||||
|
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method for pretty jsonerror output
|
||||||
|
*
|
||||||
|
* @param array $error
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonError($error)
|
||||||
|
{
|
||||||
|
echo json_encode(
|
||||||
|
[
|
||||||
|
'status' => 'failed',
|
||||||
|
'data' => 'none',
|
||||||
|
'error' => $error
|
||||||
|
],
|
||||||
|
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get authentication key out database
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getAuthKey()
|
||||||
|
{
|
||||||
|
$validTokens = DatabaseShow(
|
||||||
|
"API_Credentials",
|
||||||
|
"TOKEN"
|
||||||
|
);
|
||||||
|
|
||||||
|
return array_column($validTokens, 'TOKEN');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* url authentication method via token and optional parameter function
|
||||||
|
*
|
||||||
|
* @param string $token
|
||||||
|
* @param string $function
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function urlAuth($token, $function = '')
|
||||||
|
{
|
||||||
|
|
||||||
|
$validTokens = $this->getAuthKey();
|
||||||
|
if (!in_array($token, $validTokens)) {
|
||||||
|
http_response_code(401);
|
||||||
|
$error = json_encode([
|
||||||
|
"error" => "Unauthorized",
|
||||||
|
"debug_received_token" => $token,
|
||||||
|
]);
|
||||||
|
|
||||||
|
echo $this->jsonError($error);
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"API_LOGS",
|
||||||
|
"CLIENT_IP, TOKEN, API, FUNKTION, JSON",
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
$token,
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
$function,
|
||||||
|
$error
|
||||||
|
);
|
||||||
|
|
||||||
|
errorMail(
|
||||||
|
"API Login failed",
|
||||||
|
$error,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function requestSave($function = '')
|
||||||
|
{
|
||||||
|
DatabaseInsert(
|
||||||
|
"API_LOGS",
|
||||||
|
"CLIENT_IP, TOKEN, API, FUNKTION, JSON",
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
$_GET['token'],
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
$function,
|
||||||
|
'{"status": "success"}',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create new api token
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function createToken()
|
||||||
|
{
|
||||||
|
return bin2hex(random_bytes(32));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save created api token
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function saveToken()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DatabaseInsert(
|
||||||
|
"API_Credentials",
|
||||||
|
"TOKEN, BENUTZER",
|
||||||
|
$this->createToken(),
|
||||||
|
"API-User"
|
||||||
|
);
|
||||||
|
} catch (Exception $error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
class getSpecificData {
|
class getSpecificData {
|
||||||
|
|
||||||
public function getWeather() {
|
public function getWeather() {
|
||||||
$url = "https://api.openweathermap.org/data/2.5/weather?q=Berlin,DE&APPID=5bc3e1a438c58fca444c4370ac0517b2&units=metric";
|
$url = "https://api.openweathermap.org/data/2.5/weather?q=Jena,DE&APPID=5bc3e1a438c58fca444c4370ac0517b2&units=metric";
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
@@ -108,25 +108,23 @@ class getSpecificData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getServerIP(): string {
|
public function getServerIP(): string {
|
||||||
$ServerIP = $_SERVER['SERVER_ADDR'] ?? 'Unbekannt';
|
return $_SERVER['SERVER_ADDR'] ?? 'Unbekannt';
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($ServerIP, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) {
|
public function getClientIP(): string
|
||||||
return "Lokal";
|
{
|
||||||
} else {
|
if (PHP_SAPI === 'cli') {
|
||||||
return $ServerIP;
|
return 'CLI';
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClientIP(): string {
|
|
||||||
$xff = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null;
|
$xff = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null;
|
||||||
|
|
||||||
if ($xff) {
|
if (!empty($xff)) {
|
||||||
$ips = array_map('trim', explode(',', $xff));
|
$ips = array_map('trim', explode(',', $xff));
|
||||||
$clientIp = $ips[0];
|
return $ips[0];
|
||||||
return $clientIp;
|
|
||||||
} else {
|
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequestTime(): string {
|
public function getRequestTime(): string {
|
||||||
@@ -162,27 +160,7 @@ class getSpecificData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getServerNode($ServerIP) {
|
function getServerNode($ServerIP) {
|
||||||
$nodes = [
|
return $ServerIP;
|
||||||
'node1' => '172.30.0.11',
|
|
||||||
'node1' => '172.30.0.21',
|
|
||||||
|
|
||||||
'node2' => '172.30.0.12',
|
|
||||||
'node2' => '172.30.0.22',
|
|
||||||
|
|
||||||
'node3' => '172.30.0.13',
|
|
||||||
'node3' => '172.30.0.23',
|
|
||||||
|
|
||||||
'node4' => '172.30.0.14',
|
|
||||||
'node4' => '172.30.0.24',
|
|
||||||
'Lokal' => 'Lokal',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($nodes as $node => $ip) {
|
|
||||||
if ($ServerIP == $ip) {
|
|
||||||
return $node;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClientStatus($ClientIP) {
|
function getClientStatus($ClientIP) {
|
||||||
|
|||||||
@@ -1,34 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function db_connect() {
|
include_once __DIR__ . '/../modules/Mail.php';
|
||||||
|
include_once __DIR__ . '/../controller/RoutesController.php';
|
||||||
|
include_once 'DataController.php';
|
||||||
|
|
||||||
|
function db_connect()
|
||||||
|
{
|
||||||
$servers = [
|
$servers = [
|
||||||
'dev' => [
|
'local' => [
|
||||||
'hostaddr' => '10.233.1.29',
|
'hostaddr' => '127.0.0.1',
|
||||||
'username' => 'worker',
|
|
||||||
'password' => 'bBHofurUJWKzPE8Z',
|
|
||||||
'database' => 'DEV',
|
|
||||||
],
|
|
||||||
'vpn' => [
|
|
||||||
'hostaddr' => '100.123.136.86',
|
|
||||||
'username' => 'worker',
|
'username' => 'worker',
|
||||||
'password' => 'bBHofurUJWKzPE8Z',
|
'password' => 'bBHofurUJWKzPE8Z',
|
||||||
'database' => 'DEV',
|
'database' => 'DEV',
|
||||||
],
|
],
|
||||||
'live' => [
|
'live' => [
|
||||||
'hostaddr' => '10.233.1.244',
|
'hostaddr' => '152.53.159.169',
|
||||||
|
'username' => 'worker',
|
||||||
|
'password' => 'bBHofurUJWKzPE8Z',
|
||||||
|
'database' => 'LIVE',
|
||||||
|
],
|
||||||
|
'dev' => [
|
||||||
|
'hostaddr' => '152.53.159.169',
|
||||||
'username' => 'worker',
|
'username' => 'worker',
|
||||||
'password' => 'bBHofurUJWKzPE8Z',
|
'password' => 'bBHofurUJWKzPE8Z',
|
||||||
'database' => 'DEV',
|
'database' => 'DEV',
|
||||||
],
|
],
|
||||||
'backup' => [
|
|
||||||
'hostaddr' => '10.233.1.243',
|
|
||||||
'username' => 'worker',
|
|
||||||
'password' => 'bBHofurUJWKzPE8Z',
|
|
||||||
'database' => 'DEV',
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$enviroment = 'live';
|
$enviroment = 'dev';
|
||||||
|
|
||||||
|
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
$conn = new mysqli(
|
$conn = new mysqli(
|
||||||
$servers[$enviroment]['hostaddr'],
|
$servers[$enviroment]['hostaddr'],
|
||||||
@@ -37,12 +40,16 @@ function db_connect() {
|
|||||||
$servers[$enviroment]['database'],
|
$servers[$enviroment]['database'],
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($conn->connect_error) {
|
|
||||||
throw new Exception('Connection Error: ' . $conn->connect_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->set_charset("utf8mb4");
|
$conn->set_charset("utf8mb4");
|
||||||
return $conn;
|
return $conn;
|
||||||
}
|
} catch (mysqli_sql_exception $e) {
|
||||||
|
|
||||||
?>
|
errorMail(
|
||||||
|
"Database Connection failed",
|
||||||
|
$e->getMessage(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
redirectToWebsite("https://mrhossa.de");
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,72 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
function DatabaseCreateTable($table, $columnsDefinition) {
|
||||||
|
include_once 'DatabaseConnect.php';
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$sql = "CREATE TABLE IF NOT EXISTS `$table` ($columnsDefinition)";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
|
||||||
|
if (!$stmt) {
|
||||||
|
die("Fehler beim Prepare: " . $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
die("Fehler beim Execute: " . $stmt->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseShowTables() {
|
||||||
|
include_once 'DatabaseConnect.php';
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$tablesResult = $conn->query("SHOW TABLES");
|
||||||
|
if (!$tablesResult) {
|
||||||
|
die("Fehler beim Laden der Tabellen: " . $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tables = [];
|
||||||
|
|
||||||
|
while ($tableRow = $tablesResult->fetch_array()) {
|
||||||
|
$tables[] = $tableRow[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tables;
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseShowTableStructure($table) {
|
||||||
|
include_once 'DatabaseConnect.php';
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SHOW COLUMNS FROM `$table`");
|
||||||
|
if (!$stmt) {
|
||||||
|
die("Fehler beim Prepare: " . $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
die("Fehler beim Execute: " . $stmt->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
$columns = [];
|
||||||
|
|
||||||
|
while ($column = $result->fetch_assoc()) {
|
||||||
|
$columns[] = [
|
||||||
|
"Field" => $column["Field"],
|
||||||
|
"Type" => $column["Type"],
|
||||||
|
"Null" => $column["Null"],
|
||||||
|
"Key" => $column["Key"],
|
||||||
|
"Default" => $column["Default"],
|
||||||
|
"Extra" => $column["Extra"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $columns;
|
||||||
|
}
|
||||||
|
|
||||||
function DatabaseShow($table, $columns = "*", $where = "", ...$values) {
|
function DatabaseShow($table, $columns = "*", $where = "", ...$values) {
|
||||||
include_once 'DatabaseConnect.php';
|
include_once 'DatabaseConnect.php';
|
||||||
$conn = db_connect();
|
$conn = db_connect();
|
||||||
@@ -80,10 +147,37 @@ function DatabaseUpdate($table, $set, $where, ...$values) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFKValue($conn, $table, $key, $value, $id, &$cache) {
|
||||||
|
if ($id === null) return null;
|
||||||
|
|
||||||
|
$cacheKey = $table . "_" . $id;
|
||||||
|
|
||||||
|
if (isset($cache[$cacheKey])) {
|
||||||
|
return $cache[$cacheKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT `$value` FROM `$table` WHERE `$key` = ? LIMIT 1");
|
||||||
|
if (!$stmt) {
|
||||||
|
die("FK Prepare Fehler: " . $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param("i", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$result = $stmt->get_result()->fetch_assoc();
|
||||||
|
$valueResult = $result[$value] ?? null;
|
||||||
|
|
||||||
|
$cache[$cacheKey] = $valueResult;
|
||||||
|
|
||||||
|
return $valueResult;
|
||||||
|
}
|
||||||
|
|
||||||
function DatabaseShowWithFK($table, $fkMap = [], $columns = "*", $where = "", ...$values) {
|
function DatabaseShowWithFK($table, $fkMap = [], $columns = "*", $where = "", ...$values) {
|
||||||
include_once 'DatabaseConnect.php';
|
include_once 'DatabaseConnect.php';
|
||||||
$conn = db_connect();
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$cache = [];
|
||||||
|
|
||||||
$select = is_array($columns) ? implode(", ", $columns) : $columns;
|
$select = is_array($columns) ? implode(", ", $columns) : $columns;
|
||||||
|
|
||||||
$sql = "SELECT $select FROM `$table`";
|
$sql = "SELECT $select FROM `$table`";
|
||||||
@@ -94,33 +188,32 @@ function DatabaseShowWithFK($table, $fkMap = [], $columns = "*", $where = "", ..
|
|||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
if (!$stmt) die("Fehler beim Prepare: " . $conn->error);
|
if (!$stmt) die("Fehler beim Prepare: " . $conn->error);
|
||||||
|
|
||||||
if (!$stmt->execute($values)) die("Fehler beim Execute: " . $stmt->error);
|
if (!empty($values)) {
|
||||||
|
$stmt->execute($values);
|
||||||
|
} else {
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
if (!$result) die("Fehler beim get_result: " . $stmt->error);
|
if (!$result) die("Fehler beim get_result: " . $conn->error);
|
||||||
|
|
||||||
$columnsResult = [];
|
|
||||||
while ($fieldinfo = $result->fetch_field()) {
|
|
||||||
$columnsResult[] = $fieldinfo->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
$rows = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
|
||||||
foreach ($rows as &$row) {
|
foreach ($rows as &$row) {
|
||||||
foreach ($fkMap as $fkColumn => $fkInfo) {
|
foreach ($fkMap as $fkColumn => $fkInfo) {
|
||||||
if (isset($row[$fkColumn]) && $row[$fkColumn] !== null) {
|
|
||||||
$fkStmt = $conn->prepare(
|
|
||||||
"SELECT {$fkInfo['value']} FROM `{$fkInfo['table']}` WHERE {$fkInfo['key']} = ?"
|
|
||||||
);
|
|
||||||
if (!$fkStmt) die("Fehler beim Prepare FK: " . $conn->error);
|
|
||||||
|
|
||||||
$fkStmt->bind_param("i", $row[$fkColumn]);
|
if (!isset($row[$fkColumn]) || $row[$fkColumn] === null) {
|
||||||
$fkStmt->execute();
|
continue;
|
||||||
$fkResult = $fkStmt->get_result();
|
|
||||||
$fkRow = $fkResult->fetch_assoc();
|
|
||||||
|
|
||||||
$row[$fkColumn] = $fkRow ? $fkRow[$fkInfo['value']] : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$row[$fkColumn] = getFKValue(
|
||||||
|
$conn,
|
||||||
|
$fkInfo['table'],
|
||||||
|
$fkInfo['key'],
|
||||||
|
$fkInfo['value'],
|
||||||
|
$row[$fkColumn],
|
||||||
|
$cache
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +222,29 @@ function DatabaseShowWithFK($table, $fkMap = [], $columns = "*", $where = "", ..
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DatabaseShowAllSchemas() {
|
||||||
|
include_once 'DatabaseConnect.php';
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$result = $conn->query("
|
||||||
|
SELECT TABLE_NAME, COLUMN_NAME
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
ORDER BY TABLE_NAME, ORDINAL_POSITION
|
||||||
|
");
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
die("Fehler beim Laden des Schemas: " . $conn->error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$schema = [];
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$schema[$row['TABLE_NAME']][] = $row['COLUMN_NAME'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $schema;
|
||||||
|
}
|
||||||
|
|
||||||
$Berufsschulberichte = [
|
$Berufsschulberichte = [
|
||||||
"FACH_S1" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
|
"FACH_S1" => ["table" => "Fach", "key" => "ID", "value" => "Fach"],
|
||||||
"LEHRER_S1" => ["table" => "Lehrer", "key" => "ID", "value" => "NAME"],
|
"LEHRER_S1" => ["table" => "Lehrer", "key" => "ID", "value" => "NAME"],
|
||||||
@@ -172,6 +288,6 @@ $Stundenplan = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
$Berechtigungen = [
|
$Berechtigungen = [
|
||||||
"BENUTZER_ID" => ["table" => "Benutzer", "key" => "ID", "value" => "ID"],
|
"BENUTZER_ID" => ["table" => "Benutzer", "key" => "ID", "value" => "NAME"],
|
||||||
"BERECHTIGUNGEN_ID" => ["table" => "Berechtigungen", "key" => "ID", "value" => "ID"]
|
"SEITEN_ID" => ["table" => "Backend_Seiten", "key" => "ID", "value" => "DATEINAME"]
|
||||||
];
|
];
|
||||||
@@ -3,10 +3,15 @@
|
|||||||
|
|
||||||
function logging() {
|
function logging() {
|
||||||
include_once 'DataController.php';
|
include_once 'DataController.php';
|
||||||
if ((new getSpecificData())->getLoggingStatus("GENERAL_BACKEND_LOGGING")[0]['WERT'] == 'ON') {
|
|
||||||
include_once 'DatabaseConnect.php';
|
include_once 'DatabaseConnect.php';
|
||||||
include_once 'DatabaseController.php';
|
include_once 'DatabaseController.php';
|
||||||
include_once 'DataController.php';
|
include_once __DIR__ . '/../modules/Mail.php';
|
||||||
|
|
||||||
|
if ((new getSpecificData())->getLoggingStatus("GENERAL_BACKEND_LOGGING")[0]['WERT'] == 'ON') {
|
||||||
|
|
||||||
|
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
$ClientIP = (new getSpecificData())->getClientIP();
|
$ClientIP = (new getSpecificData())->getClientIP();
|
||||||
$UserAgent = (new getSpecificData())->getUserAgent();
|
$UserAgent = (new getSpecificData())->getUserAgent();
|
||||||
@@ -84,7 +89,14 @@ function logging() {
|
|||||||
$username
|
$username
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// ConsoleLog("Client IP: $ClientIP | User Agent: $UserAgent | Request URL: $RequestURL | User Cookie: $USERCOOKIE | Session ID: $SessionID | Request Time: $REQUESTTIME | GeoIP: $LAND | Server Node: $node | Website: $website");
|
}
|
||||||
|
} catch (mysqli_sql_exception $e) {
|
||||||
|
errorMail(
|
||||||
|
"Logging failed",
|
||||||
|
$e->getMessage(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/DatabaseController.php');
|
||||||
|
|
||||||
|
class RightsController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save new site with sitename
|
||||||
|
*
|
||||||
|
* @param string $sitename
|
||||||
|
*/
|
||||||
|
private function saveSite($sitename) {
|
||||||
|
DatabaseInsert(
|
||||||
|
"Backend_Seiten",
|
||||||
|
"DATEINAME",
|
||||||
|
$sitename
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get site id by sitename
|
||||||
|
*
|
||||||
|
* @param string $sitename
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getSiteID($sitename) {
|
||||||
|
$id = DatabaseShow(
|
||||||
|
"Backend_Seiten",
|
||||||
|
"ID",
|
||||||
|
"DATEINAME = ?",
|
||||||
|
$sitename
|
||||||
|
);
|
||||||
|
return $id[0]['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get user id
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $lastname
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getUserID($name, $lastname) {
|
||||||
|
$id = DatabaseShow(
|
||||||
|
"Benutzer",
|
||||||
|
"ID",
|
||||||
|
"NAME = ? AND NACHNAME = ?",
|
||||||
|
$name,
|
||||||
|
$lastname
|
||||||
|
);
|
||||||
|
return $id[0]['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rights Handler for saving default user is Bruno
|
||||||
|
*
|
||||||
|
* @param string $sitename
|
||||||
|
* @param string $name
|
||||||
|
* @param string $lastname
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function RightsHandler($sitename, $name = 'Bruno', $lastname = 'Eckhardt') {
|
||||||
|
try {
|
||||||
|
$sitename = strtolower($sitename);
|
||||||
|
$this->saveSite($sitename);
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Benutzer_Berechtigungen",
|
||||||
|
"BENUTZER_ID, SEITEN_ID",
|
||||||
|
$this->getUserID($name, $lastname),
|
||||||
|
$this->getSiteID($sitename)
|
||||||
|
);
|
||||||
|
} catch (Exception $error) {
|
||||||
|
return json_encode(
|
||||||
|
[
|
||||||
|
"status" => "failed",
|
||||||
|
"error" => $error->getMessage()
|
||||||
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return json_encode(
|
||||||
|
[
|
||||||
|
"status" => "success",
|
||||||
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,20 @@ class UserController {
|
|||||||
$admin,
|
$admin,
|
||||||
$home_ip,
|
$home_ip,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$userID = DatabaseShow(
|
||||||
|
"Benutzer",
|
||||||
|
"ID",
|
||||||
|
"NAME = ?",
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Benutzer_Berechtigungen",
|
||||||
|
"BENUTZER_ID, SEITEN_ID",
|
||||||
|
$userID[0]['ID'],
|
||||||
|
"8"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DeleteUser($name, $nachname, $email) {
|
public function DeleteUser($name, $nachname, $email) {
|
||||||
|
|||||||
+89
-44
@@ -1,35 +1,88 @@
|
|||||||
<?php
|
<?php
|
||||||
ob_start();
|
ob_start();
|
||||||
// Vor allen includes, vor jeglicher Ausgabe
|
|
||||||
session_set_cookie_params([
|
session_set_cookie_params([
|
||||||
'lifetime' => 0, // bis Browser geschlossen
|
'lifetime' => 0,
|
||||||
'path' => '/', // Gültig für ganze Domain
|
'path' => '/',
|
||||||
'domain' => '', // aktuelle Domain
|
'domain' => '',
|
||||||
'secure' => false, // true nur für HTTPS
|
'secure' => false,
|
||||||
'httponly' => true,
|
'httponly' => true,
|
||||||
'samesite' => 'Lax'
|
'samesite' => 'Lax'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (empty($_SESSION['user_logged_in'])) {
|
if (empty($_SESSION['user_logged_in'])) {
|
||||||
header('Location: login.php');
|
header('Location: login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
include 'config.php';
|
include_once 'config.php'; // enthält jetzt nur noch $superuser
|
||||||
include 'controller/CookieController.php';
|
include_once 'controller/CookieController.php';
|
||||||
include 'controller/DatabaseConnect.php';
|
include_once 'controller/DatabaseConnect.php';
|
||||||
include 'controller/DatabaseController.php';
|
include_once 'controller/DatabaseController.php';
|
||||||
include 'controller/DataController.php';
|
include_once 'controller/DataController.php';
|
||||||
include 'controller/LogController.php';
|
include_once 'controller/LogController.php';
|
||||||
include 'controller/UserController.php';
|
include_once 'controller/UserController.php';
|
||||||
include 'modules/ConsoleLog.php';
|
include_once 'modules/ConsoleLog.php';
|
||||||
// include 'controller/RoutesController.php';
|
|
||||||
|
|
||||||
|
$user_id = DatabaseShow(
|
||||||
|
"Benutzer",
|
||||||
|
"ID",
|
||||||
|
"NAME = ?",
|
||||||
|
$_SESSION['username'],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Berechtigte Seiten-IDs des Nutzers (bleibt unverändert)
|
||||||
|
$rightsArray = DatabaseShowWithFK(
|
||||||
|
"Benutzer_Berechtigungen",
|
||||||
|
$Berechtigungen,
|
||||||
|
"SEITEN_ID",
|
||||||
|
"BENUTZER_ID = ?",
|
||||||
|
$user_id[0]['ID'],
|
||||||
|
);
|
||||||
|
$userRights = array_map('trim', array_column($rightsArray['rows'], 'SEITEN_ID'));
|
||||||
|
|
||||||
|
$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true;
|
||||||
|
// --- Seiten & Gruppen aus der DB laden ---
|
||||||
|
$seitenGruppenRows = DatabaseShow(
|
||||||
|
"Backend_Seiten_Gruppen",
|
||||||
|
"ID, LABEL, DEFAULT_OPEN, SORTIERUNG"
|
||||||
|
);
|
||||||
|
usort($seitenGruppenRows, fn($a, $b) => ($a['SORTIERUNG'] ?? 0) <=> ($b['SORTIERUNG'] ?? 0));
|
||||||
|
|
||||||
|
$seitenRows = DatabaseShow(
|
||||||
|
"Backend_Seiten",
|
||||||
|
"ID, DATEINAME, NAME, AKTIV, ADMIN_ONLY, GRUPPE_ID, SORTIERUNG"
|
||||||
|
);
|
||||||
|
usort($seitenRows, fn($a, $b) => ($a['SORTIERUNG'] ?? 0) <=> ($b['SORTIERUNG'] ?? 0));
|
||||||
|
|
||||||
|
$services = [];
|
||||||
|
foreach ($seitenRows as $row) {
|
||||||
|
$services[$row['DATEINAME']] = [
|
||||||
|
'id' => $row['ID'],
|
||||||
|
'name' => $row['NAME'],
|
||||||
|
'active' => (bool)$row['AKTIV'],
|
||||||
|
'adminOnly' => (bool)$row['ADMIN_ONLY'],
|
||||||
|
'gruppeId' => $row['GRUPPE_ID'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceGroups = [];
|
||||||
|
foreach ($seitenGruppenRows as $gruppe) {
|
||||||
|
$servicesInGruppe = array_keys(array_filter(
|
||||||
|
$services,
|
||||||
|
fn($s) => $s['gruppeId'] == $gruppe['ID']
|
||||||
|
));
|
||||||
|
$serviceGroups[$gruppe['LABEL']] = [
|
||||||
|
'label' => $gruppe['LABEL'],
|
||||||
|
'defaultOpen' => (bool)$gruppe['DEFAULT_OPEN'],
|
||||||
|
'services' => $servicesInGruppe,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Selected Service Logik bleibt unverändert ---
|
||||||
$selectedService = null;
|
$selectedService = null;
|
||||||
|
|
||||||
// 1. Service aus URL, wenn erlaubt & aktiv
|
|
||||||
if (
|
if (
|
||||||
isset($_GET['service']) &&
|
isset($_GET['service']) &&
|
||||||
isset($services[$_GET['service']]) &&
|
isset($services[$_GET['service']]) &&
|
||||||
@@ -38,27 +91,23 @@ if (
|
|||||||
$selectedService = $_GET['service'];
|
$selectedService = $_GET['service'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Default-Service
|
$ausgeschlosseneServices = ['logout']; // technische Endpunkte, keine echten Seiten
|
||||||
if (!$selectedService &&
|
|
||||||
isset($defaultService) &&
|
|
||||||
isset($services[$defaultService]) &&
|
|
||||||
$services[$defaultService]['active']
|
|
||||||
) {
|
|
||||||
$selectedService = $defaultService;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Fallback: erster aktiver Service
|
|
||||||
if (!$selectedService) {
|
if (!$selectedService) {
|
||||||
foreach ($services as $key => $service) {
|
foreach ($services as $key => $service) {
|
||||||
|
if (in_array($key, $ausgeschlosseneServices, true)) continue;
|
||||||
if ($service['active']) {
|
if ($service['active']) {
|
||||||
$selectedService = $key;
|
$selectedService = $key;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true;
|
|
||||||
|
|
||||||
if ((new getSpecificData())->getWebsite() != "backend.blackpi.ipv64.net") {
|
if ($selectedService && !in_array($selectedService, $userRights, true)) {
|
||||||
|
$selectedService = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((new getSpecificData())->getWebsite() != "backend.mrhossa.de") {
|
||||||
$title = "DEV Backend";
|
$title = "DEV Backend";
|
||||||
} else {
|
} else {
|
||||||
$title = "Backend";
|
$title = "Backend";
|
||||||
@@ -76,7 +125,7 @@ if ((new getSpecificData())->getWebsite() != "backend.blackpi.ipv64.net") {
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header class="main-header">
|
||||||
Backend
|
Backend
|
||||||
<button id="darkModeToggle">Dark Mode</button>
|
<button id="darkModeToggle">Dark Mode</button>
|
||||||
<button id="logoutButton">Logout</button>
|
<button id="logoutButton">Logout</button>
|
||||||
@@ -85,33 +134,29 @@ if ((new getSpecificData())->getWebsite() != "backend.blackpi.ipv64.net") {
|
|||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<?php foreach ($serviceGroups as $groupKey => $group): ?>
|
<?php foreach ($serviceGroups as $groupKey => $group): ?>
|
||||||
<?php
|
<?php
|
||||||
$isOpen = false;
|
$visibleServices = [];
|
||||||
|
|
||||||
if (!empty($group['defaultOpen'])) {
|
foreach ($group['services'] as $serviceKey) {
|
||||||
$isOpen = true;
|
if (!isset($services[$serviceKey])) continue;
|
||||||
|
if (!$services[$serviceKey]['active']) continue;
|
||||||
|
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) continue;
|
||||||
|
if (!in_array($serviceKey, $userRights, true)) continue;
|
||||||
|
$visibleServices[] = $serviceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($selectedService, $group['services'], true)) {
|
if (empty($visibleServices)) continue;
|
||||||
$isOpen = true;
|
|
||||||
}
|
$isOpen = !empty($group['defaultOpen']) || in_array($selectedService, $visibleServices, true);
|
||||||
?>
|
?>
|
||||||
|
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= htmlspecialchars($groupKey) ?>">
|
||||||
|
|
||||||
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= $groupKey ?>">
|
|
||||||
<div class="group-title">
|
<div class="group-title">
|
||||||
<?= htmlspecialchars($group['label']) ?>
|
<?= htmlspecialchars($group['label']) ?>
|
||||||
<span class="arrow">▸</span>
|
<span class="arrow">▸</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group-services">
|
<div class="group-services">
|
||||||
<?php foreach ($group['services'] as $serviceKey): ?>
|
<?php foreach ($visibleServices as $serviceKey): ?>
|
||||||
<?php
|
|
||||||
if (!isset($services[$serviceKey])) continue;
|
|
||||||
if (!$services[$serviceKey]['active']) continue;
|
|
||||||
|
|
||||||
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<a href="?service=<?= $serviceKey ?>">
|
<a href="?service=<?= $serviceKey ?>">
|
||||||
<button class="<?= $selectedService === $serviceKey ? 'active' : '' ?>">
|
<button class="<?= $selectedService === $serviceKey ? 'active' : '' ?>">
|
||||||
<?= htmlspecialchars($services[$serviceKey]['name']) ?>
|
<?= htmlspecialchars($services[$serviceKey]['name']) ?>
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
const AJAX_HANDLER_URL = '/api/js/AjaxHandler';
|
||||||
|
|
||||||
|
function escapeHtml(str) {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = str ?? '';
|
||||||
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function parseJsonResponse(response) {
|
||||||
|
const rawText = await response.text();
|
||||||
|
try {
|
||||||
|
return JSON.parse(rawText);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Antwort war kein gültiges JSON:', rawText);
|
||||||
|
throw new Error('Server hat kein gültiges JSON zurückgegeben (siehe Konsole)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ajaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(AJAX_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseInsert(table, columns, values) {
|
||||||
|
return ajaxRequest({
|
||||||
|
action: 'insert',
|
||||||
|
table,
|
||||||
|
columns,
|
||||||
|
values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseShow(table, columns = [], conditions = []) {
|
||||||
|
return ajaxRequest({
|
||||||
|
action: 'show',
|
||||||
|
table,
|
||||||
|
columns,
|
||||||
|
conditions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseUpdate(table, updates, conditions) {
|
||||||
|
return ajaxRequest({
|
||||||
|
action: 'update',
|
||||||
|
table,
|
||||||
|
updates,
|
||||||
|
conditions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function DatabaseDelete(table, conditions) {
|
||||||
|
return ajaxRequest({
|
||||||
|
action: 'delete',
|
||||||
|
table,
|
||||||
|
conditions
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
|
||||||
|
function renderTable(wrapperEl, entries, spaltenKonfig, idSpalte, onDelete) {
|
||||||
|
|
||||||
|
if (entries && !Array.isArray(entries)) {
|
||||||
|
console.warn('entries war kein Array:', entries);
|
||||||
|
entries = Object.values(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
wrapperEl.innerHTML = '<p>Keine Einträge vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${spaltenKonfig.map(s => `<th>${escapeHtml(s.label)}</th>`).join('')}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
html += `<tr>`;
|
||||||
|
for (const s of spaltenKonfig) {
|
||||||
|
html += `<td data-label="${escapeHtml(s.label)}">${escapeHtml(entry[s.key])}</td>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</tbody>
|
||||||
|
</table>`;
|
||||||
|
wrapperEl.innerHTML = html;
|
||||||
|
|
||||||
|
wrapperEl.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Eintrag wirklich löschen?')) return;
|
||||||
|
await onDelete(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTableWithDelete(wrapperEl, entries, spaltenKonfig, idSpalte, onDelete) {
|
||||||
|
|
||||||
|
if (entries && !Array.isArray(entries)) {
|
||||||
|
console.warn('entries war kein Array:', entries);
|
||||||
|
entries = Object.values(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
wrapperEl.innerHTML = '<p>Keine Einträge vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${spaltenKonfig.map(s => `<th>${escapeHtml(s.label)}</th>`).join('')}
|
||||||
|
<th style="width: 100px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
html += `<tr>`;
|
||||||
|
for (const s of spaltenKonfig) {
|
||||||
|
html += `<td data-label="${escapeHtml(s.label)}">${escapeHtml(entry[s.key])}</td>`;
|
||||||
|
}
|
||||||
|
html += `
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<button type="button" class="btn-delete" data-id="${escapeHtml(entry[idSpalte])}">
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</tbody>
|
||||||
|
</table>`;
|
||||||
|
wrapperEl.innerHTML = html;
|
||||||
|
|
||||||
|
wrapperEl.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Eintrag wirklich löschen?')) return;
|
||||||
|
await onDelete(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// [Erweiterung für /js/AjaxMethods.js]
|
||||||
|
function renderTableWithEdit(wrapperEl, entries, spaltenKonfig, idSpalte, onEdit, onDelete) {
|
||||||
|
|
||||||
|
if (entries && !Array.isArray(entries)) {
|
||||||
|
console.warn('entries war kein Array:', entries);
|
||||||
|
entries = Object.values(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
wrapperEl.innerHTML = '<p>Keine Einträge vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${spaltenKonfig.map(s => `<th>${escapeHtml(s.label)}</th>`).join('')}
|
||||||
|
<th style="width: 180px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
html += `<tr>`;
|
||||||
|
for (const s of spaltenKonfig) {
|
||||||
|
html += `<td data-label="${escapeHtml(s.label)}">${escapeHtml(entry[s.key])}</td>`;
|
||||||
|
}
|
||||||
|
html += `
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<button type="button" class="btn-edit" data-id="${escapeHtml(entry[idSpalte])}" style="margin-right: 5px; padding: 6px 12px;">
|
||||||
|
Bearbeiten
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</tbody>
|
||||||
|
</table>`;
|
||||||
|
wrapperEl.innerHTML = html;
|
||||||
|
|
||||||
|
// Event-Listener für Edit
|
||||||
|
wrapperEl.querySelectorAll('.btn-edit').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
await onEdit(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event-Listener für Löschen
|
||||||
|
wrapperEl.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Eintrag wirklich löschen?')) return;
|
||||||
|
await onDelete(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTableWithEditAndDelete(wrapperEl, entries, spaltenKonfig, idSpalte, onEdit, onDelete) {
|
||||||
|
|
||||||
|
if (entries && !Array.isArray(entries)) {
|
||||||
|
console.warn('entries war kein Array:', entries);
|
||||||
|
entries = Object.values(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
wrapperEl.innerHTML = '<p>Keine Einträge vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${spaltenKonfig.map(s => `<th>${escapeHtml(s.label)}</th>`).join('')}
|
||||||
|
<th style="width: 180px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (const entry of entries) {
|
||||||
|
html += `<tr>`;
|
||||||
|
for (const s of spaltenKonfig) {
|
||||||
|
html += `<td data-label="${escapeHtml(s.label)}">${escapeHtml(entry[s.key])}</td>`;
|
||||||
|
}
|
||||||
|
html += `
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<button type="button" class="btn-edit" data-id="${escapeHtml(entry[idSpalte])}" style="margin-right: 5px; padding: 6px 12px;">
|
||||||
|
Bearbeiten
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn-delete" data-id="${escapeHtml(entry[idSpalte])}" style="margin-right: 5px; padding: 6px 12px;">
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</tbody>
|
||||||
|
</table>`;
|
||||||
|
wrapperEl.innerHTML = html;
|
||||||
|
|
||||||
|
// Event-Listener für Edit
|
||||||
|
wrapperEl.querySelectorAll('.btn-edit').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
await onEdit(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event-Listener für Löschen
|
||||||
|
wrapperEl.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Eintrag wirklich löschen?')) return;
|
||||||
|
await onDelete(btn.dataset.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
const TERMINE_HANDLER_URL = '/api/js/handler/TermineAjaxHandler';
|
||||||
|
|
||||||
|
async function termineAjaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(TERMINE_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Termine-Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTermine() {
|
||||||
|
return termineAjaxRequest({ action: 'get_entries' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTermin(datum, zeit, name, notiz, wiederholung, enddatum) {
|
||||||
|
return termineAjaxRequest({ action: 'add_termin', datum, zeit, name, notiz, wiederholung, enddatum });
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTermin(id) {
|
||||||
|
return termineAjaxRequest({ action: 'delete_termin', id });
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTerminSerie(serienId) {
|
||||||
|
return termineAjaxRequest({ action: 'delete_serie', serienId });
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
const TICKETS_HANDLER_URL = '/api/js/handler/TicketBoardAjaxHandler';
|
||||||
|
|
||||||
|
async function ticketsAjaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(TICKETS_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Tickets-Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTicketEntries() {
|
||||||
|
return ticketsAjaxRequest({ action: 'get_entries' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function addTicketEntry(titel, beschreibung) {
|
||||||
|
return ticketsAjaxRequest({ action: 'add_entry', titel, beschreibung });
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTicketEntry(id) {
|
||||||
|
return ticketsAjaxRequest({ action: 'delete_entry', id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
const TICKET_CONTRO_HANDLER_URL = '/api/js/handler/TicketControlAjaxHandler';
|
||||||
|
|
||||||
|
async function ticketControAjaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(TICKET_CONTRO_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('TicketContro-Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTicketControEntries() {
|
||||||
|
return ticketControAjaxRequest({ action: 'get_entries' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function editTicketControEntry(id, status) {
|
||||||
|
return ticketControAjaxRequest({ action: 'edit_entry', id, status });
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTicketControEntry(id) {
|
||||||
|
return ticketControAjaxRequest({ action: 'delete_entry', id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
const VERGABE_HANDLER_URL = '/api/js/handler/VergabeAjaxHandler';
|
||||||
|
|
||||||
|
async function vergabeAjaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(VERGABE_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Vergabe-Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVergabeEntries(searchWer = '', searchWas = '') {
|
||||||
|
return vergabeAjaxRequest({ action: 'get_entries', searchWer, searchWas });
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVergabeSuggestions() {
|
||||||
|
return vergabeAjaxRequest({ action: 'get_suggestions' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function addVergabeEntry(was, wer, wann, rueckgabe) {
|
||||||
|
return vergabeAjaxRequest({ action: 'add_entry', was, wer, wann, rueckgabe });
|
||||||
|
}
|
||||||
|
|
||||||
|
function returnVergabeEntry(id) {
|
||||||
|
return vergabeAjaxRequest({ action: 'return_entry', id });
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
const OVERTIME_HANDLER_URL = '/api/js/handler/ZeiterfassungAjaxHandler';
|
||||||
|
|
||||||
|
async function overtimeAjaxRequest(payload) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(OVERTIME_HANDLER_URL, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await parseJsonResponse(response);
|
||||||
|
|
||||||
|
if (data.error) {
|
||||||
|
throw new Error(data.error);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Overtime-Ajax-Fehler:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOvertimeStats() {
|
||||||
|
return overtimeAjaxRequest({ action: 'get_stats' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function addOvertimeEntry(datum, minuten, grund) {
|
||||||
|
return overtimeAjaxRequest({ action: 'add_overtime', datum, minuten, grund });
|
||||||
|
}
|
||||||
+70
-11
@@ -2,8 +2,11 @@
|
|||||||
include_once 'controller/DatabaseController.php';
|
include_once 'controller/DatabaseController.php';
|
||||||
include_once 'controller/RoutesController.php';
|
include_once 'controller/RoutesController.php';
|
||||||
include_once 'controller/LogController.php';
|
include_once 'controller/LogController.php';
|
||||||
|
include_once 'modules/Mail.php';
|
||||||
include_once 'config.php';
|
include_once 'config.php';
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
session_set_cookie_params([
|
session_set_cookie_params([
|
||||||
'lifetime' => 0,
|
'lifetime' => 0,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
@@ -18,10 +21,48 @@ logging();
|
|||||||
|
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
|
function schreibeSessionUndPruefe(): void
|
||||||
|
{
|
||||||
|
$sid = session_id();
|
||||||
|
$writeOk = session_write_close();
|
||||||
|
$sessionFile = session_save_path() . '/sess_' . $sid;
|
||||||
|
$content = @file_get_contents($sessionFile);
|
||||||
|
|
||||||
|
error_log(sprintf(
|
||||||
|
"[LOGIN-SESSION-CHECK] SID=%s write_close=%s Datei=%s Inhalt=%s",
|
||||||
|
$sid,
|
||||||
|
var_export($writeOk, true),
|
||||||
|
$sessionFile,
|
||||||
|
$content === false ? '(Datei nicht lesbar/vorhanden)' : var_export($content, true)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$username = $_POST['username'] ?? '';
|
$username = $_POST['username'] ?? '';
|
||||||
$password = $_POST['password'] ?? '';
|
$password = $_POST['password'] ?? '';
|
||||||
|
|
||||||
|
// Gast-Login direkt prüfen
|
||||||
|
if ($username === 'gast') {
|
||||||
|
$_SESSION['user_logged_in'] = true;
|
||||||
|
$_SESSION['username'] = 'gast';
|
||||||
|
$_SESSION['is_admin'] = false;
|
||||||
|
$_SESSION['is_superuser'] = false;
|
||||||
|
|
||||||
|
schreibeSessionUndPruefe();
|
||||||
|
|
||||||
|
logging();
|
||||||
|
sendMail(
|
||||||
|
"Gast Login Successful",
|
||||||
|
"Benutzer: gast",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
redirectToWebsite("index.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regulärer Benutzer-Login
|
||||||
$results = DatabaseShow(
|
$results = DatabaseShow(
|
||||||
'Benutzer',
|
'Benutzer',
|
||||||
'PASSWORD',
|
'PASSWORD',
|
||||||
@@ -54,18 +95,38 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$_SESSION['is_admin'] = false;
|
$_SESSION['is_admin'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// header("Location: index.php");
|
schreibeSessionUndPruefe();
|
||||||
|
|
||||||
logging();
|
logging();
|
||||||
|
sendMail(
|
||||||
|
"User Login Successful",
|
||||||
|
"$username, $password",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
redirectToWebsite("index.php");
|
redirectToWebsite("index.php");
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$error = 'Login fehlgeschlagen: Passwort inkorrekt';
|
$error = 'Login fehlgeschlagen';
|
||||||
|
sendMail(
|
||||||
|
"User Login failed",
|
||||||
|
"$username, $password",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = 'Systemfehler: Spalte "password" nicht in der Datenbank gefunden.';
|
$error = 'Systemfehler: Spalte "password" nicht in der Datenbank gefunden.';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = 'Login fehlgeschlagen: Benutzer nicht gefunden';
|
$error = 'Login fehlgeschlagen';
|
||||||
|
sendMail(
|
||||||
|
"User Login failed",
|
||||||
|
"$username, $password",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -81,8 +142,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<button id="darkModeToggle">🌙 Dark Mode</button>
|
<button id="darkModeToggle">🌙 Dark Mode</button>
|
||||||
|
|
||||||
@@ -100,15 +159,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
<button style="margin-top: 9px" type="button"
|
||||||
</div>
|
onclick="document.querySelector('input[name=username]').value='gast'; document.querySelector('form').submit();">
|
||||||
|
Als Gast einloggen
|
||||||
|
</button>
|
||||||
|
|
||||||
</body>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const toggle = document.getElementById('darkModeToggle');
|
const toggle = document.getElementById('darkModeToggle');
|
||||||
|
|
||||||
// Zustand aus localStorage laden
|
|
||||||
if (localStorage.getItem('darkMode') === 'enabled') {
|
if (localStorage.getItem('darkMode') === 'enabled') {
|
||||||
document.body.classList.add('dark-mode');
|
document.body.classList.add('dark-mode');
|
||||||
}
|
}
|
||||||
@@ -124,8 +185,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
include_once(__DIR__ . '/modules/Mail.php');
|
||||||
|
include_once(__DIR__ . '/controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/controller/LogController.php');
|
||||||
|
|
||||||
|
try {
|
||||||
|
session_start();
|
||||||
|
logging();
|
||||||
|
sendMail(
|
||||||
|
"User Logged Out Successful",
|
||||||
|
(new getSpecificData())->getUsername(),
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$_SESSION = array();
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
http_response_code(200);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(['error' => 'An error occurred while logging out.']);
|
||||||
|
sendMail(
|
||||||
|
"[ERROR] Logout",
|
||||||
|
"$e",
|
||||||
|
(new getSpecificData())->getRequestURL(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
+1
-1
@@ -27,7 +27,7 @@ document.querySelectorAll('.group-title').forEach(title => {
|
|||||||
|
|
||||||
const logoutButton = document.getElementById('logoutButton');
|
const logoutButton = document.getElementById('logoutButton');
|
||||||
logoutButton.addEventListener('click', () => {
|
logoutButton.addEventListener('click', () => {
|
||||||
fetch('services/logout.php', { method: 'POST' })
|
fetch('logout', { method: 'POST' })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
window.location.href = 'login.php';
|
window.location.href = 'login.php';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once __DIR__ . '/../controller/DatabaseController.php';
|
||||||
|
include_once __DIR__ . '/../controller/DataController.php';
|
||||||
|
|
||||||
|
function sendMail($subject, $message, $url, bool $log, $to = "bruno.eckhardt07@gmail.com")
|
||||||
|
{
|
||||||
|
$headers = "From: bruno.eckhardt07@gmail.com\r\n";
|
||||||
|
mail(
|
||||||
|
$to,
|
||||||
|
$subject,
|
||||||
|
$message,
|
||||||
|
$headers
|
||||||
|
);
|
||||||
|
if ($log == true) {
|
||||||
|
DatabaseInsert(
|
||||||
|
"Mailing",
|
||||||
|
"DATUM, SUBJECT, MESSAGE, MAIL_AN, URL, CLIENT_IP",
|
||||||
|
(new getSpecificData())->getRequestTime(),
|
||||||
|
$subject,
|
||||||
|
$message,
|
||||||
|
$to,
|
||||||
|
$url,
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorMail($title, $error, bool $log)
|
||||||
|
{
|
||||||
|
$headers = "From: bruno.eckhardt07@gmail.com\r\n";
|
||||||
|
$headers .= "MIME-Version: 1.0\r\n";
|
||||||
|
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||||
|
|
||||||
|
mail(
|
||||||
|
"bruno.eckhardt07@gmail.com",
|
||||||
|
"[ERROR] $title",
|
||||||
|
$error,
|
||||||
|
$headers,
|
||||||
|
);
|
||||||
|
if ($log == true) {
|
||||||
|
DatabaseInsert(
|
||||||
|
"Mailing",
|
||||||
|
"DATUM, SUBJECT, MESSAGE, URL, CLIENT_IP",
|
||||||
|
(new getSpecificData())->getRequestTime(),
|
||||||
|
"[ERROR] $title",
|
||||||
|
$error,
|
||||||
|
(new getSpecificData())->getClientIP(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
<?php
|
||||||
|
if (!isset($selectedService)) {
|
||||||
|
exit('Direkter Zugriff nicht erlaubt.');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<!-- Formular für INSERT -->
|
||||||
|
<div class="vergabe-form">
|
||||||
|
<h3>1. Eintrag hinzufügen (DatabaseInsert)</h3>
|
||||||
|
<form id="insertForm" class="vergabe-grid">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Artikelname</label>
|
||||||
|
<input type="text" id="insertProdukt" placeholder="z.B. Apfel" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Menge</label>
|
||||||
|
<input type="text" id="insertMenge" placeholder="z.B. 5 Stück" required>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn-submit-vergabe">💾 Hinzufügen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Suchfeld für SHOW mit Filtern -->
|
||||||
|
<div class="form-container" style="margin-top: 20px;">
|
||||||
|
<h3>2. Liste filtern (DatabaseShow mit Conditions)</h3>
|
||||||
|
<div class="user-form-grid">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Suche nach Produkt (LIKE)</label>
|
||||||
|
<input type="text" id="searchProdukt" placeholder="Leer lassen für alle Einträge...">
|
||||||
|
</div>
|
||||||
|
<button type="button" id="btnFilter" class="btn btn-primary" style="margin: 0; width: 100%; height: 43px;">
|
||||||
|
🔍 Filtern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabellen-Container -->
|
||||||
|
<div class="table-container" style="margin-top: 30px;">
|
||||||
|
<h3>3 & 4. Daten verwalten (Tabelle via JS gerendert)</h3>
|
||||||
|
<div id="showcaseTableWrapper">
|
||||||
|
<p>Lade daten...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const tableWrapper = document.getElementById('showcaseTableWrapper');
|
||||||
|
const dbTable = 'Einkaufsliste';
|
||||||
|
|
||||||
|
const spaltenKonfig = [{
|
||||||
|
key: 'PRODUKT',
|
||||||
|
label: 'Produkt'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'MENGE',
|
||||||
|
label: 'Menge'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// ALL IN ONE: Daten laden und via AjaxMethods-Tabelle anzeigen
|
||||||
|
async function loadData() {
|
||||||
|
const searchQuery = document.getElementById('searchProdukt').value.trim();
|
||||||
|
let conditions = [];
|
||||||
|
|
||||||
|
if (searchQuery !== '') {
|
||||||
|
conditions.push({
|
||||||
|
column: 'PRODUKT',
|
||||||
|
operator: 'LIKE',
|
||||||
|
value: `%${searchQuery}%`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. SHOW ausführen
|
||||||
|
const data = await DatabaseShow(dbTable, ['ID', 'PRODUKT', 'MENGE'], conditions);
|
||||||
|
|
||||||
|
// 2. TABELLE RENDERN(Nutzt die neue Methode aus AjaxMethods.js)
|
||||||
|
// renderTableWithEdit(
|
||||||
|
// tableWrapper,
|
||||||
|
// data.entries,
|
||||||
|
// spaltenKonfig,
|
||||||
|
// 'ID',
|
||||||
|
// async (id) => {
|
||||||
|
// await editWorkflow(id);
|
||||||
|
// }, // Edit Callback
|
||||||
|
// );
|
||||||
|
|
||||||
|
// renderTableWithDelete(
|
||||||
|
// tableWrapper,
|
||||||
|
// data.entries,
|
||||||
|
// spaltenKonfig,
|
||||||
|
// 'ID',
|
||||||
|
// async (id) => {
|
||||||
|
// await deleteWorkflow(id);
|
||||||
|
// }, // Edit Callback
|
||||||
|
// )
|
||||||
|
|
||||||
|
// renderTableWithEditAndDelete(
|
||||||
|
// tableWrapper,
|
||||||
|
// data.entries,
|
||||||
|
// spaltenKonfig,
|
||||||
|
// 'ID',
|
||||||
|
// async (id) => {
|
||||||
|
// await editWorkflow(id);
|
||||||
|
// }, // Edit Callback
|
||||||
|
// async (id) => {
|
||||||
|
// await deleteWorkflow(id);
|
||||||
|
// } // Delete Callback
|
||||||
|
// )
|
||||||
|
|
||||||
|
renderTable(
|
||||||
|
tableWrapper,
|
||||||
|
data.entries,
|
||||||
|
spaltenKonfig,
|
||||||
|
)
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
tableWrapper.innerHTML = `<p style="color:red;">❌ Fehler: ${escapeHtml(error.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WORKFLOW: INSERT
|
||||||
|
document.getElementById('insertForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const produkt = document.getElementById('insertProdukt').value.trim();
|
||||||
|
const menge = document.getElementById('insertMenge').value.trim();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await DatabaseInsert(dbTable, ['PRODUKT', 'MENGE'], [produkt, menge]);
|
||||||
|
e.target.reset();
|
||||||
|
await loadData();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Fehler beim Einfügen: ' + error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// WORKFLOW: UPDATE
|
||||||
|
async function editWorkflow(id) {
|
||||||
|
|
||||||
|
const neueMenge = prompt('Neue Menge (Abbrechen für keine Änderung):');
|
||||||
|
if (neueMenge === null) return; // Abgebrochen
|
||||||
|
|
||||||
|
// Daten-Objekt für den UPDATE-Query vorbereiten
|
||||||
|
let updates = {};
|
||||||
|
if (neueMenge.trim() !== '') updates.MENGE = neueMenge.trim();
|
||||||
|
|
||||||
|
// Falls beide Felder leer gelassen wurden, abbrechen
|
||||||
|
if (Object.keys(updates).length === 0) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await DatabaseUpdate(
|
||||||
|
dbTable,
|
||||||
|
updates,
|
||||||
|
[{
|
||||||
|
column: 'ID',
|
||||||
|
operator: '=',
|
||||||
|
value: id
|
||||||
|
}]
|
||||||
|
);
|
||||||
|
await loadData();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Fehler beim Aktualisieren: ' + error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WORKFLOW: DELETE
|
||||||
|
async function deleteWorkflow(id) {
|
||||||
|
try {
|
||||||
|
await DatabaseDelete(dbTable, [{
|
||||||
|
column: 'ID',
|
||||||
|
operator: '=',
|
||||||
|
value: id
|
||||||
|
}]);
|
||||||
|
await loadData();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Fehler beim Löschen: ' + error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event Listener für Filter-Button
|
||||||
|
document.getElementById('btnFilter').addEventListener('click', loadData);
|
||||||
|
|
||||||
|
// Erster App-Start
|
||||||
|
loadData();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,580 @@
|
|||||||
|
<?php
|
||||||
|
// ======================================================
|
||||||
|
// API TESTER
|
||||||
|
// Modul für index.php
|
||||||
|
// ======================================================
|
||||||
|
|
||||||
|
// API Basis-Verzeichnis
|
||||||
|
$apiDir = realpath(__DIR__ . '/../api');
|
||||||
|
|
||||||
|
// Alle PHP APIs rekursiv finden
|
||||||
|
$apiOptions = [];
|
||||||
|
|
||||||
|
if ($apiDir !== false) {
|
||||||
|
|
||||||
|
$iterator = new RecursiveIteratorIterator(
|
||||||
|
new RecursiveDirectoryIterator(
|
||||||
|
$apiDir,
|
||||||
|
RecursiveDirectoryIterator::SKIP_DOTS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($iterator as $file) {
|
||||||
|
|
||||||
|
if (!$file->isFile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file->getExtension() !== 'php') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// relativen Pfad erzeugen
|
||||||
|
$relativePath = str_replace(
|
||||||
|
$apiDir . DIRECTORY_SEPARATOR,
|
||||||
|
'',
|
||||||
|
$file->getPathname()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Windows kompatibel
|
||||||
|
$relativePath = str_replace('\\', '/', $relativePath);
|
||||||
|
|
||||||
|
$apiOptions[] = 'api/' . $relativePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sortieren
|
||||||
|
sort($apiOptions);
|
||||||
|
|
||||||
|
// Standard Token
|
||||||
|
$defaultToken = "15a437d128c918633e57dc7d18118a073b807644f21731ed5a7ebcf3eca9e242";
|
||||||
|
?>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* ======================================================
|
||||||
|
API TESTER STYLES
|
||||||
|
====================================================== */
|
||||||
|
|
||||||
|
.api-tester-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1000px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
padding: 25px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.api-tester-container h2 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: var(--btn-bg);
|
||||||
|
border-bottom: 1px solid var(--card-border);
|
||||||
|
padding-bottom: 12px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-form-group {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-form-group label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-input,
|
||||||
|
.tester-textarea,
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: var(--input-bg);
|
||||||
|
border: 1px solid var(--input-border);
|
||||||
|
color: var(--input-text);
|
||||||
|
border-radius: 6px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-textarea {
|
||||||
|
min-height: 120px;
|
||||||
|
resize: vertical;
|
||||||
|
font-family: Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-btn-send {
|
||||||
|
width: 100%;
|
||||||
|
background-color: var(--btn-bg);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 13px;
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.2s;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-btn-send:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
#tester-response-container {
|
||||||
|
margin-top: 25px;
|
||||||
|
background-color: var(--input-bg);
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 15px;
|
||||||
|
min-height: 100px;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tester-output-content {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-family: Consolas, monospace;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-badge {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-status-200 {
|
||||||
|
background-color: #198754;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-status-error {
|
||||||
|
background-color: #dc3545;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-status-warning {
|
||||||
|
background-color: #ffc107;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-small-btn {
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--input-border);
|
||||||
|
color: var(--text);
|
||||||
|
padding: 6px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-small-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-response-info {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
|
||||||
|
.tester-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tester-row {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="api-tester-container">
|
||||||
|
|
||||||
|
<h2>🛠️ API Tester</h2>
|
||||||
|
|
||||||
|
<!-- API Auswahl -->
|
||||||
|
<div class="tester-form-group">
|
||||||
|
<label for="endpoint">API Endpunkt</label>
|
||||||
|
|
||||||
|
<select id="endpoint" class="tester-input" onchange="checkEndpoint()">
|
||||||
|
|
||||||
|
<?php foreach ($apiOptions as $opt): ?>
|
||||||
|
|
||||||
|
<option value="<?= htmlspecialchars($opt) ?>">
|
||||||
|
<?= htmlspecialchars($opt) ?>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Methode + Function -->
|
||||||
|
<div class="tester-grid">
|
||||||
|
|
||||||
|
<div class="tester-form-group">
|
||||||
|
<label for="method">HTTP Methode</label>
|
||||||
|
|
||||||
|
<select id="method" class="tester-input">
|
||||||
|
<option value="GET">GET</option>
|
||||||
|
<option value="POST">POST</option>
|
||||||
|
<option value="PUT">PUT</option>
|
||||||
|
<option value="DELETE">DELETE</option>
|
||||||
|
<option value="PATCH">PATCH</option>
|
||||||
|
<option value="OPTIONS">OPTIONS</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tester-form-group" id="function-group">
|
||||||
|
<label for="function-header">Function Header</label>
|
||||||
|
|
||||||
|
<input type="text" id="function-header" class="tester-input" placeholder="z.B. IPs, Ueberstunden">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Token -->
|
||||||
|
<div class="tester-form-group">
|
||||||
|
|
||||||
|
<label for="token">Authorization Token</label>
|
||||||
|
|
||||||
|
<div class="tester-row">
|
||||||
|
|
||||||
|
<input type="text" id="token" class="tester-input" value="<?= htmlspecialchars($defaultToken) ?>">
|
||||||
|
|
||||||
|
<label class="tester-checkbox">
|
||||||
|
<input type="checkbox" id="send-token" checked>
|
||||||
|
Mitsenden
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Eigene Header -->
|
||||||
|
<div class="tester-form-group">
|
||||||
|
|
||||||
|
<label for="custom-headers">
|
||||||
|
Zusätzliche Header (JSON)
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<textarea id="custom-headers" class="tester-textarea" placeholder='{
|
||||||
|
"X-Test": "123",
|
||||||
|
"Client": "Frontend"
|
||||||
|
}'></textarea>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- JSON Body -->
|
||||||
|
<div class="tester-form-group" id="json-body-group">
|
||||||
|
|
||||||
|
<label for="json-body">
|
||||||
|
JSON Body
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<textarea id="json-body" class="tester-textarea" placeholder='{
|
||||||
|
"test": true
|
||||||
|
}'></textarea>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Datei Upload -->
|
||||||
|
<div class="tester-form-group hidden" id="file-group">
|
||||||
|
|
||||||
|
<label for="files">Dateien Upload</label>
|
||||||
|
|
||||||
|
<input type="file" id="files" class="tester-input" multiple>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Buttons -->
|
||||||
|
<div class="tester-grid">
|
||||||
|
|
||||||
|
<button class="tester-btn-send" onclick="sendApiRequest()">
|
||||||
|
Anfrage senden 🚀
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button class="tester-btn-send" onclick="clearResponse()">
|
||||||
|
Ausgabe leeren 🧹
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Ausgabe -->
|
||||||
|
<div id="tester-response-container">
|
||||||
|
|
||||||
|
<div style="text-align:center; opacity:0.7; padding:15px;">
|
||||||
|
Bereit für Anfragen.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// ======================================================
|
||||||
|
// CHECK ENDPOINT
|
||||||
|
// ======================================================
|
||||||
|
|
||||||
|
function checkEndpoint() {
|
||||||
|
|
||||||
|
const endpoint = document.getElementById('endpoint').value;
|
||||||
|
|
||||||
|
const fileGroup = document.getElementById('file-group');
|
||||||
|
const functionGroup = document.getElementById('function-group');
|
||||||
|
const jsonBodyGroup = document.getElementById('json-body-group');
|
||||||
|
const methodSelect = document.getElementById('method');
|
||||||
|
|
||||||
|
// reset
|
||||||
|
fileGroup.classList.add('hidden');
|
||||||
|
functionGroup.classList.remove('hidden');
|
||||||
|
jsonBodyGroup.classList.remove('hidden');
|
||||||
|
|
||||||
|
// upload api
|
||||||
|
if (endpoint.includes('upload.php')) {
|
||||||
|
|
||||||
|
fileGroup.classList.remove('hidden');
|
||||||
|
jsonBodyGroup.classList.add('hidden');
|
||||||
|
|
||||||
|
methodSelect.value = 'POST';
|
||||||
|
}
|
||||||
|
|
||||||
|
// get api
|
||||||
|
if (endpoint.includes('get.php')) {
|
||||||
|
methodSelect.value = 'GET';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
// CLEAR RESPONSE
|
||||||
|
// ======================================================
|
||||||
|
|
||||||
|
function clearResponse() {
|
||||||
|
|
||||||
|
document.getElementById('tester-response-container').innerHTML = `
|
||||||
|
<div style="text-align:center; opacity:0.7; padding:15px;">
|
||||||
|
Ausgabe geleert.
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
// SEND REQUEST
|
||||||
|
// ======================================================
|
||||||
|
|
||||||
|
async function sendApiRequest() {
|
||||||
|
|
||||||
|
const endpoint = document.getElementById('endpoint').value;
|
||||||
|
const method = document.getElementById('method').value;
|
||||||
|
const token = document.getElementById('token').value;
|
||||||
|
const functionHeader = document.getElementById('function-header').value;
|
||||||
|
const customHeadersInput = document.getElementById('custom-headers').value;
|
||||||
|
const jsonBodyInput = document.getElementById('json-body').value;
|
||||||
|
const fileInput = document.getElementById('files');
|
||||||
|
const sendToken = document.getElementById('send-token').checked;
|
||||||
|
|
||||||
|
const responseContainer = document.getElementById('tester-response-container');
|
||||||
|
|
||||||
|
responseContainer.innerHTML = `
|
||||||
|
<div style="text-align:center; padding:15px;">
|
||||||
|
Anfrage läuft...
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let headers = {};
|
||||||
|
|
||||||
|
// Token
|
||||||
|
if (sendToken && token.trim() !== '') {
|
||||||
|
headers['Authorization'] = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function Header
|
||||||
|
if (functionHeader.trim() !== '') {
|
||||||
|
headers['Function'] = functionHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom Headers
|
||||||
|
if (customHeadersInput.trim() !== '') {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const customHeaders = JSON.parse(customHeadersInput);
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
...headers,
|
||||||
|
...customHeaders
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
responseContainer.innerHTML = `
|
||||||
|
<div style="color:#dc3545; padding:15px;">
|
||||||
|
Fehlerhafte Header JSON Struktur.
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
method: method,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
|
||||||
|
// Upload
|
||||||
|
if (endpoint.includes('upload.php') && fileInput.files.length > 0) {
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
|
||||||
|
for (let i = 0; i < fileInput.files.length; i++) {
|
||||||
|
formData.append('files[]', fileInput.files[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
options.body = formData;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// JSON Body
|
||||||
|
if (
|
||||||
|
['POST', 'PUT', 'PATCH', 'DELETE']
|
||||||
|
.includes(method) &&
|
||||||
|
jsonBodyInput.trim() !== ''
|
||||||
|
) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
JSON.parse(jsonBodyInput);
|
||||||
|
|
||||||
|
headers['Content-Type'] = 'application/json';
|
||||||
|
|
||||||
|
options.body = jsonBodyInput;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
responseContainer.innerHTML = `
|
||||||
|
<div style="color:#dc3545; padding:15px;">
|
||||||
|
Fehlerhafte JSON Body Struktur.
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedAt = performance.now();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const response = await fetch(endpoint, options);
|
||||||
|
|
||||||
|
const duration = (performance.now() - startedAt).toFixed(0);
|
||||||
|
|
||||||
|
const status = response.status;
|
||||||
|
|
||||||
|
const rawText = await response.text();
|
||||||
|
|
||||||
|
let resultText = rawText;
|
||||||
|
|
||||||
|
// JSON hübsch formatieren
|
||||||
|
try {
|
||||||
|
|
||||||
|
const json = JSON.parse(rawText);
|
||||||
|
|
||||||
|
resultText = JSON.stringify(json, null, 2);
|
||||||
|
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
let badgeClass = 'tester-status-error';
|
||||||
|
|
||||||
|
if (status >= 200 && status < 300) {
|
||||||
|
badgeClass = 'tester-status-200';
|
||||||
|
} else if (status >= 300 && status < 400) {
|
||||||
|
badgeClass = 'tester-status-warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
responseContainer.innerHTML = `
|
||||||
|
<div class="tester-badge ${badgeClass}">
|
||||||
|
Status: ${status}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tester-response-info">
|
||||||
|
⏱️ ${duration} ms
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="tester-small-btn"
|
||||||
|
onclick="copyResponse()"
|
||||||
|
>
|
||||||
|
Antwort kopieren
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<pre id="tester-output-content"></pre>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.getElementById('tester-output-content').textContent = resultText;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
responseContainer.innerHTML = `
|
||||||
|
<div style="color:#dc3545; padding:15px;">
|
||||||
|
Fehler: ${error.message}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================
|
||||||
|
// COPY RESPONSE
|
||||||
|
// ======================================================
|
||||||
|
|
||||||
|
function copyResponse() {
|
||||||
|
|
||||||
|
const content = document.getElementById('tester-output-content');
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
navigator.clipboard.writeText(content.textContent);
|
||||||
|
|
||||||
|
alert('Antwort kopiert.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial
|
||||||
|
checkEndpoint();
|
||||||
|
</script>
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
$conn = db_connect();
|
$conn = db_connect();
|
||||||
|
|
||||||
$sql = "SELECT DATE(FIRST_REQUEST) as tag, COUNT(*) as anzahl FROM logs WHERE WEBSITE = 'backend.blackpi.ipv64.net' GROUP BY DATE(FIRST_REQUEST) ORDER BY DATE(FIRST_REQUEST)";
|
$sql = "SELECT DATE(FIRST_REQUEST) as tag, COUNT(*) as anzahl FROM logs WHERE WEBSITE = 'backend.mrhossa.de' GROUP BY DATE(FIRST_REQUEST) ORDER BY DATE(FIRST_REQUEST)";
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
$labels = [];
|
$labels = [];
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
if ($result->num_rows > 0) {
|
if ($result->num_rows > 0) {
|
||||||
while($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
$labels[] = $row['tag'];
|
$labels[] = $row['tag'];
|
||||||
$data[] = (int)$row['anzahl'];
|
$data[] = (int)$row['anzahl'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE DATE(FIRST_REQUEST) = CURDATE()
|
WHERE DATE(FIRST_REQUEST) = CURDATE()
|
||||||
AND (WEBSITE = 'backend.blackpi.ipv64.net')
|
AND (WEBSITE = 'backend.mrhossa.de')
|
||||||
AND CLIENT_IP NOT IN ($devips_sql)
|
AND CLIENT_IP NOT IN ($devips_sql)
|
||||||
ORDER BY FIRST_REQUEST DESC
|
ORDER BY FIRST_REQUEST DESC
|
||||||
";
|
";
|
||||||
@@ -50,7 +50,7 @@ if (!$useCustom) {
|
|||||||
$sql = "
|
$sql = "
|
||||||
SELECT CLIENT_IP, LAND, USER_AGENT, SUM(counter) AS gesamt_counter
|
SELECT CLIENT_IP, LAND, USER_AGENT, SUM(counter) AS gesamt_counter
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE (WEBSITE = 'backend.blackpi.ipv64.net')
|
WHERE (WEBSITE = 'backend.mrhossa.de')
|
||||||
AND CLIENT_IP NOT IN ($devips_sql)
|
AND CLIENT_IP NOT IN ($devips_sql)
|
||||||
GROUP BY CLIENT_IP
|
GROUP BY CLIENT_IP
|
||||||
ORDER BY gesamt_counter DESC
|
ORDER BY gesamt_counter DESC
|
||||||
@@ -62,7 +62,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node1'
|
WHERE `SERVER_IP` = 'node1'
|
||||||
AND (WEBSITE = 'backend.blackpi.ipv64.net')
|
AND (WEBSITE = 'backend.mrhossa.de')
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -72,7 +72,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node2'
|
WHERE `SERVER_IP` = 'node2'
|
||||||
AND (WEBSITE = 'backend.blackpi.ipv64.net')
|
AND (WEBSITE = 'backend.mrhossa.de')
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -82,7 +82,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node3'
|
WHERE `SERVER_IP` = 'node3'
|
||||||
AND (WEBSITE = 'backend.blackpi.ipv64.net')
|
AND (WEBSITE = 'backend.mrhossa.de')
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -92,7 +92,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node4'
|
WHERE `SERVER_IP` = 'node4'
|
||||||
AND (WEBSITE = 'backend.blackpi.ipv64.net')
|
AND (WEBSITE = 'backend.mrhossa.de')
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -101,7 +101,7 @@ if (!$useCustom) {
|
|||||||
$sql = "
|
$sql = "
|
||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE (WEBSITE = 'backend.blackpi.ipv64.net')
|
WHERE (WEBSITE = 'backend.mrhossa.de')
|
||||||
AND CLIENT_IP NOT IN ($devips_sql)
|
AND CLIENT_IP NOT IN ($devips_sql)
|
||||||
ORDER BY FIRST_REQUEST DESC
|
ORDER BY FIRST_REQUEST DESC
|
||||||
";
|
";
|
||||||
@@ -116,7 +116,7 @@ if (!$useCustom) {
|
|||||||
|
|
||||||
<select name="filter" onchange="this.form.submit()">
|
<select name="filter" onchange="this.form.submit()">
|
||||||
<?php
|
<?php
|
||||||
$options = ['alle','today','node1','node2','node3','node4','counterperip'];
|
$options = ['alle', 'today', 'node1', 'node2', 'node3', 'node4', 'counterperip'];
|
||||||
foreach ($options as $opt) {
|
foreach ($options as $opt) {
|
||||||
$sel = ($filter === $opt) ? 'selected' : '';
|
$sel = ($filter === $opt) ? 'selected' : '';
|
||||||
echo "<option value='$opt' $sel>$opt</option>";
|
echo "<option value='$opt' $sel>$opt</option>";
|
||||||
@@ -150,10 +150,10 @@ if ($erg = $conn->query($sql)) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (!$daten): ?>
|
<?php if (!$daten): ?>
|
||||||
<b>Keine Daten gefunden</b>
|
<b>Keine Daten gefunden</b>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<div style="overflow-x:auto;">
|
<div style="overflow-x:auto;">
|
||||||
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;width:100%;">
|
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;width:100%;">
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($daten[0] as $key => $_): ?>
|
<?php foreach ($daten[0] as $key => $_): ?>
|
||||||
@@ -169,6 +169,6 @@ if ($erg = $conn->query($sql)) {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$mode = $_GET['mode'] ?? 'fk';
|
||||||
|
|
||||||
|
if ($mode === 'normal') {
|
||||||
|
$data = Databaseshow("Firmenberichte");
|
||||||
|
} else {
|
||||||
|
$data = DatabaseShowWithFK(
|
||||||
|
"Berufsschulberichte",
|
||||||
|
$Berufsschulberichte,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array_reverse($data);
|
||||||
|
|
||||||
|
$displayData = (is_array($data) && isset($data['rows'])) ? $data['rows'] : $data;
|
||||||
|
$count = is_array($displayData) ? count($displayData) : 0;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" href="../style.css">
|
||||||
|
<style>
|
||||||
|
.debug-table-container {
|
||||||
|
background: #252525;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0;
|
||||||
|
margin-top: 20px;
|
||||||
|
overflow-x: auto;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
color: #ccc;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
background: #333;
|
||||||
|
text-align: left;
|
||||||
|
padding: 15px 12px;
|
||||||
|
border-bottom: 2px solid #3498db;
|
||||||
|
color: #3498db;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:nth-child(even) {
|
||||||
|
background: rgba(255, 255, 255, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
tr:hover {
|
||||||
|
background: rgba(52, 152, 219, 0.1);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Highlight für DATUM Spalte */
|
||||||
|
td:first-child,
|
||||||
|
th:first-child {
|
||||||
|
position: sticky;
|
||||||
|
left: 0;
|
||||||
|
background: #252525;
|
||||||
|
z-index: 5;
|
||||||
|
border-right: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
th:first-child {
|
||||||
|
z-index: 11;
|
||||||
|
background: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debug-raw {
|
||||||
|
background: #1a1a1a;
|
||||||
|
color: #00ff00;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-family: 'Fira Code', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
overflow: auto;
|
||||||
|
border-left: 4px solid #3498db;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-count {
|
||||||
|
background: #3498db;
|
||||||
|
color: white;
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-note {
|
||||||
|
padding: 40px;
|
||||||
|
text-align: center;
|
||||||
|
color: #777;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="<?= ($_SESSION['dark_mode'] ?? true) ? 'dark-mode' : '' ?>">
|
||||||
|
<div class="main">
|
||||||
|
<div class="content">
|
||||||
|
<h2 style="display: flex; justify-content: space-between; align-items: center;">
|
||||||
|
<span>📊 Berichte-Vorschau:</span>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="?service=<?= $selectedService ?>&mode=fk">
|
||||||
|
<button <?= $mode === 'fk' ? 'style="background:#3498db;color:white;"' : '' ?>>
|
||||||
|
Berufsschulberichte
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="?service=<?= $selectedService ?>&mode=normal">
|
||||||
|
<button <?= $mode === 'normal' ? 'style="background:#3498db;color:white;"' : '' ?>>
|
||||||
|
Arbeitsberichte
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<?php if ($count > 0 && is_array($displayData[0])): ?>
|
||||||
|
<div class="debug-table-container">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<?php foreach (array_keys($displayData[0]) as $column): ?>
|
||||||
|
<th><?= htmlspecialchars($column) ?></th>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($displayData as $row): ?>
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($row as $key => $cell): ?>
|
||||||
|
<td><?= htmlspecialchars($cell ?? '-') ?></td>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="debug-table-container">
|
||||||
|
<div class="empty-note">
|
||||||
|
Keine tabellarischen Daten gefunden.<br>
|
||||||
|
<small>Struktur: <?= is_array($data) ? 'Array ('.count($data).' Keys)' : gettype($data) ?></small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
<?php
|
|
||||||
$conn = db_connect();
|
|
||||||
$view = $_GET['view'] ?? 'show';
|
|
||||||
$selectedService = $_GET['service'];
|
|
||||||
|
|
||||||
// --- LOGIK: Überstunden-Eintrag (Abbau) speichern ---
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_overtime'])) {
|
|
||||||
$datum = $_POST['ot_date'];
|
|
||||||
$minuten = intval($_POST['ot_minutes']);
|
|
||||||
$grund = $conn->real_escape_string($_POST['ot_reason']);
|
|
||||||
$insert_sql = "INSERT INTO Ueberstunden (DATUM, MINUTEN, GRUND) VALUES ('$datum', $minuten, '$grund')";
|
|
||||||
$conn->query($insert_sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Daten laden ---
|
|
||||||
$daten = [];
|
|
||||||
$sql = "SELECT `DATUM`, `PROZESS_1`, `PROZESS_2`, `PROZESS_3`, `PROZESS_4`, `BEGINN`, `ENDE_REAL`, `OVERTIME` FROM Firmenberichte ORDER BY `DATUM` DESC";
|
|
||||||
if ($erg = $conn->query($sql)) {
|
|
||||||
while ($datensatz = $erg->fetch_object()) { $daten[] = $datensatz; }
|
|
||||||
$erg->free();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Gesamtsumme berechnen ---
|
|
||||||
$minuten_berichte = 0;
|
|
||||||
$res1 = $conn->query("SELECT SUM(OVERTIME) AS summe FROM Firmenberichte");
|
|
||||||
if ($row = $res1->fetch_object()) { $minuten_berichte = intval($row->summe); }
|
|
||||||
|
|
||||||
$minuten_extra = 0;
|
|
||||||
$res2 = $conn->query("SELECT SUM(MINUTEN) AS summe FROM Ueberstunden");
|
|
||||||
if ($row = $res2->fetch_object()) { $minuten_extra = intval($row->summe); }
|
|
||||||
|
|
||||||
$gesamt_minuten = $minuten_berichte - $minuten_extra;
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="arbeitsberichte-wrapper">
|
|
||||||
<div style="display: flex; gap: 10px; margin-bottom: 25px;">
|
|
||||||
<a href="?service=<?= $selectedService ?>&view=rechner" style="text-decoration:none;">
|
|
||||||
<button class="nav-btn <?= $view == 'rechner' ? 'active' : '' ?>" style="padding: 10px 20px; cursor: pointer; border: none; border-radius: 4px; font-weight: bold;
|
|
||||||
background: <?= $view == 'rechner' ? '#007bff' : 'rgba(150,150,150,0.2)' ?>;
|
|
||||||
color: <?= $view == 'rechner' ? '#fff' : '#fff' ?>;">
|
|
||||||
Live-Timer
|
|
||||||
</button>
|
|
||||||
</a>
|
|
||||||
<a href="?service=<?= $selectedService ?>&view=show" style="text-decoration:none;">
|
|
||||||
<button class="nav-btn <?= $view == 'show' ? 'active' : '' ?>" style="padding: 10px 20px; cursor: pointer; border: none; border-radius: 4px; font-weight: bold;
|
|
||||||
background: <?= $view == 'show' ? '#007bff' : 'rgba(150,150,150,0.2)' ?>;
|
|
||||||
color: <?= $view == 'show' ? '#fff' : '#fff' ?>;">
|
|
||||||
Übersicht
|
|
||||||
</button>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if ($view === 'rechner'): ?>
|
|
||||||
<div class="overtime-container" style="color: inherit;">
|
|
||||||
<h2 style="color: inherit;">Überstunden Rechner</h2>
|
|
||||||
<label for="startTime">Arbeitsstartzeit:</label>
|
|
||||||
<input type="time" id="startTime" step="60"
|
|
||||||
style="background: rgba(150,150,150,0.1); color: inherit; border: 1px solid #555;">
|
|
||||||
<button id="startBtn">Timer starten</button>
|
|
||||||
|
|
||||||
<div id="resultBox" class="overtime-result">
|
|
||||||
<p style="margin:0; font-size: 0.9rem;">Überstunden / Restzeit:</p>
|
|
||||||
<div id="result">0:00</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php else: ?>
|
|
||||||
<div
|
|
||||||
style="background: rgba(150,150,150,0.05); padding: 25px; border-radius: 10px; margin-bottom: 25px; border: 1px solid rgba(150,150,150,0.2); border-left: 6px solid #007bff;">
|
|
||||||
<div style="margin-bottom: 20px;">
|
|
||||||
<span style="color: #888; font-size: 0.8rem; font-weight: bold; text-transform: uppercase;">Aktueller
|
|
||||||
Stand</span>
|
|
||||||
<h2 style="margin: 5px 0 0 0; font-size: 2rem; color: <?= $gesamt_minuten >= 0 ? '#28a745' : '#dc3545' ?>;">
|
|
||||||
<?= intdiv($gesamt_minuten, 60) ?>h <?= abs($gesamt_minuten % 60) ?>min
|
|
||||||
</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form method="POST" style="display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-end;">
|
|
||||||
<input type="hidden" name="add_overtime" value="1">
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 5px;">
|
|
||||||
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Datum</label>
|
|
||||||
<input type="date" name="ot_date" value="<?= date('Y-m-d') ?>" required
|
|
||||||
style="padding: 8px; border: 1px solid rgba(150,150,150,0.3); border-radius: 4px; background: rgba(150,150,150,0.1); color: inherit;">
|
|
||||||
</div>
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 5px;">
|
|
||||||
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Minuten Abbau</label>
|
|
||||||
<input type="number" name="ot_minutes" placeholder="480" required
|
|
||||||
style="width: 100px; padding: 8px; border: 1px solid rgba(150,150,150,0.3); border-radius: 4px; background: rgba(150,150,150,0.1); color: inherit;">
|
|
||||||
</div>
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 5px; flex-grow: 1;">
|
|
||||||
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Grund</label>
|
|
||||||
<input type="text" name="ot_reason" placeholder="z.B. Abbau" required
|
|
||||||
style="padding: 8px; border: 1px solid rgba(150,150,150,0.3); border-radius: 4px; background: rgba(150,150,150,0.1); color: inherit;">
|
|
||||||
</div>
|
|
||||||
<button type="submit"
|
|
||||||
style="background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; font-weight: bold; cursor: pointer;">
|
|
||||||
Eintrag speichern
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table style="width: 100%; border-collapse: collapse; color: inherit;">
|
|
||||||
<thead>
|
|
||||||
<tr style="background: rgba(0,123,255,0.15); text-align: left;">
|
|
||||||
<th style="padding: 12px; border-bottom: 2px solid #007bff;">Datum</th>
|
|
||||||
<th style="padding: 12px; border-bottom: 2px solid #007bff;">Prozesse</th>
|
|
||||||
<th style="padding: 12px; border-bottom: 2px solid #007bff;">Zeitraum</th>
|
|
||||||
<th style="padding: 12px; border-bottom: 2px solid #007bff;">Overtime</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($daten as $b): ?>
|
|
||||||
<tr style="border-bottom: 1px solid rgba(150,150,150,0.2); vertical-align: top;">
|
|
||||||
<td style="padding: 12px; white-space: nowrap;"><?= htmlspecialchars($b->DATUM) ?></td>
|
|
||||||
<td style="padding: 12px;">
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; opacity: 0.8;">
|
|
||||||
<?php for($i=1; $i<=4; $i++): $p = "PROZESS_$i"; ?>
|
|
||||||
<?php if(!empty($b->$p)): ?> <span>• <?= htmlspecialchars($b->$p) ?></span> <?php endif; ?>
|
|
||||||
<?php endfor; ?>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td style="padding: 12px; font-size: 0.9rem; white-space: nowrap;"><?= $b->BEGINN ?> -
|
|
||||||
<?= $b->ENDE_REAL ?></td>
|
|
||||||
<td style="padding: 12px; font-weight: bold; color: <?= $b->OVERTIME >= 0 ? '#28a745' : '#dc3545' ?>;">
|
|
||||||
<?= $b->OVERTIME ?> min
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Live-Rechner Logik
|
|
||||||
if (document.getElementById('startBtn')) {
|
|
||||||
document.getElementById('startBtn').addEventListener('click', function() {
|
|
||||||
const startTimeInput = document.getElementById('startTime').value;
|
|
||||||
if (!startTimeInput) return;
|
|
||||||
const [hours, minutes] = startTimeInput.split(':').map(Number);
|
|
||||||
let startDate = new Date();
|
|
||||||
startDate.setHours(hours, minutes, 0);
|
|
||||||
const targetWorkMs = 8.5 * 60 * 60 * 1000;
|
|
||||||
const resultEl = document.getElementById('result');
|
|
||||||
const resultBox = document.getElementById('resultBox');
|
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
const diffMs = (new Date() - startDate) - targetWorkMs;
|
|
||||||
const negative = diffMs < 0;
|
|
||||||
const absMs = Math.abs(diffMs);
|
|
||||||
const h = Math.floor(absMs / 3600000);
|
|
||||||
const m = Math.floor((absMs % 3600000) / 60000);
|
|
||||||
resultEl.innerText = (negative ? '-' : '+') + h + ":" + (m < 10 ? '0' : '') + m;
|
|
||||||
if (negative) {
|
|
||||||
resultBox.classList.add('negative');
|
|
||||||
} else {
|
|
||||||
resultBox.classList.remove('negative');
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
<?php
|
||||||
|
include_once(__DIR__ . '/../controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
$alleFaecher = DatabaseShow("Fach", "ID, FACH");
|
||||||
|
$alleRaeume = DatabaseShow("Raum", "ID, RAUM_NR");
|
||||||
|
$alleLehrer = DatabaseShow("Lehrer", "ID, NAME");
|
||||||
|
|
||||||
|
/*
|
||||||
|
1 => ["fach_id" => 1, "raum_id" => 5, "lehrer_id" => 8], // LF1
|
||||||
|
1 => ["fach_id" => 2, "raum_id" => 4, "lehrer_id" => 11], // LF2
|
||||||
|
1 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
1 => ["fach_id" => 4, "raum_id" => 1, "lehrer_id" => 5], // LF4
|
||||||
|
6 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
1 => ["fach_id" => 6, "raum_id" => 5, "lehrer_id" => 4], // Sozi
|
||||||
|
1 => ["fach_id" => 8, "raum_id" => 5, "lehrer_id" => 7], // VWL
|
||||||
|
1 => ["fach_id" => 9, "raum_id" => 5, "lehrer_id" => 3], // DE
|
||||||
|
1 => ["fach_id" => 10, "raum_id" => 5, "lehrer_id" => 3], // ENG
|
||||||
|
*/
|
||||||
|
|
||||||
|
$Stundenplan = [
|
||||||
|
"MO" => [
|
||||||
|
1 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
2 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
3 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
4 => ["fach_id" => 6, "raum_id" => 5, "lehrer_id" => 4], // Sozi
|
||||||
|
5 => ["fach_id" => 10, "raum_id" => 5, "lehrer_id" => 3], // Eng
|
||||||
|
6 => ["fach_id" => 10, "raum_id" => 5, "lehrer_id" => 3], // Eng
|
||||||
|
7 => ["fach_id" => 2, "raum_id" => 3, "lehrer_id" => 11], // LF2
|
||||||
|
8 => ["fach_id" => 2, "raum_id" => 3, "lehrer_id" => 11], // LF2
|
||||||
|
],
|
||||||
|
"DI" => [
|
||||||
|
1 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
2 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
3 => ["fach_id" => 5, "raum_id" => 1, "lehrer_id" => 5], // LF5
|
||||||
|
4 => ["fach_id" => 2, "raum_id" => 3, "lehrer_id" => 6], // LF2
|
||||||
|
5 => ["fach_id" => 2, "raum_id" => 3, "lehrer_id" => 6], // LF2
|
||||||
|
],
|
||||||
|
"MI" => [
|
||||||
|
1 => ["fach_id" => 8, "raum_id" => 5, "lehrer_id" => 7], // VWL
|
||||||
|
2 => ["fach_id" => 8, "raum_id" => 5, "lehrer_id" => 7], // VWL
|
||||||
|
3 => ["fach_id" => 9, "raum_id" => 5, "lehrer_id" => 3], // DE
|
||||||
|
4 => ["fach_id" => 9, "raum_id" => 5, "lehrer_id" => 3], // DE
|
||||||
|
5 => ["fach_id" => 2, "raum_id" => 4, "lehrer_id" => 6], // LF2
|
||||||
|
6 => ["fach_id" => 2, "raum_id" => 4, "lehrer_id" => 6], // LF2
|
||||||
|
7 => ["fach_id" => 8, "raum_id" => 5, "lehrer_id" => 7], // VWL
|
||||||
|
],
|
||||||
|
"DO" => [
|
||||||
|
1 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
2 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
3 => ["fach_id" => 3, "raum_id" => 1, "lehrer_id" => 2], // LF3
|
||||||
|
4 => ["fach_id" => 6, "raum_id" => 5, "lehrer_id" => 4], // Sozi
|
||||||
|
5 => ["fach_id" => 6, "raum_id" => 5, "lehrer_id" => 4], // Sozi
|
||||||
|
6 => ["fach_id" => 4, "raum_id" => 1, "lehrer_id" => 5], // LF4
|
||||||
|
7 => ["fach_id" => 4, "raum_id" => 1, "lehrer_id" => 5], // LF4
|
||||||
|
8 => ["fach_id" => 4, "raum_id" => 1, "lehrer_id" => 5], // LF4
|
||||||
|
],
|
||||||
|
"FR" => [
|
||||||
|
1 => ["fach_id" => 1, "raum_id" => 5, "lehrer_id" => 8], // LF1
|
||||||
|
2 => ["fach_id" => 1, "raum_id" => 5, "lehrer_id" => 8], // LF1
|
||||||
|
3 => ["fach_id" => 1, "raum_id" => 5, "lehrer_id" => 8], // LF1
|
||||||
|
4 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
5 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
6 => ["fach_id" => 5, "raum_id" => 3, "lehrer_id" => 1], // LF5
|
||||||
|
]
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Berufsschulbericht</title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="main">
|
||||||
|
<div class="content" style="max-width: 1100px; margin: 0 auto; padding: 20px;">
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
<h3 style="margin-top: 0;">Berufsschulbericht erfassen</h3>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="form-group" style="max-width: 220px; margin-bottom: 25px;">
|
||||||
|
<label for="datum">Datum auswählen</label>
|
||||||
|
<input type="date" name="datum" id="datum" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="vergabe-grid"
|
||||||
|
style="font-weight: bold; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--card-border);">
|
||||||
|
<div>Stunde</div>
|
||||||
|
<div>Fach</div>
|
||||||
|
<div>Raum</div>
|
||||||
|
<div>Lehrer</div>
|
||||||
|
<div>Inhalt / Thema</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php for ($i = 1; $i <= 8; $i++): ?>
|
||||||
|
<div class="vergabe-grid" style="margin-bottom: 10px; align-items: center;">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span class="badge"
|
||||||
|
style="display: inline-block; min-width: 90px; text-align: center; padding: 8px 12px; font-weight: bold;">Stunde
|
||||||
|
<?= $i ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<select name="stunden[<?= $i ?>][fach_id]" data-stunde="<?= $i ?>" data-type="fach_id">
|
||||||
|
<option value="">-- Fach --</option>
|
||||||
|
<?php foreach ($alleFaecher as $row): ?>
|
||||||
|
<option value="<?= $row['ID'] ?>"><?= htmlspecialchars($row['FACH']) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<select name="stunden[<?= $i ?>][raum_id]" data-stunde="<?= $i ?>" data-type="raum_id">
|
||||||
|
<option value="">-- Raum --</option>
|
||||||
|
<?php foreach ($alleRaeume as $row): ?>
|
||||||
|
<option value="<?= $row['ID'] ?>"><?= htmlspecialchars($row['RAUM_NR']) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<select name="stunden[<?= $i ?>][lehrer_id]" data-stunde="<?= $i ?>" data-type="lehrer_id">
|
||||||
|
<option value="">-- Lehrer --</option>
|
||||||
|
<?php foreach ($alleLehrer as $row): ?>
|
||||||
|
<option value="<?= $row['ID'] ?>"><?= htmlspecialchars($row['NAME']) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" name="stunden[<?= $i ?>][inhalt_text]" placeholder="Inhalt der Stunde..."
|
||||||
|
style="margin: 0; padding: 10px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php endfor; ?>
|
||||||
|
|
||||||
|
<div style="margin-top: 25px; text-align: right;">
|
||||||
|
<button type="submit" class="btn-submit-vergabe"
|
||||||
|
style="width: 220px; display: inline-flex; font-weight: bold;">
|
||||||
|
Bericht speichern
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const stundenplan = <?= json_encode($Stundenplan) ?>;
|
||||||
|
const wochentage = ["SO", "MO", "DI", "MI", "DO", "FR", "SA"];
|
||||||
|
|
||||||
|
document.getElementById('datum').addEventListener('change', function() {
|
||||||
|
const gewaehltesDatum = new Date(this.value);
|
||||||
|
if (isNaN(gewaehltesDatum)) return;
|
||||||
|
|
||||||
|
let tagKey = wochentage[gewaehltesDatum.getDay()];
|
||||||
|
|
||||||
|
if (tagKey === "SO" || tagKey === "SA") {
|
||||||
|
tagKey = "MO";
|
||||||
|
}
|
||||||
|
|
||||||
|
const tagesPlan = stundenplan[tagKey] || {};
|
||||||
|
|
||||||
|
document.querySelectorAll('.vergabe-grid select').forEach(select => {
|
||||||
|
const stunde = select.getAttribute('data-stunde');
|
||||||
|
const type = select.getAttribute('data-type');
|
||||||
|
|
||||||
|
const vordefinierteId = (tagesPlan[stunde] && tagesPlan[stunde][type]) ? tagesPlan[stunde][
|
||||||
|
type
|
||||||
|
] : "";
|
||||||
|
|
||||||
|
select.value = vordefinierteId;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$datum = $_POST['datum'] ?? null;
|
||||||
|
$werte = [$datum];
|
||||||
|
|
||||||
|
for ($i = 1; $i <= 8; $i++) {
|
||||||
|
$stunde = $_POST['stunden'][$i] ?? [];
|
||||||
|
$werte[] = !empty($stunde['fach_id']) ? $stunde['fach_id'] : null;
|
||||||
|
$werte[] = !empty($stunde['lehrer_id']) ? $stunde['lehrer_id'] : null;
|
||||||
|
$werte[] = !empty($stunde['raum_id']) ? $stunde['raum_id'] : null;
|
||||||
|
$werte[] = !empty($stunde['inhalt_text']) ? $stunde['inhalt_text'] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Berufsschulberichte",
|
||||||
|
"DATUM, FACH_S1, LEHRER_S1, RAUM_S1, INHALT_S1, FACH_S2, LEHRER_S2, RAUM_S2, INHALT_S2, FACH_S3, LEHRER_S3, RAUM_S3, INHALT_S3, FACH_S4, LEHRER_S4, RAUM_S4, INHALT_S4, FACH_S5, LEHRER_S5, RAUM_S5, INHALT_S5, FACH_S6, LEHRER_S6, RAUM_S6, INHALT_S6, FACH_S7, LEHRER_S7, RAUM_S7, INHALT_S7, FACH_S8, LEHRER_S8, RAUM_S8, INHALT_S8",
|
||||||
|
...$werte
|
||||||
|
);
|
||||||
|
|
||||||
|
echo "<div class='status-msg' style='position: fixed; bottom: 20px; right: 20px; z-index: 10000;'>Bericht gespeichert!</div>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$statusMsg = "";
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
Neue Domain hinzufügen
|
||||||
|
========================= */
|
||||||
|
if (isset($_POST["add_domain"])) {
|
||||||
|
|
||||||
|
$subdomain = trim($_POST["subdomain"]);
|
||||||
|
|
||||||
|
if ($subdomain != "") {
|
||||||
|
DatabaseInsert("Domains", "SUBDOMAIN", $subdomain);
|
||||||
|
$statusMsg = "Domain wurde hinzugefügt.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
Domain löschen
|
||||||
|
========================= */
|
||||||
|
if (isset($_POST["delete_domain"])) {
|
||||||
|
|
||||||
|
$id = intval($_POST["id"]);
|
||||||
|
|
||||||
|
DatabaseDelete("Domains", "ID = ?", $id);
|
||||||
|
|
||||||
|
$statusMsg = "Domain wurde gelöscht.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
Domain bearbeiten
|
||||||
|
========================= */
|
||||||
|
if (isset($_POST["save_domain"])) {
|
||||||
|
|
||||||
|
$id = intval($_POST["id"]);
|
||||||
|
$subdomain = trim($_POST["subdomain"]);
|
||||||
|
|
||||||
|
DatabaseUpdate("Domains", "SUBDOMAIN = ?", "ID = ?", $subdomain, $id);
|
||||||
|
|
||||||
|
$statusMsg = "Domain wurde gespeichert.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* =========================
|
||||||
|
Domains laden
|
||||||
|
========================= */
|
||||||
|
|
||||||
|
$domains = DatabaseShow("Domains", "*");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
Domain Verwaltung
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<?php if ($statusMsg): ?>
|
||||||
|
<div class="status-msg">
|
||||||
|
<?= htmlspecialchars($statusMsg) ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="admin-grid">
|
||||||
|
|
||||||
|
<?php foreach ($domains as $domain): ?>
|
||||||
|
|
||||||
|
<form method="post" class="admin-card">
|
||||||
|
|
||||||
|
<input type="hidden" name="id" value="<?= $domain["ID"] ?>">
|
||||||
|
|
||||||
|
<label>Subdomain</label>
|
||||||
|
|
||||||
|
<input type="text" name="subdomain" value="<?= htmlspecialchars($domain["SUBDOMAIN"]) ?>">
|
||||||
|
|
||||||
|
<div style="margin-top:10px; display:flex; gap:10px;">
|
||||||
|
|
||||||
|
<button type="submit" name="save_domain" class="btn-save">
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="submit" name="delete_domain" class="btn-delete">
|
||||||
|
Löschen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Neue Domain -->
|
||||||
|
|
||||||
|
<form method="post" class="admin-card new-item">
|
||||||
|
|
||||||
|
<h3>Neu</h3>
|
||||||
|
|
||||||
|
<label>Subdomain</label>
|
||||||
|
|
||||||
|
<input type="text" name="subdomain" placeholder="z.B. kleinerpenis.mrhossa.de">
|
||||||
|
|
||||||
|
<button type="submit" name="add_domain" class="btn-add">
|
||||||
|
Domain hinzufügen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<div>
|
||||||
|
<div class="vergabe-form">
|
||||||
|
<form id="addForm" class="vergabe-grid">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Artikel</label>
|
||||||
|
<input type="text" name="artikel" id="artikel" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Menge</label>
|
||||||
|
<input type="text" name="menge" id="menge" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-submit-vergabe">
|
||||||
|
Speichern
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container" style="margin-top: 30px;">
|
||||||
|
<h3>Einkaufsliste</h3>
|
||||||
|
<div id="tableWrapper">
|
||||||
|
<p>Lade Daten...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const tableWrapper = document.getElementById('tableWrapper');
|
||||||
|
const table = 'Einkaufsliste';
|
||||||
|
|
||||||
|
const spaltenKonfig = [{
|
||||||
|
key: 'PRODUKT',
|
||||||
|
label: 'Artikel'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'MENGE',
|
||||||
|
label: 'Menge'
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function reloadTable() {
|
||||||
|
try {
|
||||||
|
const data = await DatabaseShow(table);
|
||||||
|
renderTableWithDelete(tableWrapper, data.entries, spaltenKonfig, 'ID', async (id) => {
|
||||||
|
await DatabaseDelete(table, [{
|
||||||
|
column: 'ID',
|
||||||
|
operator: '=',
|
||||||
|
value: id
|
||||||
|
}]);
|
||||||
|
await reloadTable();
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
tableWrapper.innerHTML = `<p> ${escapeHtml(error.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('addForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const artikel = document.getElementById('artikel').value.trim();
|
||||||
|
const menge = document.getElementById('menge').value.trim();
|
||||||
|
if (!artikel || !menge) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await DatabaseInsert(table, ['PRODUKT', 'MENGE'], [artikel, menge]);
|
||||||
|
e.target.reset();
|
||||||
|
await reloadTable();
|
||||||
|
} catch (error) {
|
||||||
|
alert('Fehler beim Speichern: ' + error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reloadTable();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../controller/DataController.php');
|
||||||
|
include_once(__DIR__ . '/../controller/DatabaseController.php');
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_bericht'])) {
|
||||||
|
$prozess1 = $_POST['prozess1'];
|
||||||
|
$prozess2 = $_POST['prozess2'];
|
||||||
|
$prozess3 = $_POST['prozess3'];
|
||||||
|
$prozess4 = $_POST['prozess4'];
|
||||||
|
$startzeit = $_POST['startzeit'];
|
||||||
|
$endzeit = $_POST['endzeit'];
|
||||||
|
$datum = $_POST['datum'];
|
||||||
|
|
||||||
|
// IHK konforme zeiten berechnen und Überstunden berechnen
|
||||||
|
$soll = new DateTime($startzeit);
|
||||||
|
$soll->modify("+8 hours 30 minutes");
|
||||||
|
|
||||||
|
$randomMin = rand(1, 15);
|
||||||
|
$endePublicDt = clone $soll;
|
||||||
|
$endePublicDt->modify("+{$randomMin} minutes");
|
||||||
|
$endePublic = $endePublicDt->format("H:i");
|
||||||
|
|
||||||
|
$real = DateTime::createFromFormat("H:i", $endzeit);
|
||||||
|
|
||||||
|
$beginnDt = new DateTime($startzeit);
|
||||||
|
$arbeitsDiff = $beginnDt->diff($real);
|
||||||
|
$arbeitsMinuten = ($arbeitsDiff->h * 60) + $arbeitsDiff->i;
|
||||||
|
$sollMinuten = 8 * 60 + 30;
|
||||||
|
|
||||||
|
if ($arbeitsMinuten <= $sollMinuten) {
|
||||||
|
$overtime = 0;
|
||||||
|
} else {
|
||||||
|
$diff = $soll->diff($real);
|
||||||
|
$overtime = ($diff->h * 60) + $diff->i;
|
||||||
|
}
|
||||||
|
|
||||||
|
DatabaseInsert(
|
||||||
|
"Firmenberichte",
|
||||||
|
"DATUM, PROZESS_1, PROZESS_2, PROZESS_3, PROZESS_4, BEGINN, ENDE_REAL, ENDE_PUBLIC, OVERTIME",
|
||||||
|
$datum,
|
||||||
|
$prozess1,
|
||||||
|
$prozess2,
|
||||||
|
$prozess3,
|
||||||
|
$prozess4,
|
||||||
|
$startzeit,
|
||||||
|
$endzeit,
|
||||||
|
$endePublic,
|
||||||
|
$overtime
|
||||||
|
);
|
||||||
|
|
||||||
|
redirectToWebsite((new getSpecificData())->getReferer());
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="berichte-container">
|
||||||
|
<form method="POST" class="berichte-form">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Prozess 1</label>
|
||||||
|
<input type="text" name="prozess1" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Prozess 2</label>
|
||||||
|
<input type="text" name="prozess2" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Prozess 3</label>
|
||||||
|
<input type="text" name="prozess3" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Prozess 4</label>
|
||||||
|
<input type="text" name="prozess4" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Startzeit</label>
|
||||||
|
<input type="time" name="startzeit" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Endzeit</label>
|
||||||
|
<input type="time" name="endzeit" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Datum</label>
|
||||||
|
<input type="date" name="datum" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" name="add_bericht" class="btn-submit-bericht">
|
||||||
|
Bericht Speichern
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -19,6 +19,7 @@ $db_res = DatabaseShow(
|
|||||||
<h3 style="background-color: #007bff;">👤 Benutzerprofil</h3>
|
<h3 style="background-color: #007bff;">👤 Benutzerprofil</h3>
|
||||||
<div class="group-links" style="padding: 10px; color: inherit;">
|
<div class="group-links" style="padding: 10px; color: inherit;">
|
||||||
<p style="margin: 5px 0;"><strong>Name:</strong> <code><?= htmlspecialchars($username) ?></code></p>
|
<p style="margin: 5px 0;"><strong>Name:</strong> <code><?= htmlspecialchars($username) ?></code></p>
|
||||||
|
<?php if ($username != 'gast'): ?>
|
||||||
<p style="margin: 5px 0;"><strong>Nachname:</strong>
|
<p style="margin: 5px 0;"><strong>Nachname:</strong>
|
||||||
<code><?= htmlspecialchars($db_res[0]['NACHNAME']) ?></code>
|
<code><?= htmlspecialchars($db_res[0]['NACHNAME']) ?></code>
|
||||||
</p>
|
</p>
|
||||||
@@ -31,6 +32,7 @@ $db_res = DatabaseShow(
|
|||||||
<p style="margin: 5px 0;"><strong>Home IP:</strong>
|
<p style="margin: 5px 0;"><strong>Home IP:</strong>
|
||||||
<code><?= htmlspecialchars($db_res[0]['HOME_IP']) ?></code>
|
<code><?= htmlspecialchars($db_res[0]['HOME_IP']) ?></code>
|
||||||
</p>
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$dir = __DIR__ . "/../static";
|
||||||
|
$files = array_diff(scandir($dir), ['.', '..']);
|
||||||
|
|
||||||
|
echo '<button onclick="printFiles()">Alle Dateien drucken</button>';
|
||||||
|
|
||||||
|
echo '<div class="print-container">';
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
|
||||||
|
$url = "static/" . rawurlencode($file);
|
||||||
|
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
echo '<div class="print-page">';
|
||||||
|
|
||||||
|
if (in_array($ext, ['png','jpg','jpeg','webp'])) {
|
||||||
|
echo "<img src='$url'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($ext === "pdf") {
|
||||||
|
echo "<embed src='$url' type='application/pdf'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
echo "<p>$file kann nicht direkt gedruckt werden.</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function printFiles() {
|
||||||
|
console.log("Ich wurde gedrückt");
|
||||||
|
window.print();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.print-page {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
page-break-after: always;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-page img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-page embed {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
|
||||||
|
body * {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-container,
|
||||||
|
.print-container * {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-container {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -40,7 +40,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE CLIENT_IP NOT IN ($devips_sql)
|
WHERE CLIENT_IP NOT IN ($devips_sql)
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
AND DATE(FIRST_REQUEST) = CURDATE()
|
AND DATE(FIRST_REQUEST) = CURDATE()
|
||||||
ORDER BY FIRST_REQUEST DESC
|
ORDER BY FIRST_REQUEST DESC
|
||||||
";
|
";
|
||||||
@@ -51,7 +51,7 @@ if (!$useCustom) {
|
|||||||
SELECT CLIENT_IP, LAND, USER_AGENT, SUM(counter) AS gesamt_counter
|
SELECT CLIENT_IP, LAND, USER_AGENT, SUM(counter) AS gesamt_counter
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE CLIENT_IP NOT IN ($devips_sql)
|
WHERE CLIENT_IP NOT IN ($devips_sql)
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
GROUP BY CLIENT_IP
|
GROUP BY CLIENT_IP
|
||||||
ORDER BY gesamt_counter DESC
|
ORDER BY gesamt_counter DESC
|
||||||
";
|
";
|
||||||
@@ -62,7 +62,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node1'
|
WHERE `SERVER_IP` = 'node1'
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -72,7 +72,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node2'
|
WHERE `SERVER_IP` = 'node2'
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -82,7 +82,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node3'
|
WHERE `SERVER_IP` = 'node3'
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -92,7 +92,7 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE `SERVER_IP` = 'node4'
|
WHERE `SERVER_IP` = 'node4'
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
ORDER BY `FIRST_REQUEST` DESC
|
ORDER BY `FIRST_REQUEST` DESC
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
@@ -102,10 +102,10 @@ if (!$useCustom) {
|
|||||||
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
SELECT `CLIENT_IP`, `LAND`, `REQUEST_URL`, `COUNTER`, `FIRST_REQUEST`, `WEBSITE`
|
||||||
FROM logs
|
FROM logs
|
||||||
WHERE CLIENT_IP NOT IN ($devips_sql)
|
WHERE CLIENT_IP NOT IN ($devips_sql)
|
||||||
AND (WEBSITE != 'backend.blackpi.ipv64.net' OR WEBSITE IS NULL)
|
AND (WEBSITE != 'backend.mrhossa.de' OR WEBSITE IS NULL)
|
||||||
ORDER BY FIRST_REQUEST DESC
|
ORDER BY FIRST_REQUEST DESC
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ if (!$useCustom) {
|
|||||||
|
|
||||||
<select name="filter" onchange="this.form.submit()">
|
<select name="filter" onchange="this.form.submit()">
|
||||||
<?php
|
<?php
|
||||||
$options = ['alle','today','node1','node2','node3','node4','counterperip'];
|
$options = ['alle', 'today', 'node1', 'node2', 'node3', 'node4', 'counterperip'];
|
||||||
foreach ($options as $opt) {
|
foreach ($options as $opt) {
|
||||||
$sel = ($filter === $opt) ? 'selected' : '';
|
$sel = ($filter === $opt) ? 'selected' : '';
|
||||||
echo "<option value='$opt' $sel>$opt</option>";
|
echo "<option value='$opt' $sel>$opt</option>";
|
||||||
@@ -150,10 +150,10 @@ if ($erg = $conn->query($sql)) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (!$daten): ?>
|
<?php if (!$daten): ?>
|
||||||
<b>Keine Daten gefunden</b>
|
<b>Keine Daten gefunden</b>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<div style="overflow-x:auto;">
|
<div style="overflow-x:auto;">
|
||||||
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;width:100%;">
|
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse;width:100%;">
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($daten[0] as $key => $_): ?>
|
<?php foreach ($daten[0] as $key => $_): ?>
|
||||||
@@ -169,6 +169,6 @@ if ($erg = $conn->query($sql)) {
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include_once(__DIR__ . '/../controller/RightsController.php');
|
||||||
|
include_once(__DIR__ . '/../config.php');
|
||||||
|
|
||||||
$configFile = 'config.php';
|
$configFile = 'config.php';
|
||||||
$backupDir = 'config_backups';
|
$backupDir = 'config_backups';
|
||||||
|
|
||||||
@@ -47,6 +50,7 @@ if (isset($_POST['save']) && ($_SESSION['logged_in'] ?? false)) {
|
|||||||
$serviceToGroupMapping[$s['targetGroup']][] = $finalId;
|
$serviceToGroupMapping[$s['targetGroup']][] = $finalId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(new RightsController())->RightsHandler($s['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newServiceGroups = [];
|
$newServiceGroups = [];
|
||||||
@@ -118,7 +122,7 @@ unset($_SESSION['status_message']);
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="<?= ($_SESSION['dark_mode'] ?? false) ? 'dark-mode' : '' ?>">
|
<body class="<?= ($_SESSION['dark_mode'] ?? false) ? 'dark-mode' : '' ?>">
|
||||||
<div class="main">
|
<div class="content">
|
||||||
<?php if (!($_SESSION['logged_in'] ?? false)): ?>
|
<?php if (!($_SESSION['logged_in'] ?? false)): ?>
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<div class="login-box">
|
<div class="login-box">
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
$tables = DatabaseShowTables();
|
||||||
|
$selectedTable = $_GET['table'] ?? null;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Datenbank Struktur</h2>
|
||||||
|
|
||||||
|
<form method="GET">
|
||||||
|
<input type="hidden" name="service" value="tabellen">
|
||||||
|
|
||||||
|
<label for="table">Tabelle auswählen:</label>
|
||||||
|
<select name="table" id="table" onchange="this.form.submit()">
|
||||||
|
<option value="">-- Bitte wählen --</option>
|
||||||
|
<?php foreach ($tables as $table): ?>
|
||||||
|
<option value="<?= htmlspecialchars($table) ?>" <?= ($selectedTable === $table) ? 'selected' : '' ?>>
|
||||||
|
<?= htmlspecialchars($table) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($selectedTable && in_array($selectedTable, $tables)) {
|
||||||
|
|
||||||
|
$structure = DatabaseShowTableStructure($selectedTable);
|
||||||
|
|
||||||
|
echo "<div class='table-container'>";
|
||||||
|
echo "<table class='db-table'>";
|
||||||
|
echo "<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Null</th>
|
||||||
|
<th>Key</th>
|
||||||
|
<th>Default</th>
|
||||||
|
<th>Extra</th>
|
||||||
|
</tr>";
|
||||||
|
|
||||||
|
foreach ($structure as $column) {
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>" . ($column['Field']) . "</td>";
|
||||||
|
echo "<td>" . ($column['Type']) . "</td>";
|
||||||
|
echo "<td>" . ($column['Null']) . "</td>";
|
||||||
|
echo "<td>" . ($column['Key']) . "</td>";
|
||||||
|
echo "<td>" . ($column['Default']) . "</td>";
|
||||||
|
echo "<td>" . ($column['Extra']) . "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "</table>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
<div id="statusMsg" class="status-msg" style="display:none;"></div>
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
<h3>📅 Neuen Termin vergeben</h3>
|
||||||
|
<form id="addTerminForm" class="vergabe-form">
|
||||||
|
<div class="vergabe-grid">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="datum">Start-Datum *</label>
|
||||||
|
<input type="date" id="datum" name="datum" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="zeit">Uhrzeit *</label>
|
||||||
|
<input type="time" id="zeit" name="zeit" required
|
||||||
|
style="width:100%; padding:10px; border-radius:5px; border:1px solid var(--input-border); background:var(--input-bg); color:var(--input-text);">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">Name / Zweck *</label>
|
||||||
|
<input type="text" id="name" name="name" placeholder="z.B. Kundentermin" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="notiz">Notiz (Optional)</label>
|
||||||
|
<input type="text" id="notiz" name="notiz" placeholder="Details zum Termin...">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="wiederholung">Wiederholung</label>
|
||||||
|
<select id="wiederholung" name="wiederholung"
|
||||||
|
style="width:100%; padding:10px; border-radius:5px; border:1px solid var(--input-border); background:var(--input-bg); color:var(--input-text);">
|
||||||
|
<option value="none">Keine Wiederholung</option>
|
||||||
|
<option value="daily">Täglich</option>
|
||||||
|
<option value="weekly">Wöchentlich</option>
|
||||||
|
<option value="monthly">Monatlich</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" id="enddatum-group" style="display: none;">
|
||||||
|
<label for="enddatum">Wiederholen bis *</label>
|
||||||
|
<input type="date" id="enddatum" name="enddatum">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn-submit-vergabe">Speichern</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
<h3>📋 Aktuelle Terminbelegungen</h3>
|
||||||
|
<div class="table-container">
|
||||||
|
<div id="termineTableWrapper">Lade Daten...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script src="/js/ajaxApi/TermineAjaxMethods.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const statusMsg = document.getElementById('statusMsg');
|
||||||
|
const tableWrapper = document.getElementById('termineTableWrapper');
|
||||||
|
|
||||||
|
const intervallNamen = {
|
||||||
|
daily: 'Täglich',
|
||||||
|
weekly: 'Wöchentlich',
|
||||||
|
monthly: 'Monatlich'
|
||||||
|
};
|
||||||
|
|
||||||
|
function zeigeStatus(text, istFehler = false) {
|
||||||
|
statusMsg.textContent = text;
|
||||||
|
statusMsg.style.display = 'block';
|
||||||
|
statusMsg.style.background = istFehler ? '#f8d7da' : '';
|
||||||
|
statusMsg.style.color = istFehler ? '#721c24' : '';
|
||||||
|
setTimeout(() => {
|
||||||
|
statusMsg.style.display = 'none';
|
||||||
|
}, 4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDatum(iso) {
|
||||||
|
const d = new Date(iso);
|
||||||
|
return d.toLocaleDateString('de-DE');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatZeit(zeit) {
|
||||||
|
return zeit?.slice(0, 5) ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTermine(termine) {
|
||||||
|
if (!termine || termine.length === 0) {
|
||||||
|
tableWrapper.innerHTML = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead><tr><th>Datum / Turnus</th><th>Uhrzeit</th><th>Termin / Name</th><th>Notiz</th><th>Eingetragen von</th><th>Aktion</th></tr></thead>
|
||||||
|
<tbody><tr><td colspan="6" style="text-align:center; padding:20px;">Keine Termine eingetragen.</td></tr></tbody>
|
||||||
|
</table>`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr><th>Datum / Turnus</th><th>Uhrzeit</th><th>Termin / Name</th><th>Notiz</th><th>Eingetragen von</th><th>Aktion</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (const t of termine) {
|
||||||
|
const istSerie = !!t.SERIEN_ID;
|
||||||
|
html += `
|
||||||
|
<tr>
|
||||||
|
<td data-label="Datum:">
|
||||||
|
<strong>${escapeHtml(formatDatum(t.DATUM))}</strong>
|
||||||
|
${istSerie ? `<br><small style="color:#007bff; font-style:italic;">(${escapeHtml(intervallNamen[t.INTERVALL] ?? '')} bis ${escapeHtml(formatDatum(t.SERIEN_ENDE))})</small>` : ''}
|
||||||
|
</td>
|
||||||
|
<td data-label="Uhrzeit:">${escapeHtml(formatZeit(t.ZEIT))}</td>
|
||||||
|
<td data-label="Termin / Name:">
|
||||||
|
<strong>${escapeHtml(t.NAME)}</strong>
|
||||||
|
${istSerie ? `<span style="font-size:0.8em; background:#e1f5fe; color:#0288d1; padding:2px 6px; border-radius:10px; margin-left:5px;">Wiederholend</span>` : ''}
|
||||||
|
</td>
|
||||||
|
<td data-label="Notiz:">${escapeHtml(t.NOTIZ || '-')}</td>
|
||||||
|
<td data-label="Von:"><span class="badge">${escapeHtml(t.ERSTELLT_VON)}</span></td>
|
||||||
|
<td data-label="Aktion:">
|
||||||
|
${istSerie
|
||||||
|
? `<button type="button" class="btn-delete btn-delete-serie" data-serien-id="${escapeHtml(t.SERIEN_ID)}" style="background-color:#d32f2f;">löschen</button>`
|
||||||
|
: `<button type="button" class="btn-delete btn-delete-einzeln" data-id="${escapeHtml(t.ID)}">Löschen</button>`
|
||||||
|
}
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += `</tbody></table>`;
|
||||||
|
tableWrapper.innerHTML = html;
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-delete-einzeln').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Termin wirklich löschen?')) return;
|
||||||
|
try {
|
||||||
|
const data = await deleteTermin(btn.dataset.id);
|
||||||
|
zeigeStatus(data.message);
|
||||||
|
await ladeTermine();
|
||||||
|
} catch (err) {
|
||||||
|
zeigeStatus('Fehler: ' + err.message, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-delete-serie').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du die GESAMTE Terminserie löschen?')) return;
|
||||||
|
try {
|
||||||
|
const data = await deleteTerminSerie(btn.dataset.serienId);
|
||||||
|
zeigeStatus(data.message);
|
||||||
|
await ladeTermine();
|
||||||
|
} catch (err) {
|
||||||
|
zeigeStatus('Fehler: ' + err.message, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeTermine() {
|
||||||
|
try {
|
||||||
|
const data = await getTermine();
|
||||||
|
renderTermine(data.entries);
|
||||||
|
} catch (err) {
|
||||||
|
tableWrapper.innerHTML = `<p>❌ ${escapeHtml(err.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Wiederholung: Enddatum-Feld ein-/ausblenden
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('wiederholung').addEventListener('change', function() {
|
||||||
|
const enddatumGroup = document.getElementById('enddatum-group');
|
||||||
|
const enddatumInput = document.getElementById('enddatum');
|
||||||
|
|
||||||
|
if (this.value !== 'none') {
|
||||||
|
enddatumGroup.style.display = 'block';
|
||||||
|
enddatumInput.required = true;
|
||||||
|
} else {
|
||||||
|
enddatumGroup.style.display = 'none';
|
||||||
|
enddatumInput.required = false;
|
||||||
|
enddatumInput.value = '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Formular absenden
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('addTerminForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const datum = document.getElementById('datum').value;
|
||||||
|
const zeit = document.getElementById('zeit').value;
|
||||||
|
const name = document.getElementById('name').value.trim();
|
||||||
|
const notiz = document.getElementById('notiz').value.trim();
|
||||||
|
const wiederholung = document.getElementById('wiederholung').value;
|
||||||
|
const enddatum = document.getElementById('enddatum').value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await addTermin(datum, zeit, name, notiz, wiederholung, enddatum);
|
||||||
|
zeigeStatus(data.message);
|
||||||
|
e.target.reset();
|
||||||
|
document.getElementById('enddatum-group').style.display = 'none';
|
||||||
|
await ladeTermine();
|
||||||
|
} catch (err) {
|
||||||
|
zeigeStatus('Fehler: ' + err.message, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ladeTermine();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
<div class="arbeitsberichte-wrapper">
|
||||||
|
<div class="vergabe-form">
|
||||||
|
<h3>Neues Ticket anlegen</h3>
|
||||||
|
<form id="addTicketForm" class="vergabe-grid">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Titel</label>
|
||||||
|
<input type="text" name="titel" id="in-titel" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Beschreibung</label>
|
||||||
|
<input type="text" name="beschreibung" id="in-beschreibung" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-submit-vergabe">💾 Speichern</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container" style="margin-top: 30px;">
|
||||||
|
<h3>Tickets</h3>
|
||||||
|
<div id="tableWrapper">
|
||||||
|
<p>Lade Daten...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/ajaxApi/TicketBoardAjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const tableWrapper = document.getElementById('tableWrapper');
|
||||||
|
const POLL_INTERVAL_MS = 5000;
|
||||||
|
let lastStatusById = {};
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Tabelle rendern (eigene Render-Funktion wg. Status-Highlight)
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
function renderTicketsTabelle(entries) {
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
tableWrapper.innerHTML = '<p>Keine Tickets vorhanden.</p>';
|
||||||
|
lastStatusById = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Titel</th><th>Beschreibung</th><th>Status</th>
|
||||||
|
<th style="width: 100px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
for (const e of entries) {
|
||||||
|
const changed = lastStatusById[e.ID] !== undefined &&
|
||||||
|
lastStatusById[e.ID] !== e.STATUS;
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<tr data-id="${escapeHtml(e.ID)}" class="${changed ? 'status-row-changed' : ''}">
|
||||||
|
<td data-label="Titel">${escapeHtml(e.TITEL)}</td>
|
||||||
|
<td data-label="Beschreibung">${escapeHtml(e.BESCHREIBUNG)}</td>
|
||||||
|
<td data-label="Status"><span class="status-badge">${escapeHtml(e.STATUS)}</span></td>
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<button type="button" class="btn-delete" data-id="${escapeHtml(e.ID)}">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
html += `</tbody></table>`;
|
||||||
|
tableWrapper.innerHTML = html;
|
||||||
|
|
||||||
|
const neueStatus = {};
|
||||||
|
entries.forEach(e => {
|
||||||
|
neueStatus[e.ID] = e.STATUS;
|
||||||
|
});
|
||||||
|
lastStatusById = neueStatus;
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du dieses Ticket wirklich löschen?')) return;
|
||||||
|
try {
|
||||||
|
await deleteTicketEntry(btn.dataset.id);
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Löschen: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeListe() {
|
||||||
|
try {
|
||||||
|
const data = await getTicketEntries();
|
||||||
|
renderTicketsTabelle(data.entries);
|
||||||
|
} catch (err) {
|
||||||
|
tableWrapper.innerHTML = `<p>❌ ${escapeHtml(err.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Ticket anlegen
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('addTicketForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const titel = document.getElementById('in-titel').value.trim();
|
||||||
|
const beschreibung = document.getElementById('in-beschreibung').value.trim();
|
||||||
|
|
||||||
|
if (!titel || !beschreibung) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await addTicketEntry(titel, beschreibung);
|
||||||
|
e.target.reset();
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Speichern: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Initialisierung + zyklische Aktualisierung
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
ladeListe();
|
||||||
|
setInterval(ladeListe, POLL_INTERVAL_MS);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@keyframes statusChanged {
|
||||||
|
0% {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-row-changed {
|
||||||
|
animation: statusChanged 2.5s ease-out;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<div class="arbeitsberichte-wrapper">
|
||||||
|
<div class="table-container" style="margin-top: 30px;">
|
||||||
|
<h3>Ticket Verwaltung</h3>
|
||||||
|
<div id="tableWrapper">
|
||||||
|
<p>Lade Daten...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script src="/js/ajaxApi/TicketControlAjaxMethods.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const tableWrapper = document.getElementById('tableWrapper');
|
||||||
|
const allowedStatuses = ['OFFEN', 'DEPLOYED', 'ABGELEHNT', 'ANGENOMMEN'];
|
||||||
|
|
||||||
|
function renderTicketControTabelle(entries) {
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
tableWrapper.innerHTML = '<p>Keine Tickets vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Titel</th><th>Beschreibung</th><th>Status</th><th>Ersteller</th>
|
||||||
|
<th style="width: 220px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
for (const e of entries) {
|
||||||
|
const options = allowedStatuses.map(s =>
|
||||||
|
`<option value="${escapeHtml(s)}" ${e.STATUS === s ? 'selected' : ''}>${escapeHtml(s)}</option>`
|
||||||
|
).join('');
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<tr data-id="${escapeHtml(e.ID)}">
|
||||||
|
<td data-label="Titel">${escapeHtml(e.TITEL)}</td>
|
||||||
|
<td data-label="Beschreibung">${escapeHtml(e.BESCHREIBUNG)}</td>
|
||||||
|
<td data-label="Status">${escapeHtml(e.STATUS)}</td>
|
||||||
|
<td data-label="Ersteller">${escapeHtml(e.ERSTELLER)}</td>
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<div style="display:flex; flex-direction:column; gap:6px; align-items:stretch;">
|
||||||
|
<select class="status-select" data-id="${escapeHtml(e.ID)}">
|
||||||
|
${options}
|
||||||
|
</select>
|
||||||
|
<button type="button" class="btn-edit" data-id="${escapeHtml(e.ID)}">Speichern</button>
|
||||||
|
<button type="button" class="btn-delete" data-id="${escapeHtml(e.ID)}" style="margin-top:3pt;">Löschen</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
html += `</tbody></table>`;
|
||||||
|
tableWrapper.innerHTML = html;
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-edit').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
const id = btn.dataset.id;
|
||||||
|
const select = tableWrapper.querySelector(
|
||||||
|
`.status-select[data-id="${id}"]`);
|
||||||
|
try {
|
||||||
|
await editTicketControEntry(id, select.value);
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Speichern: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du dieses Ticket wirklich löschen?')) return;
|
||||||
|
try {
|
||||||
|
await deleteTicketControEntry(btn.dataset.id);
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Löschen: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeListe() {
|
||||||
|
try {
|
||||||
|
const data = await getTicketControEntries();
|
||||||
|
renderTicketControTabelle(data.entries);
|
||||||
|
} catch (err) {
|
||||||
|
tableWrapper.innerHTML = `<p>❌ ${escapeHtml(err.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ladeListe();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
<div class="arbeitsberichte-wrapper">
|
||||||
|
<div class="vergabe-form">
|
||||||
|
<form id="addForm" class="vergabe-grid">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Wann ausgeliehen</label>
|
||||||
|
<input type="date" name="wann" id="in-wann" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Rückgabe</label>
|
||||||
|
<input type="date" name="rueckgabe" id="in-rueckgabe" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group autocomplete-wrapper">
|
||||||
|
<label>An wen</label>
|
||||||
|
<input type="text" id="wer-input" placeholder="Name eingeben" required autocomplete="off">
|
||||||
|
<div class="autocomplete-suggestions" id="wer-suggestions"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group autocomplete-wrapper">
|
||||||
|
<label>Was</label>
|
||||||
|
<input type="text" id="was-input" placeholder="Gegenstand eingeben" required autocomplete="off">
|
||||||
|
<div class="autocomplete-suggestions" id="was-suggestions"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn-submit-vergabe">Speichern</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="vergabe-form" style="margin-top: 30px;">
|
||||||
|
<form id="searchForm" class="vergabe-grid">
|
||||||
|
|
||||||
|
<div class="form-group autocomplete-wrapper">
|
||||||
|
<label for="search-wer-input">Nach Person filtern</label>
|
||||||
|
<input type="text" id="search-wer-input" placeholder="Name eingeben..." autocomplete="off">
|
||||||
|
<div class="autocomplete-suggestions" id="search-wer-suggestions"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group autocomplete-wrapper">
|
||||||
|
<label for="search-was-input">Nach Gegenstand filtern</label>
|
||||||
|
<input type="text" id="search-was-input" placeholder="Gegenstand eingeben..." autocomplete="off">
|
||||||
|
<div class="autocomplete-suggestions" id="search-was-suggestions"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="display: flex; gap: 10px; align-items: flex-end;">
|
||||||
|
<button type="submit" class="btn-submit-vergabe" style="margin: 0; flex-grow: 1;">Suchen</button>
|
||||||
|
<button type="button" id="resetSearch" class="btn-delete" style="margin: 0;">Zurücksetzen</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-container" style="margin-top: 30px;">
|
||||||
|
<h3 id="tableHeading">Aktuelle Vergaben</h3>
|
||||||
|
<div id="tableWrapper">
|
||||||
|
<p>Lade Daten...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/ajaxApi/VergabeAjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const tableWrapper = document.getElementById('tableWrapper');
|
||||||
|
const tableHeading = document.getElementById('tableHeading');
|
||||||
|
|
||||||
|
let aktuellSearchWer = '';
|
||||||
|
let aktuellSearchWas = '';
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Tabelle rendern (eigene Render-Funktion, da "Zurückgeben"
|
||||||
|
// eine andere Aktion ist als das generische Löschen)
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
function renderVergabeTabelle(entries) {
|
||||||
|
if (!entries || entries.length === 0) {
|
||||||
|
tableWrapper.innerHTML = '<p>Keine Einträge vorhanden.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<table class="db-table mobile-responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Was</th><th>Wer</th><th>Wann ausgeliehen</th><th>Rückgabe</th>
|
||||||
|
<th style="width: 100px;">Aktion</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
`;
|
||||||
|
for (const e of entries) {
|
||||||
|
html += `
|
||||||
|
<tr data-id="${escapeHtml(e.ID)}">
|
||||||
|
<td data-label="Was">${escapeHtml(e.WAS)}</td>
|
||||||
|
<td data-label="Wer">${escapeHtml(e.WER)}</td>
|
||||||
|
<td data-label="Wann">${escapeHtml(e.WANN)}</td>
|
||||||
|
<td data-label="Rückgabe">${escapeHtml(e.RUECKGABE)}</td>
|
||||||
|
<td data-label="Aktion">
|
||||||
|
<button type="button" class="btn-delete" data-id="${escapeHtml(e.ID)}">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
html += `</tbody></table>`;
|
||||||
|
tableWrapper.innerHTML = html;
|
||||||
|
|
||||||
|
tableWrapper.querySelectorAll('.btn-delete').forEach(btn => {
|
||||||
|
btn.addEventListener('click', async () => {
|
||||||
|
if (!confirm('Möchtest du diesen Eintrag wirklich löschen?')) return;
|
||||||
|
try {
|
||||||
|
await returnVergabeEntry(btn.dataset.id);
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Löschen: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function aktualisiereUeberschrift() {
|
||||||
|
if (aktuellSearchWer && aktuellSearchWas) {
|
||||||
|
tableHeading.textContent = `Gefiltert nach: ${aktuellSearchWer} ➔ ${aktuellSearchWas}`;
|
||||||
|
} else if (aktuellSearchWer) {
|
||||||
|
tableHeading.textContent = `Vergaben für: ${aktuellSearchWer}`;
|
||||||
|
} else if (aktuellSearchWas) {
|
||||||
|
tableHeading.textContent = `Ausgeliehene Gegenstände: ${aktuellSearchWas}`;
|
||||||
|
} else {
|
||||||
|
tableHeading.textContent = 'Aktuelle Vergaben';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeListe() {
|
||||||
|
try {
|
||||||
|
const data = await getVergabeEntries(aktuellSearchWer, aktuellSearchWas);
|
||||||
|
aktualisiereUeberschrift();
|
||||||
|
renderVergabeTabelle(data.entries);
|
||||||
|
} catch (err) {
|
||||||
|
tableWrapper.innerHTML = `<p>❌ ${escapeHtml(err.message)}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Eintrag hinzufügen
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('addForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const wann = document.getElementById('in-wann').value;
|
||||||
|
const rueckgabe = document.getElementById('in-rueckgabe').value;
|
||||||
|
const wer = document.getElementById('wer-input').value.trim();
|
||||||
|
const was = document.getElementById('was-input').value.trim();
|
||||||
|
|
||||||
|
if (!wann || !rueckgabe || !wer || !was) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await addVergabeEntry(was, wer, wann, rueckgabe);
|
||||||
|
e.target.reset();
|
||||||
|
document.getElementById('in-wann').value = new Date().toISOString().slice(0, 10);
|
||||||
|
document.getElementById('in-rueckgabe').value = new Date().toISOString().slice(0, 10);
|
||||||
|
await ladeVorschlaege(); // neue WAS/WER-Werte könnten dazugekommen sein
|
||||||
|
await ladeListe();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Speichern: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Suche
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('searchForm').addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
aktuellSearchWer = document.getElementById('search-wer-input').value.trim();
|
||||||
|
aktuellSearchWas = document.getElementById('search-was-input').value.trim();
|
||||||
|
await ladeListe();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('resetSearch').addEventListener('click', async () => {
|
||||||
|
aktuellSearchWer = '';
|
||||||
|
aktuellSearchWas = '';
|
||||||
|
document.getElementById('search-wer-input').value = '';
|
||||||
|
document.getElementById('search-was-input').value = '';
|
||||||
|
await ladeListe();
|
||||||
|
});
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Autocomplete (unverändert zu deiner Logik, nur Datenquelle
|
||||||
|
// kommt jetzt per AJAX statt server-seitig eingebettet)
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
function setupAutocomplete(inputId, suggestionsId, data, submitOnSelect = false) {
|
||||||
|
const input = document.getElementById(inputId);
|
||||||
|
const box = document.getElementById(suggestionsId);
|
||||||
|
if (!input || !box) return;
|
||||||
|
|
||||||
|
let items = [];
|
||||||
|
let activeIndex = -1;
|
||||||
|
|
||||||
|
function render(list) {
|
||||||
|
box.innerHTML = '';
|
||||||
|
items = list;
|
||||||
|
activeIndex = -1;
|
||||||
|
if (list.length === 0) {
|
||||||
|
box.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
list.forEach((val, i) => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.textContent = val;
|
||||||
|
div.addEventListener('mousedown', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
selectItem(i);
|
||||||
|
});
|
||||||
|
box.appendChild(div);
|
||||||
|
});
|
||||||
|
box.style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateActive() {
|
||||||
|
[...box.children].forEach((el, i) => el.classList.toggle('active', i === activeIndex));
|
||||||
|
if (activeIndex >= 0) box.children[activeIndex].scrollIntoView({
|
||||||
|
block: 'nearest'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectItem(i) {
|
||||||
|
if (items[i] !== undefined) input.value = items[i];
|
||||||
|
box.style.display = 'none';
|
||||||
|
activeIndex = -1;
|
||||||
|
if (submitOnSelect) {
|
||||||
|
input.closest('form').dispatchEvent(new Event('submit', {
|
||||||
|
cancelable: true
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
input.addEventListener('input', () => {
|
||||||
|
const val = input.value.toLowerCase();
|
||||||
|
if (val.length === 0) {
|
||||||
|
box.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
render(data.filter(d => d.toLowerCase().includes(val)));
|
||||||
|
});
|
||||||
|
|
||||||
|
input.addEventListener('keydown', (e) => {
|
||||||
|
if (box.style.display !== 'block') return;
|
||||||
|
if (e.key === 'ArrowDown') {
|
||||||
|
e.preventDefault();
|
||||||
|
activeIndex = Math.min(activeIndex + 1, items.length - 1);
|
||||||
|
updateActive();
|
||||||
|
} else if (e.key === 'ArrowUp') {
|
||||||
|
e.preventDefault();
|
||||||
|
activeIndex = Math.max(activeIndex - 1, 0);
|
||||||
|
updateActive();
|
||||||
|
} else if (e.key === 'Tab' || e.key === 'Enter') {
|
||||||
|
if (activeIndex >= 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
selectItem(activeIndex);
|
||||||
|
} else box.style.display = 'none';
|
||||||
|
} else if (e.key === 'Escape') box.style.display = 'none';
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', (e) => {
|
||||||
|
if (e.target !== input) box.style.display = 'none';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeVorschlaege() {
|
||||||
|
const data = await getVergabeSuggestions();
|
||||||
|
setupAutocomplete('was-input', 'was-suggestions', data.was);
|
||||||
|
setupAutocomplete('wer-input', 'wer-suggestions', data.wer);
|
||||||
|
setupAutocomplete('search-wer-input', 'search-wer-suggestions', data.wer, true);
|
||||||
|
setupAutocomplete('search-was-input', 'search-was-suggestions', data.was, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Initialisierung
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
document.getElementById('in-wann').value = new Date().toISOString().slice(0, 10);
|
||||||
|
document.getElementById('in-rueckgabe').value = new Date().toISOString().slice(0, 10);
|
||||||
|
|
||||||
|
ladeVorschlaege();
|
||||||
|
ladeListe();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
$conn = db_connect();
|
||||||
|
|
||||||
|
$sql = "SELECT ZEIT, AKTUELL FROM Wetter";
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
$labels = [];
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$labels[] = $row['ZEIT'];
|
||||||
|
$data[] = (float)$row['AKTUELL'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<canvas id="logChart" width="600" height="400"></canvas>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ctx = document.getElementById('logChart').getContext('2d');
|
||||||
|
const logChart = new Chart(ctx, {
|
||||||
|
type: 'line',
|
||||||
|
data: {
|
||||||
|
labels: <?php echo json_encode($labels); ?>,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Wetter',
|
||||||
|
data: <?php echo json_encode($data); ?>,
|
||||||
|
borderColor: 'rgba(75, 192, 192, 1)',
|
||||||
|
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
||||||
|
fill: false,
|
||||||
|
tension: 0
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
plugins: {
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
display: true,
|
||||||
|
position: 'top'
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
pan: {
|
||||||
|
enabled: true,
|
||||||
|
mode: 'x',
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
wheel: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
mode: 'x',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
interaction: {
|
||||||
|
mode: 'index',
|
||||||
|
intersect: false
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: {
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Zeitraum'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
min: -10,
|
||||||
|
max: 40,
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Temperatur in °C'
|
||||||
|
},
|
||||||
|
ticks: {
|
||||||
|
stepSize: 1
|
||||||
|
},
|
||||||
|
beginAtZero: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<div class="arbeitsberichte-wrapper">
|
||||||
|
<div id="overtimeCard"
|
||||||
|
style="background: rgba(150,150,150,0.05); padding: 25px; border-radius: 10px; margin-bottom: 25px; border: 1px solid rgba(150,150,150,0.2); border-left: 6px solid #007bff;">
|
||||||
|
|
||||||
|
<div style="margin-bottom: 20px;">
|
||||||
|
<span style="color: #888; font-size: 0.8rem; font-weight: bold; text-transform: uppercase;">Aktueller
|
||||||
|
Stand</span>
|
||||||
|
<h2 id="standAnzeige" style="margin: 5px 0 0 0; font-size: 2rem;">Lädt...</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="overtimeForm" style="display: none; gap: 15px; flex-wrap: wrap; align-items: flex-end;">
|
||||||
|
<div style="display: flex; flex-direction: column; gap: 5px;">
|
||||||
|
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Datum</label>
|
||||||
|
<input type="date" id="ot-date" required
|
||||||
|
style="padding: 8px; border: 1px solid rgba(150,150,150,0.3); border-radius: 4px; background: rgba(150,150,150,0.1); color: inherit;">
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; flex-direction: column; gap: 5px;">
|
||||||
|
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Minuten</label>
|
||||||
|
<input type="number" id="ot-minutes" placeholder="480" required
|
||||||
|
style="width: 100px; padding: 8px; border: 1px solid rgba(150,150,150,0.3); border-radius: 4px; background: rgba(150,150,150,0.1); color: inherit;">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Grund</label>
|
||||||
|
<select id="ot-reason" required>
|
||||||
|
<option value="">Bitte wählen</option>
|
||||||
|
<option value="Abbau">Abbau</option>
|
||||||
|
<option value="Aufbau">Aufbau</option>
|
||||||
|
<option value="Anderes">Anderes</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button type="submit"
|
||||||
|
style="background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; font-weight: bold; cursor: pointer;">
|
||||||
|
Eintrag speichern
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/AjaxMethods.js"></script>
|
||||||
|
<script src="/js/AjaxRenderTables.js"></script>
|
||||||
|
<script src="/js/ajaxApi/ZeiterfassungAjaxMethods.js"></script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const standAnzeige = document.getElementById('standAnzeige');
|
||||||
|
const overtimeForm = document.getElementById('overtimeForm');
|
||||||
|
|
||||||
|
function formatStand(gesamtMinuten) {
|
||||||
|
const stunden = Math.trunc(gesamtMinuten / 60);
|
||||||
|
const minuten = Math.abs(gesamtMinuten % 60);
|
||||||
|
return `${stunden}h ${minuten}min`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ladeStand() {
|
||||||
|
try {
|
||||||
|
const data = await getOvertimeStats();
|
||||||
|
|
||||||
|
standAnzeige.textContent = formatStand(data.gesamtMinuten);
|
||||||
|
standAnzeige.style.color = data.gesamtMinuten >= 0 ? '#28a745' : '#dc3545';
|
||||||
|
|
||||||
|
overtimeForm.style.display = data.istBerechtigt ? 'flex' : 'none';
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
standAnzeige.textContent = 'Fehler beim Laden';
|
||||||
|
console.error(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
overtimeForm.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
const datum = document.getElementById('ot-date').value;
|
||||||
|
const minuten = document.getElementById('ot-minutes').value;
|
||||||
|
const grund = document.getElementById('ot-reason').value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await addOvertimeEntry(datum, minuten, grund);
|
||||||
|
e.target.reset();
|
||||||
|
document.getElementById('ot-date').value = new Date().toISOString().slice(0, 10);
|
||||||
|
await ladeStand();
|
||||||
|
} catch (err) {
|
||||||
|
alert('Fehler beim Speichern: ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('ot-date').value = new Date().toISOString().slice(0, 10);
|
||||||
|
ladeStand();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/.htaccess</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/api/get.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/api/upload.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/favicon.ico</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/index.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>weekly</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/modules/ConsoleLog.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/api_tester.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/backend_request_chart.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/backend_request_logs.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/berichte_arbeit.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/berichte_arbeit_gen.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/data_info.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/home_info.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/links.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/logout.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/personal_request_logs.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/public_request_chart.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/public_request_logs.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/services_control.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/tabellen.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/user_control.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/variablen_control.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/services/weather_chart.php</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/sitemap.xml</loc>
|
||||||
|
<lastmod>2026-03-03</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
<url>
|
||||||
|
<loc>http://backend.blackpi.ipv64.net/style.css</loc>
|
||||||
|
<lastmod>2026-03-02</lastmod>
|
||||||
|
<changefreq>daily</changefreq>
|
||||||
|
<priority>1.0</priority>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
||||||
+498
-3
@@ -4,6 +4,7 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
@@ -17,14 +18,29 @@ header {
|
|||||||
.main {
|
.main {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: hidden;
|
height: calc(100vh - 60px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-header {
|
||||||
|
background-color: #007bff;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 20px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
width: 200px;
|
width: 240px;
|
||||||
background-color: #f4f4f4;
|
background-color: #f4f4f4;
|
||||||
border-right: 1px solid #ccc;
|
border-right: 1px solid #ccc;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
|
overflow-y: auto;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar button {
|
.sidebar button {
|
||||||
@@ -46,7 +62,10 @@ header {
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: auto;
|
padding: 15px;
|
||||||
|
|
||||||
|
overflow-y: auto;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dark Mode Styles */
|
/* Dark Mode Styles */
|
||||||
@@ -861,6 +880,17 @@ body.dark-mode .user-table .btn-primary:hover {
|
|||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-edit {
|
||||||
|
background-color: #32b844;
|
||||||
|
color: white;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ===== Toggle Switch ===== */
|
/* ===== Toggle Switch ===== */
|
||||||
|
|
||||||
.toggle-card {
|
.toggle-card {
|
||||||
@@ -955,3 +985,468 @@ body.dark-mode .info-key {
|
|||||||
body.dark-mode .info-value {
|
body.dark-mode .info-value {
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===== Datenbank Struktur Tabelle ===== */
|
||||||
|
|
||||||
|
.db-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 20px;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.db-table thead {
|
||||||
|
background-color: var(--btn-bg);
|
||||||
|
color: var(--btn-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.db-table th,
|
||||||
|
.db-table td {
|
||||||
|
padding: 12px 15px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid var(--card-border);
|
||||||
|
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.db-table td:nth-child(2) {
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.db-table tr:hover {
|
||||||
|
background-color: rgba(0, 123, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Alternierende Zeilen */
|
||||||
|
.db-table tr:nth-child(even) {
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark Mode */
|
||||||
|
body.dark-mode .db-table thead {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .db-table tr:hover {
|
||||||
|
background-color: rgba(0, 123, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .db-table tr:nth-child(even) {
|
||||||
|
background-color: #1e1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar,
|
||||||
|
.content::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar-thumb,
|
||||||
|
.content::-webkit-scrollbar-thumb {
|
||||||
|
background: #888;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar::-webkit-scrollbar-thumb:hover,
|
||||||
|
.content::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .sidebar::-webkit-scrollbar-thumb,
|
||||||
|
body.dark-mode .content::-webkit-scrollbar-thumb {
|
||||||
|
background: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Optional: schöner Dropdown Pfeil */
|
||||||
|
select {
|
||||||
|
appearance: none;
|
||||||
|
background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg fill='%23666' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: right 10px center;
|
||||||
|
background-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark Mode Pfeil */
|
||||||
|
body.dark-mode select {
|
||||||
|
background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg fill='%23ccc' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 5 5-5z'/%3E%3C/svg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Vergabe Formular ===== */
|
||||||
|
.vergabe-form {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
border-left: 5px solid var(--btn-bg);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop-First Grid Layout */
|
||||||
|
.vergabe-grid {
|
||||||
|
display: grid;
|
||||||
|
/* Nutzt minmax, damit die Datumsfelder auf kleineren Desktop-Monitoren nicht zerquetschen */
|
||||||
|
grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 1.3fr 2fr auto;
|
||||||
|
gap: 15px;
|
||||||
|
align-items: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vergabe-grid .form-group {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vergabe-grid input,
|
||||||
|
.btn-submit-vergabe {
|
||||||
|
width: 100%;
|
||||||
|
/* Wichtig für Responsiveness */
|
||||||
|
padding: 10px 16px;
|
||||||
|
font-size: 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode input[type="date"] {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dedizierter Speicher-Button Style */
|
||||||
|
.btn-submit-vergabe {
|
||||||
|
background: var(--btn-add-bg);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
height: 43px;
|
||||||
|
/* Gleicht die Höhe der Inputs inklusive Padding/Border perfekt aus */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: background-color 0.2s ease, transform 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit-vergabe:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit-vergabe:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Mobile Optimierung (Tablets & Smartphones) ===== */
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.vergabe-grid {
|
||||||
|
/* Schaltet auf Mobilgeräten in eine saubere 1-spaltige Liste um */
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
/* Schafft vertikalen Abstand zwischen den Feldern */
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit-vergabe {
|
||||||
|
margin-top: 5px;
|
||||||
|
height: 48px;
|
||||||
|
/* Größere Touch-Fläche für Smartphones */
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Globale Mobile Anpassungen ===== */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
|
||||||
|
/* 1. Haupt-Layout untereinander brechen lassen */
|
||||||
|
.main {
|
||||||
|
flex-direction: column;
|
||||||
|
height: calc(100vh - 60px);
|
||||||
|
/* Behält die feste Gesamthöhe bei */
|
||||||
|
overflow-y: auto;
|
||||||
|
/* Erlaubt das Scrollen der gesamten Seite falls nötig */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2. Sidebar nimmt volle Breite ein und passt sich dem Inhalt an */
|
||||||
|
.sidebar {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
/* Keine feste Höhe mehr auf Mobile */
|
||||||
|
border-right: none;
|
||||||
|
border-bottom: 1px solid #333;
|
||||||
|
/* Trennlinie nach unten statt nach rechts */
|
||||||
|
overflow-y: visible;
|
||||||
|
/* Scrollbar hier deaktivieren */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3. Inhaltsbereich nimmt den Rest des Platzes ein */
|
||||||
|
.content {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
overflow-y: visible;
|
||||||
|
/* Verhindert doppelte Scrollbalken */
|
||||||
|
padding: 15px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4. Das Vergabe-Formular bricht sauber in eine Spalte um */
|
||||||
|
.vergabe-grid {
|
||||||
|
grid-template-columns: 1fr !important;
|
||||||
|
/* Erzwingt eine Spalte */
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 5. Inputs und Buttons nehmen die volle Breite der Box ein */
|
||||||
|
.vergabe-grid input,
|
||||||
|
.btn-submit-vergabe,
|
||||||
|
.vergabe-grid button {
|
||||||
|
width: 100% !important;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Optional: Header-Buttons (Logout / Light Mode) für Mobile optimieren, falls sie überlappen */
|
||||||
|
#darkModeToggle,
|
||||||
|
#logoutButton {
|
||||||
|
position: static;
|
||||||
|
/* Entfernt absolute Positionierung im mobilen Header */
|
||||||
|
margin: 5px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Mobile Optimierung für die Vergabe-Tabelle ===== */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
|
||||||
|
/* Verstecke die normale Tabellen-Überschrift */
|
||||||
|
.mobile-responsive-table thead {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mache aus der Tabelle ein Block-Layout */
|
||||||
|
.mobile-responsive-table,
|
||||||
|
.mobile-responsive-table tbody,
|
||||||
|
.mobile-responsive-table tr,
|
||||||
|
.mobile-responsive-table td {
|
||||||
|
display: block;
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Jede Zeile wird zu einer schicken Card */
|
||||||
|
.mobile-responsive-table tr {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
padding: 10px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Einzelne Zellen nebeneinander/untereinander stylen */
|
||||||
|
.mobile-responsive-table td {
|
||||||
|
text-align: right !important;
|
||||||
|
padding: 8px 10px !important;
|
||||||
|
border-bottom: 1px solid var(--card-border);
|
||||||
|
position: relative;
|
||||||
|
white-space: normal !important;
|
||||||
|
/* Erlaubt Textumbruch auf Handys */
|
||||||
|
overflow: visible !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-responsive-table td:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-top: 12px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Die Beschriftung (z.B. "Was:") links einblenden */
|
||||||
|
.mobile-responsive-table td::before {
|
||||||
|
content: attr(data-label);
|
||||||
|
position: absolute;
|
||||||
|
left: 10px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lösch-Button auf Mobile über die gesamte Breite strecken für leichtere Bedienung */
|
||||||
|
.mobile-responsive-table .btn-delete {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===== Optimiertes Firmenberichte Erfassungsformular ===== */
|
||||||
|
|
||||||
|
.berichte-container {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--card-border);
|
||||||
|
border-top: 4px solid #007bff;
|
||||||
|
/* Eleganter blauer Akzentstreifen oben statt links */
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 30px;
|
||||||
|
max-width: 500px;
|
||||||
|
/* Kompakt und perfekt lesbar auf Monitoren */
|
||||||
|
margin: 40px auto;
|
||||||
|
/* Schön zentriert mit Luft nach oben/unten */
|
||||||
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tiefenwirkung für den Dark Mode */
|
||||||
|
body.dark-mode .berichte-container {
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
|
||||||
|
background: #161616;
|
||||||
|
/* Passt sich perfekt deiner CSS-Variable an */
|
||||||
|
}
|
||||||
|
|
||||||
|
.berichte-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.berichte-form .form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.berichte-form .form-group label {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.8px;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Einheitlicher, moderner Look für ALLE Input-Typen */
|
||||||
|
.berichte-form input[type="text"],
|
||||||
|
.berichte-form input[type="time"],
|
||||||
|
.berichte-form input[type="date"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 16px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
border: 1px solid var(--input-border);
|
||||||
|
color: var(--input-text);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: border-color 0.2s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Behebt das Problem mit den grellweißen Zeit/Datumsfeldern im Dark Mode */
|
||||||
|
body.dark-mode .berichte-form input[type="time"],
|
||||||
|
body.dark-mode .berichte-form input[type="date"] {
|
||||||
|
color-scheme: dark;
|
||||||
|
/* Zwingt den Browser, das native Dropdown dunkel zu machen */
|
||||||
|
background: #222;
|
||||||
|
border-color: #444;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fokus-Effekt (weicher blauer Schein) */
|
||||||
|
.berichte-form input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #007bff;
|
||||||
|
box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .berichte-form input:focus {
|
||||||
|
box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Vollbreiter, moderner Absende-Button */
|
||||||
|
.btn-submit-bericht {
|
||||||
|
width: 100%;
|
||||||
|
background: #28a745;
|
||||||
|
/* Kräftiges Success-Grün */
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 14px;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit-bericht:hover {
|
||||||
|
background: #218838;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 6px 15px rgba(40, 167, 69, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-submit-bericht:active {
|
||||||
|
transform: scale(0.98);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Kleine Bildschirme (Smartphones) */
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.berichte-container {
|
||||||
|
margin: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete-wrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete-suggestions {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid var(--input-border);
|
||||||
|
border-top: none;
|
||||||
|
max-height: 180px;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 1000;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete-suggestions div {
|
||||||
|
padding: 8px 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete-suggestions div:hover,
|
||||||
|
.autocomplete-suggestions div.active {
|
||||||
|
background: rgba(0, 123, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
body.dark-mode .autocomplete-suggestions div:hover,
|
||||||
|
body.dark-mode .autocomplete-suggestions div.active {
|
||||||
|
background: rgba(0, 123, 255, 0.25);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Starte automatischen Merge- und Tag-Prozess..."
|
||||||
|
|
||||||
|
git config core.filemode false
|
||||||
|
|
||||||
|
echo "Aktualisiere lokale Branches vom Remote..."
|
||||||
|
git fetch --all --quiet
|
||||||
|
|
||||||
|
echo "Wechsle zu main..."
|
||||||
|
git checkout main --quiet
|
||||||
|
git pull origin main --quiet
|
||||||
|
|
||||||
|
echo "Merge: main -> dev..."
|
||||||
|
git checkout dev --quiet
|
||||||
|
git pull origin dev --quiet || true
|
||||||
|
git merge main --no-ff -m "Automated merge from main to dev" --quiet
|
||||||
|
git push origin dev --quiet
|
||||||
|
|
||||||
|
echo "Merge: dev -> live..."
|
||||||
|
git checkout live --quiet
|
||||||
|
git pull origin live --quiet || true
|
||||||
|
git merge dev --no-ff -m "Automated merge from dev to live" --quiet
|
||||||
|
git push origin live --quiet
|
||||||
|
|
||||||
|
TAG_NAME="v$(date +'%Y.%m.%d-%H%M')"
|
||||||
|
|
||||||
|
echo " Erstelle Tag: $TAG_NAME..."
|
||||||
|
git tag -a "$TAG_NAME" -m "Automated release tag $TAG_NAME"
|
||||||
|
git push origin "$TAG_NAME" --quiet
|
||||||
|
|
||||||
|
git checkout main --quiet
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "========================================================"
|
||||||
|
echo "✅ FERTIG! Alles sauber durchgelaufen."
|
||||||
|
echo "📦 Neuer Release-Tag gepusht: $TAG_NAME"
|
||||||
|
echo "========================================================"
|
||||||
Reference in new issue
Block a user