Merge branch 'main' into LIVE

This commit is contained in:
Bruno Eckhardt committed 2026-03-25 07:46:45 +01:00
commit 8c53e850c1
2 files changed
+44 -109

No files matched your search

+17 -109
View File
@@ -12,59 +12,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_overtime'])) {
$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); }
$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); }
$gesamt_minuten = $minuten_berichte - $minuten_extra;
$minuten_aufbau = 0;
$res2 = $conn->query("SELECT SUM(MINUTEN) AS summe FROM Ueberstunden WHERE GRUND = 'Aufbau'");
if ($row = $res2->fetch_object()) { $minuten_aufbau = intval($row->summe); }
$gesamt_minuten = $minuten_berichte - $minuten_abbau + $minuten_aufbau;
?>
<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;">
@@ -87,10 +51,15 @@ $gesamt_minuten = $minuten_berichte - $minuten_extra;
<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;">
<div class="form-group">
<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;">
<select name="ot_reason" required>
<option value="">Bitte wählen</option>
<option value="Abbau">Abbau</option>
<option value="Aufbau">Aufbau</option>
</select>
</div>
<button type="submit"
style="background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; font-weight: bold; cursor: pointer;">
@@ -99,65 +68,4 @@ $gesamt_minuten = $minuten_berichte - $minuten_extra;
</form>
<?php endif ?>
</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>
</div>
+27
View File
@@ -1043,4 +1043,31 @@ body.dark-mode .db-table tr:nth-child(even) {
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");
}