Update: DatabaseConnect

This commit is contained in:
bruno committed 2026-01-12 14:01:04 +01:00
1 parent 24f57ec757
commit e5605a6327
11 files changed
+604 -715

No files matched your search

+73 -73
View File
@@ -1,73 +1,73 @@
#!/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
#!/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
+45 -45
View File
@@ -1,46 +1,46 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"workbench.colorTheme": "Catppuccin Macchiato",
"workbench.colorCustomizations": {
"activityBar.background": "#00aeff75",
"activityBar.foreground": "#000000",
"breadcrumb.foreground": "#FFFFFF",
},
"editor.renderWhitespace": "all",
"editor.smoothScrolling": true,
"editor.fontSize": 14,
"editor.formatOnSave": true,
"editor.minimap.enabled": true,
"editor.minimap.scale": 2,
"editor.minimap.side": "right",
"editor.minimap.maxColumn": 100,
"editor.minimap.renderCharacters": true,
"editor.minimap.showSlider": "always",
"files.autoSave": "off",
"files.autoSaveDelay": 3000,
"window.title": "PUBLIC",
"workbench.editor.wrapTabs": true,
},
"extensions": {
"recommendations": [
"oderwat.indent-rainbow",
"pranaygp.vscode-css-peek",
"wayou.vscode-todo-highlight",
"mrmlnc.vscode-mustache",
"fabiospampinato.vscode-highlight",
"junstyle.php-cs-fixer",
"mtea.gettext-editor",
"neilbrayfield.php-docblocker",
"bmewburn.vscode-intelephense-client",
"mohamed-ali.html-css-class-completion",
"rifi2k.format-html-in-php",
"mrorz.language-gettext",
"voldemortensen.rainbow-tags",
]
}
{
"folders": [
{
"path": "."
}
],
"settings": {
"workbench.colorTheme": "Catppuccin Macchiato",
"workbench.colorCustomizations": {
"activityBar.background": "#00aeff75",
"activityBar.foreground": "#000000",
"breadcrumb.foreground": "#FFFFFF",
},
"editor.renderWhitespace": "all",
"editor.smoothScrolling": true,
"editor.fontSize": 14,
"editor.formatOnSave": true,
"editor.minimap.enabled": true,
"editor.minimap.scale": 2,
"editor.minimap.side": "right",
"editor.minimap.maxColumn": 100,
"editor.minimap.renderCharacters": true,
"editor.minimap.showSlider": "always",
"files.autoSave": "off",
"files.autoSaveDelay": 3000,
"window.title": "PUBLIC",
"workbench.editor.wrapTabs": true,
},
"extensions": {
"recommendations": [
"oderwat.indent-rainbow",
"pranaygp.vscode-css-peek",
"wayou.vscode-todo-highlight",
"mrmlnc.vscode-mustache",
"fabiospampinato.vscode-highlight",
"junstyle.php-cs-fixer",
"mtea.gettext-editor",
"neilbrayfield.php-docblocker",
"bmewburn.vscode-intelephense-client",
"mohamed-ali.html-css-class-completion",
"rifi2k.format-html-in-php",
"mrorz.language-gettext",
"voldemortensen.rainbow-tags",
]
}
}
+50 -50
View File
@@ -1,50 +1,50 @@
Use Cases:
# DatabaseController:
DatabaseShowWithFK(
"tabelle",
$fkMap,
"spaltenname1, spaltenname2, spaltenname3",
"spalte = ?",
$var1 // wer für spalte
);
DatabaseShowWithFK(
"Berufsschulberichte",
$fkMap
);
DatabaseShow(
"tabelle",
"spaltenname1, spaltenname2, spaltenname3"
"spalte = ?",
$var1 // wert für spalte
);
DatabaseShow(
"tabelle",
);
DatabaseInsert(
"tabelle",
"spaltenname1, spaltenname2, spaltenname3",
$var1,
$var2,
$var3
);
DatabaseDelete(
"tabelle",
"spalte = ?",
$var1 // wert für spalte
);
DatabaseUpdate(
"tabelle",
"username = ?, email = ?",
"id = ?",
"NeuerName",
"neu@mail.de",
$var1 // wert für id
);
Use Cases:
# DatabaseController:
DatabaseShowWithFK(
"tabelle",
$fkMap,
"spaltenname1, spaltenname2, spaltenname3",
"spalte = ?",
$var1 // wer für spalte
);
DatabaseShowWithFK(
"Berufsschulberichte",
$fkMap
);
DatabaseShow(
"tabelle",
"spaltenname1, spaltenname2, spaltenname3"
"spalte = ?",
$var1 // wert für spalte
);
DatabaseShow(
"tabelle",
);
DatabaseInsert(
"tabelle",
"spaltenname1, spaltenname2, spaltenname3",
$var1,
$var2,
$var3
);
DatabaseDelete(
"tabelle",
"spalte = ?",
$var1 // wert für spalte
);
DatabaseUpdate(
"tabelle",
"username = ?, email = ?",
"id = ?",
"NeuerName",
"neu@mail.de",
$var1 // wert für id
);
+27 -12
View File
@@ -1,25 +1,40 @@
<?php
function db_connect() {
$local = true;
$servers = [
'remote' => '10.233.1.244',
'local' => '100.123.136.86'
'dev' => [
'hostaddr' => '10.233.1.29',
'username' => 'worker',
'password' => 'bBHofurUJWKzPE8Z',
'database' => 'DEV',
],
'vpn' => [
'hostaddr' => '100.123.136.86',
'username' => 'worker',
'password' => 'bBHofurUJWKzPE8Z',
'database' => 'DEV',
],
'live' => [
'hostaddr' => '10.233.1.244',
'username' => 'worker',
'password' => 'bBHofurUJWKzPE8Z',
'database' => 'DEV',
]
];
$username = "worker";
$password = "bBHofurUJWKzPE8Z";
$dbname = "DEV";
$enviroment = 'live';
$host = $local ? $servers['local'] : $servers['remote'];
$conn = new mysqli($host, $username, $password, $dbname);
$conn = new mysqli(
$servers[$enviroment]['hostaddr'],
$servers[$enviroment]['username'],
$servers[$enviroment]['password'],
$servers[$enviroment]['database'],
);
if ($conn->connect_error) {
throw new Exception("Datenbankverbindung fehlgeschlagen: " . $conn->connect_error);
throw new Exception('Connection Error: ' . $conn->connect_error);
}
$conn->set_charset("utf8mb4");
return $conn;
}
+14 -14
View File
@@ -1,15 +1,15 @@
<?php
function ConsoleLog(...$vars) {
echo "<script>";
foreach ($vars as $index => $value) {
$data = [
"Index" => $index,
"Value" => $value
];
echo "console.log(" . json_encode($data) . ");";
}
echo "</script>";
<?php
function ConsoleLog(...$vars) {
echo "<script>";
foreach ($vars as $index => $value) {
$data = [
"Index" => $index,
"Value" => $value
];
echo "console.log(" . json_encode($data) . ");";
}
echo "</script>";
}
@@ -1,124 +1,119 @@
<?php
include_once '../../../controller/DatabaseController.php';
include_once '../../../controller/DatabaseConnect.php';
$berudata = DatabaseShowWithFK(
"Berufsschulberichte",
$fkMap
);
$fach = DatabaseShow(
"Fach",
"ID, FACH"
);
$raum = DatabaseShow(
"Raum",
"ID, RAUM_NR"
);
$lehrer = DatabaseShow(
"Lehrer",
"ID, NAME"
);
$json = json_encode([$fach, $raum, $lehrer], JSON_UNESCAPED_UNICODE);
?>
<!DOCTYPE html>
<html lang="de">
<body>
<h2>Berufsschulbericht</h2>
<form method="post">
<label for="datum">Datum:</label>
<input type="date" name="datum" id="datum_id">
<?php for ($i = 1; $i <= 8; $i++): ?>
<fieldset style="margin-bottom:20px; padding:10px;">
<legend>Stunde <?= $i ?></legend>
<label for="fach_<?= $i ?>">Fach:</label>
<select name="stunden[<?= $i ?>][fach_id]" id="fach_<?= $i ?>"></select>
<label for="raum_<?= $i ?>">Raum:</label>
<select name="stunden[<?= $i ?>][raum_id]" id="raum_<?= $i ?>"></select>
<label for="lehrer_<?= $i ?>">Lehrer:</label>
<select name="stunden[<?= $i ?>][lehrer_id]" id="lehrer_<?= $i ?>"></select>
<label for="inhalt_<?= $i ?>">Inhalt:</label>
<input type="text" name="stunden[<?= $i ?>][inhalt_text]" id="inhalt_<?= $i ?>">
</fieldset>
<?php endfor; ?>
<button type="submit">Absenden</button>
</form>
<script>
const daten = <?= $json ?>;
const faecher = daten[0];
const raeume = daten[1];
const lehrer = daten[2];
function fillSelect(selectId, data, labelKey) {
const select = document.getElementById(selectId);
select.innerHTML = '<option value="">Bitte wählen</option>';
data.forEach(item => {
const option = document.createElement('option');
option.value = item.ID;
option.textContent = item[labelKey];
select.appendChild(option);
});
}
for (let i = 1; i <= 8; i++) {
fillSelect('fach_' + i, faecher, 'FACH');
fillSelect('raum_' + i, raeume, 'RAUM_NR');
fillSelect('lehrer_' + i, lehrer, 'NAME');
}
</script>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$datum = $_POST['datum'] ?? null;
$werte = [];
for ($i = 1; $i <= 8; $i++) {
$stunde = $_POST['stunden'][$i] ?? [];
$fach = !empty($stunde['fach_id']) ? $stunde['fach_id'] : null;
$lehrer = !empty($stunde['lehrer_id'])? $stunde['lehrer_id'] : null;
$raum = !empty($stunde['raum_id']) ? $stunde['raum_id'] : null;
$inhalt = !empty($stunde['inhalt_text']) ? $stunde['inhalt_text'] : null;
$werte[] = $fach;
$werte[] = $lehrer;
$werte[] = $raum;
$werte[] = $inhalt;
}
}
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",
$datum,
...$werte
);
?>
</body>
<?php
include_once '../../../controller/DatabaseController.php';
include_once '../../../controller/DatabaseConnect.php';
$fach = DatabaseShow(
"Fach",
"ID, FACH"
);
$raum = DatabaseShow(
"Raum",
"ID, RAUM_NR"
);
$lehrer = DatabaseShow(
"Lehrer",
"ID, NAME"
);
$json = json_encode([$fach, $raum, $lehrer], JSON_UNESCAPED_UNICODE);
?>
<!DOCTYPE html>
<html lang="de">
<body>
<h2>Berufsschulbericht</h2>
<form method="post">
<label for="datum">Datum:</label>
<input type="date" name="datum" id="datum_id">
<?php for ($i = 1; $i <= 8; $i++): ?>
<fieldset style="margin-bottom:20px; padding:10px;">
<legend>Stunde <?= $i ?></legend>
<label for="fach_<?= $i ?>">Fach:</label>
<select name="stunden[<?= $i ?>][fach_id]" id="fach_<?= $i ?>"></select>
<label for="raum_<?= $i ?>">Raum:</label>
<select name="stunden[<?= $i ?>][raum_id]" id="raum_<?= $i ?>"></select>
<label for="lehrer_<?= $i ?>">Lehrer:</label>
<select name="stunden[<?= $i ?>][lehrer_id]" id="lehrer_<?= $i ?>"></select>
<label for="inhalt_<?= $i ?>">Inhalt:</label>
<input type="text" name="stunden[<?= $i ?>][inhalt_text]" id="inhalt_<?= $i ?>">
</fieldset>
<?php endfor; ?>
<button type="submit">Absenden</button>
</form>
<script>
const daten = <?= $json ?>;
const faecher = daten[0];
const raeume = daten[1];
const lehrer = daten[2];
function fillSelect(selectId, data, labelKey) {
const select = document.getElementById(selectId);
select.innerHTML = '<option value="">Bitte wählen</option>';
data.forEach(item => {
const option = document.createElement('option');
option.value = item.ID;
option.textContent = item[labelKey];
select.appendChild(option);
});
}
for (let i = 1; i <= 8; i++) {
fillSelect('fach_' + i, faecher, 'FACH');
fillSelect('raum_' + i, raeume, 'RAUM_NR');
fillSelect('lehrer_' + i, lehrer, 'NAME');
}
</script>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$datum = $_POST['datum'] ?? null;
$werte = [];
for ($i = 1; $i <= 8; $i++) {
$stunde = $_POST['stunden'][$i] ?? [];
$fach = !empty($stunde['fach_id']) ? $stunde['fach_id'] : null;
$lehrer = !empty($stunde['lehrer_id'])? $stunde['lehrer_id'] : null;
$raum = !empty($stunde['raum_id']) ? $stunde['raum_id'] : null;
$inhalt = !empty($stunde['inhalt_text']) ? $stunde['inhalt_text'] : null;
$werte[] = $fach;
$werte[] = $lehrer;
$werte[] = $raum;
$werte[] = $inhalt;
}
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",
$datum,
...$werte
);
}
?>
</body>
</html>
+77 -77
View File
@@ -1,78 +1,78 @@
<?php
include_once '../../controller/DatabaseConnect.php';
$conn = db_connect();
// Datum aus Formular
$startDatum = $_GET['start'] ?? null;
$endDatum = $_GET['end'] ?? null;
if (!$startDatum || !$endDatum) {
die("<div class='error'>Bitte Start- und Enddatum angeben.</div>");
}
// Datenbankabfrage
$berichteQuery = "SELECT `DATUM`, `PROZESS_1`, `PROZESS_2`, `PROZESS_3`, `PROZESS_4` FROM Firmenberichte WHERE `DATUM` BETWEEN '$startDatum' AND '$endDatum' ORDER BY `DATUM` ASC";
$result = $conn->query($berichteQuery);
$berichteArray = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$berichteArray[] = $row;
}
} else {
die("<div class='error'>Keine Berichte für den angegebenen Zeitraum gefunden.</div>");
}
$Einzelstunden = "2";
$Gesamtstunden = "8";
// Daten für FDF zusammenstellen
$data = [
'Text1' => '',
'Text2' => $berichteArray[0]['DATUM'],
'Text3' => end($berichteArray)['DATUM'],
'Text4' => 'Eckhardt',
'Text5' => 'Bruno Renato',
'Text6' => '1',
];
$fieldIndex = 7;
foreach ($berichteArray as $bericht) {
for ($i = 1; $i <= 4; $i++) {
$data["Text$fieldIndex"] = $bericht["PROZESS_$i"];
$fieldIndex++;
$data["Text$fieldIndex"] = $Einzelstunden;
$fieldIndex++;
}
$data["Text$fieldIndex"] = $Gesamtstunden;
$fieldIndex++;
}
// FDF erstellen
$fdf = "%FDF-1.2\n";
$fdf .= "1 0 obj\n<<\n/FDF << /Fields [\n";
foreach ($data as $field => $value) {
$value = str_replace(['(', ')'], ['\(', '\)'], $value);
$fdf .= "<< /T ($field) /V ($value) >>\n";
}
$fdf .= "] >> >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF";
$fdfFile = tempnam(sys_get_temp_dir(), 'fdf_') . '.fdf';
file_put_contents($fdfFile, $fdf);
$inputPdf = 'ausbildung-ausbildungsnachweis.pdf';
$outputPdf = __DIR__ . '/ausbildungsnachweis_' . $berichteArray[0]['DATUM'] . '-' . end($berichteArray)['DATUM'] . '.pdf';
exec("pdftk $inputPdf fill_form $fdfFile output $outputPdf flatten");
unlink($fdfFile);
$conn->close();
// Link zum fertigen PDF anzeigen
<?php
include_once '../../controller/DatabaseConnect.php';
$conn = db_connect();
// Datum aus Formular
$startDatum = $_GET['start'] ?? null;
$endDatum = $_GET['end'] ?? null;
if (!$startDatum || !$endDatum) {
die("<div class='error'>Bitte Start- und Enddatum angeben.</div>");
}
// Datenbankabfrage
$berichteQuery = "SELECT `DATUM`, `PROZESS_1`, `PROZESS_2`, `PROZESS_3`, `PROZESS_4` FROM Firmenberichte WHERE `DATUM` BETWEEN '$startDatum' AND '$endDatum' ORDER BY `DATUM` ASC";
$result = $conn->query($berichteQuery);
$berichteArray = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$berichteArray[] = $row;
}
} else {
die("<div class='error'>Keine Berichte für den angegebenen Zeitraum gefunden.</div>");
}
$Einzelstunden = "2";
$Gesamtstunden = "8";
// Daten für FDF zusammenstellen
$data = [
'Text1' => '',
'Text2' => $berichteArray[0]['DATUM'],
'Text3' => end($berichteArray)['DATUM'],
'Text4' => 'Eckhardt',
'Text5' => 'Bruno Renato',
'Text6' => '1',
];
$fieldIndex = 7;
foreach ($berichteArray as $bericht) {
for ($i = 1; $i <= 4; $i++) {
$data["Text$fieldIndex"] = $bericht["PROZESS_$i"];
$fieldIndex++;
$data["Text$fieldIndex"] = $Einzelstunden;
$fieldIndex++;
}
$data["Text$fieldIndex"] = $Gesamtstunden;
$fieldIndex++;
}
// FDF erstellen
$fdf = "%FDF-1.2\n";
$fdf .= "1 0 obj\n<<\n/FDF << /Fields [\n";
foreach ($data as $field => $value) {
$value = str_replace(['(', ')'], ['\(', '\)'], $value);
$fdf .= "<< /T ($field) /V ($value) >>\n";
}
$fdf .= "] >> >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF";
$fdfFile = tempnam(sys_get_temp_dir(), 'fdf_') . '.fdf';
file_put_contents($fdfFile, $fdf);
$inputPdf = 'ausbildung-ausbildungsnachweis.pdf';
$outputPdf = __DIR__ . '/ausbildungsnachweis_' . $berichteArray[0]['DATUM'] . '-' . end($berichteArray)['DATUM'] . '.pdf';
exec("pdftk $inputPdf fill_form $fdfFile output $outputPdf flatten");
unlink($fdfFile);
$conn->close();
// Link zum fertigen PDF anzeigen
echo "<div class='message success'>PDF erfolgreich erstellt! <a href='$outputPdf' target='_blank'>Hier öffnen</a></div>";
+82 -82
View File
@@ -1,83 +1,83 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Bericht erstellen</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f5f5f5;
padding: 50px;
}
form {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 400px;
margin: auto;
}
label {
display: block;
margin-top: 15px;
font-weight: bold;
}
input[type="date"] {
width: 100%;
padding: 8px;
margin-top: 5px;
}
button {
margin-top: 20px;
padding: 10px 20px;
background: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
.message {
margin-top: 20px;
padding: 10px;
border-radius: 5px;
}
.success {
background: #d4edda;
color: #155724;
}
.error {
background: #f8d7da;
color: #721c24;
}
</style>
</head>
<body>
<h2>Ausbildungsbericht erstellen</h2>
<form method="GET" action="generate.php">
<label for="start">Startdatum:</label>
<input type="date" id="start" name="start" required>
<label for="end">Enddatum:</label>
<input type="date" id="end" name="end" required>
<button type="submit">Bericht erstellen</button>
</form>
</body>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Bericht erstellen</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f5f5f5;
padding: 50px;
}
form {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 400px;
margin: auto;
}
label {
display: block;
margin-top: 15px;
font-weight: bold;
}
input[type="date"] {
width: 100%;
padding: 8px;
margin-top: 5px;
}
button {
margin-top: 20px;
padding: 10px 20px;
background: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
.message {
margin-top: 20px;
padding: 10px;
border-radius: 5px;
}
.success {
background: #d4edda;
color: #155724;
}
.error {
background: #f8d7da;
color: #721c24;
}
</style>
</head>
<body>
<h2>Ausbildungsbericht erstellen</h2>
<form method="GET" action="generate.php">
<label for="start">Startdatum:</label>
<input type="date" id="start" name="start" required>
<label for="end">Enddatum:</label>
<input type="date" id="end" name="end" required>
<button type="submit">Bericht erstellen</button>
</form>
</body>
</html>
+106 -106
View File
@@ -1,107 +1,107 @@
<?php
include_once '../../controller/DatabaseConnect.php';
$conn = db_connect();
$berichte="SELECT `DATUM`, `PROZESS_1`, `PROZESS_2`, `PROZESS_3`, `PROZESS_4` FROM Firmenberichte WHERE `DATUM` BETWEEN '2025-12-08' AND '2025-12-12'";
$result = $conn->query($berichte);
$berichteArray = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$berichteArray[] = $row;
}
}
$Einzelstunden = "2";
$Gesamtstunden = "8";
$data = [
'Text1' => '', // Nr
'Text2' => $berichteArray[0]['DATUM'], // Von
'Text3' => $berichteArray[4]['DATUM'], // Bis
'Text4' => 'Eckhardt',
'Text5' => 'Bruno Renato',
'Text6' => '1', //Ausbildungsjahr
'Text7' => $berichteArray[0]['PROZESS_1'], // Prozess
'Text8' => $Einzelstunden, // Einzelstunden
'Text9' => $berichteArray[0]['PROZESS_2'], // Prozess
'Text10' => $Einzelstunden, // Einzelstunden
'Text11' => $berichteArray[0]['PROZESS_3'], // Prozess
'Text12' => $Einzelstunden, // Einzelstunden
'Text13' => $berichteArray[0]['PROZESS_4'], // Prozess
'Text14' => $Einzelstunden, // Einzelstunden
'Text15' => $Gesamtstunden, // Gesamtstunden
'Text16' => $berichteArray[1]['PROZESS_1'],
'Text17' => $Einzelstunden, // Einzelstunden
'Text18' => $berichteArray[1]['PROZESS_2'],
'Text19' => $Einzelstunden, // Einzelstunden
'Text20' => $berichteArray[1]['PROZESS_3'],
'Text21' => $Einzelstunden, // Einzelstunden
'Text22' => $berichteArray[1]['PROZESS_4'],
'Text23' => $Einzelstunden, // Einzelstunden
'Text24' => $Gesamtstunden, // Gesamtstunden
'Text25' => $berichteArray[2]['PROZESS_1'],
'Text26' => $Einzelstunden, // Einzelstunden
'Text27' => $berichteArray[2]['PROZESS_2'],
'Text28' => $Einzelstunden, // Einzelstunden
'Text29' => $berichteArray[2]['PROZESS_3'],
'Text30' => $Einzelstunden, // Einzelstunden
'Text31' => $berichteArray[2]['PROZESS_4'],
'Text32' => $Einzelstunden, // Einzelstunden
'Text33' => $Gesamtstunden, // Gesamtstunden
'Text34' => $berichteArray[3]['PROZESS_1'],
'Text35' => $Einzelstunden, // Einzelstunden
'Text36' => $berichteArray[3]['PROZESS_2'],
'Text37' => $Einzelstunden, // Einzelstunden
'Text38' => $berichteArray[3]['PROZESS_3'],
'Text39' => $Einzelstunden, // Einzelstunden
'Text40' => $berichteArray[3]['PROZESS_4'],
'Text41' => $Einzelstunden, // Einzelstunden
'Text42' => $Gesamtstunden, // Gesamtstunden
'Text43' => $berichteArray[4]['PROZESS_1'],
'Text44' => $Einzelstunden, // Einzelstunden
'Text45' => $berichteArray[4]['PROZESS_2'],
'Text46' => $Einzelstunden, // Einzelstunden
'Text47' => $berichteArray[4]['PROZESS_3'],
'Text48' => $Einzelstunden, // Einzelstunden
'Text49' => $berichteArray[4]['PROZESS_4'],
'Text50' => $Einzelstunden, // Einzelstunden
'Text51' => $Gesamtstunden, // Gesamtstunden
];
$fdf = "%FDF-1.2\n";
$fdf .= "1 0 obj\n<<\n/FDF << /Fields [\n";
foreach ($data as $field => $value) {
$value = str_replace(['(', ')'], ['\(', '\)'], $value);
$fdf .= "<< /T ($field) /V ($value) >>\n";
}
$fdf .= "] >> >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF";
$fdfFile = tempnam(sys_get_temp_dir(), 'fdf_') . '.fdf';
file_put_contents($fdfFile, $fdf);
$inputPdf = 'ausbildung-ausbildungsnachweis.pdf';
$outputPdf = 'ausbildungsnachweis_' . $berichteArray[0]['DATUM'] . '-' . $berichteArray[4]['DATUM'] . '.pdf';
exec("pdftk $inputPdf fill_form $fdfFile output $outputPdf flatten");
unlink($fdfFile);
echo "PDF erfolgreich erstellt!";
<?php
include_once '../../controller/DatabaseConnect.php';
$conn = db_connect();
$berichte="SELECT `DATUM`, `PROZESS_1`, `PROZESS_2`, `PROZESS_3`, `PROZESS_4` FROM Firmenberichte WHERE `DATUM` BETWEEN '2025-12-08' AND '2025-12-12'";
$result = $conn->query($berichte);
$berichteArray = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$berichteArray[] = $row;
}
}
$Einzelstunden = "2";
$Gesamtstunden = "8";
$data = [
'Text1' => '', // Nr
'Text2' => $berichteArray[0]['DATUM'], // Von
'Text3' => $berichteArray[4]['DATUM'], // Bis
'Text4' => 'Eckhardt',
'Text5' => 'Bruno Renato',
'Text6' => '1', //Ausbildungsjahr
'Text7' => $berichteArray[0]['PROZESS_1'], // Prozess
'Text8' => $Einzelstunden, // Einzelstunden
'Text9' => $berichteArray[0]['PROZESS_2'], // Prozess
'Text10' => $Einzelstunden, // Einzelstunden
'Text11' => $berichteArray[0]['PROZESS_3'], // Prozess
'Text12' => $Einzelstunden, // Einzelstunden
'Text13' => $berichteArray[0]['PROZESS_4'], // Prozess
'Text14' => $Einzelstunden, // Einzelstunden
'Text15' => $Gesamtstunden, // Gesamtstunden
'Text16' => $berichteArray[1]['PROZESS_1'],
'Text17' => $Einzelstunden, // Einzelstunden
'Text18' => $berichteArray[1]['PROZESS_2'],
'Text19' => $Einzelstunden, // Einzelstunden
'Text20' => $berichteArray[1]['PROZESS_3'],
'Text21' => $Einzelstunden, // Einzelstunden
'Text22' => $berichteArray[1]['PROZESS_4'],
'Text23' => $Einzelstunden, // Einzelstunden
'Text24' => $Gesamtstunden, // Gesamtstunden
'Text25' => $berichteArray[2]['PROZESS_1'],
'Text26' => $Einzelstunden, // Einzelstunden
'Text27' => $berichteArray[2]['PROZESS_2'],
'Text28' => $Einzelstunden, // Einzelstunden
'Text29' => $berichteArray[2]['PROZESS_3'],
'Text30' => $Einzelstunden, // Einzelstunden
'Text31' => $berichteArray[2]['PROZESS_4'],
'Text32' => $Einzelstunden, // Einzelstunden
'Text33' => $Gesamtstunden, // Gesamtstunden
'Text34' => $berichteArray[3]['PROZESS_1'],
'Text35' => $Einzelstunden, // Einzelstunden
'Text36' => $berichteArray[3]['PROZESS_2'],
'Text37' => $Einzelstunden, // Einzelstunden
'Text38' => $berichteArray[3]['PROZESS_3'],
'Text39' => $Einzelstunden, // Einzelstunden
'Text40' => $berichteArray[3]['PROZESS_4'],
'Text41' => $Einzelstunden, // Einzelstunden
'Text42' => $Gesamtstunden, // Gesamtstunden
'Text43' => $berichteArray[4]['PROZESS_1'],
'Text44' => $Einzelstunden, // Einzelstunden
'Text45' => $berichteArray[4]['PROZESS_2'],
'Text46' => $Einzelstunden, // Einzelstunden
'Text47' => $berichteArray[4]['PROZESS_3'],
'Text48' => $Einzelstunden, // Einzelstunden
'Text49' => $berichteArray[4]['PROZESS_4'],
'Text50' => $Einzelstunden, // Einzelstunden
'Text51' => $Gesamtstunden, // Gesamtstunden
];
$fdf = "%FDF-1.2\n";
$fdf .= "1 0 obj\n<<\n/FDF << /Fields [\n";
foreach ($data as $field => $value) {
$value = str_replace(['(', ')'], ['\(', '\)'], $value);
$fdf .= "<< /T ($field) /V ($value) >>\n";
}
$fdf .= "] >> >>\nendobj\ntrailer\n<< /Root 1 0 R >>\n%%EOF";
$fdfFile = tempnam(sys_get_temp_dir(), 'fdf_') . '.fdf';
file_put_contents($fdfFile, $fdf);
$inputPdf = 'ausbildung-ausbildungsnachweis.pdf';
$outputPdf = 'ausbildungsnachweis_' . $berichteArray[0]['DATUM'] . '-' . $berichteArray[4]['DATUM'] . '.pdf';
exec("pdftk $inputPdf fill_form $fdfFile output $outputPdf flatten");
unlink($fdfFile);
echo "PDF erfolgreich erstellt!";
$conn->close();
+11 -11
View File
@@ -1,12 +1,12 @@
<?php
include_once '../controller/LogController.php';
logging();
$sitemapUrl = "http://blackpi.ipv64.net/sitemap.xml";
$xml = simplexml_load_file($sitemapUrl);
foreach ($xml->url as $urlEntry) {
$loc = (string) $urlEntry->loc;
echo '<div><a href="'.$loc.'" target="_blank">'.$loc.'</a></div>';
<?php
include_once '../controller/LogController.php';
logging();
$sitemapUrl = "http://blackpi.ipv64.net/sitemap.xml";
$xml = simplexml_load_file($sitemapUrl);
foreach ($xml->url as $urlEntry) {
$loc = (string) $urlEntry->loc;
echo '<div><a href="'.$loc.'" target="_blank">'.$loc.'</a></div>';
}
+1 -122
View File
@@ -2,126 +2,5 @@
include_once '../controller/DatabaseController.php';
include_once '../controller/DatabaseConnect.php';
include_once '../controller/DataController.php';
include_once '../moduls/ConsoleLog.php';
$berudata = DatabaseShowWithFK(
"Berufsschulberichte",
$fkMap
);
$fach = DatabaseShow(
"Fach",
"ID, FACH"
);
$raum = DatabaseShow(
"Raum",
"ID, RAUM_NR"
);
$lehrer = DatabaseShow(
"Lehrer",
"ID, NAME"
);
$json = json_encode([$fach, $raum, $lehrer], JSON_UNESCAPED_UNICODE);
?>
<!DOCTYPE html>
<html lang="de">
<body>
<h2>Berufsschulbericht</h2>
<form method="post">
<label for="datum">Datum:</label>
<input type="date" name="datum" id="datum_id">
<?php for ($i = 1; $i <= 8; $i++): ?>
<fieldset style="margin-bottom:20px; padding:10px;">
<legend>Stunde <?= $i ?></legend>
<label for="fach_<?= $i ?>">Fach:</label>
<select name="stunden[<?= $i ?>][fach_id]" id="fach_<?= $i ?>"></select>
<label for="raum_<?= $i ?>">Raum:</label>
<select name="stunden[<?= $i ?>][raum_id]" id="raum_<?= $i ?>"></select>
<label for="lehrer_<?= $i ?>">Lehrer:</label>
<select name="stunden[<?= $i ?>][lehrer_id]" id="lehrer_<?= $i ?>"></select>
<label for="inhalt_<?= $i ?>">Inhalt:</label>
<input type="text" name="stunden[<?= $i ?>][inhalt_text]" id="inhalt_<?= $i ?>">
</fieldset>
<?php endfor; ?>
<button type="submit">Absenden</button>
</form>
<script>
const daten = <?= $json ?>;
const faecher = daten[0];
const raeume = daten[1];
const lehrer = daten[2];
function fillSelect(selectId, data, labelKey) {
const select = document.getElementById(selectId);
select.innerHTML = '<option value="">Bitte wählen</option>';
data.forEach(item => {
const option = document.createElement('option');
option.value = item.ID;
option.textContent = item[labelKey];
select.appendChild(option);
});
}
for (let i = 1; i <= 8; i++) {
fillSelect('fach_' + i, faecher, 'FACH');
fillSelect('raum_' + i, raeume, 'RAUM_NR');
fillSelect('lehrer_' + i, lehrer, 'NAME');
}
</script>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$datum = $_POST['datum'] ?? null;
$werte = [];
for ($i = 1; $i <= 8; $i++) {
$stunde = $_POST['stunden'][$i] ?? [];
$fach = !empty($stunde['fach_id']) ? $stunde['fach_id'] : null;
$lehrer = !empty($stunde['lehrer_id'])? $stunde['lehrer_id'] : null;
$raum = !empty($stunde['raum_id']) ? $stunde['raum_id'] : null;
$inhalt = !empty($stunde['inhalt_text']) ? $stunde['inhalt_text'] : null;
$werte[] = $fach;
$werte[] = $lehrer;
$werte[] = $raum;
$werte[] = $inhalt;
}
}
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",
$datum,
...$werte
);
?>
</body>
</html>
echo "TEST SITE";