71 lines
3.6 KiB
PHP
71 lines
3.6 KiB
PHP
<?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);
|
|
}
|
|
|
|
// --- 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_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;
|
|
$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="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>
|
|
<?php if ($_SESSION['username'] == "bruno" || $_SESSION['username'] == "Bruno"): ?>
|
|
<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 class="form-group">
|
|
<label style="font-size: 0.85rem; font-weight: 600; color: inherit;">Grund</label>
|
|
|
|
<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;">
|
|
Eintrag speichern
|
|
</button>
|
|
</form>
|
|
<?php endif ?>
|
|
</div>
|
|
</div>
|