Abgleich mit Live-Daten
This commit is contained in:
+115
-115
@@ -1,116 +1,116 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2>Stempelkarten-System</h2>
|
||||
|
||||
<?php
|
||||
// Überprüfen, ob eine Benutzer-ID in der Session vorhanden ist
|
||||
if (!isset($_SESSION['userid'])) {
|
||||
die("Kein Benutzer angemeldet.");
|
||||
}
|
||||
|
||||
#$user_id = $_SESSION['userid'];
|
||||
|
||||
$user_id = $_GET['employee_id'] ?? null;
|
||||
$datum = $_GET['datum'] ?? null;
|
||||
|
||||
if ($user_id && $datum) {
|
||||
try {
|
||||
// Holen Sie alle Zeitbuchungen des Tages für den Mitarbeiter
|
||||
$query = "SELECT * FROM timestamps WHERE employee_id = :employee_id AND DATE(timestamp_datetime) = :datum ORDER BY timestamp_datetime ASC";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->bindParam(':employee_id', $user_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':datum', $datum);
|
||||
$stmt->execute();
|
||||
$buchungen = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch(PDOException $e) {
|
||||
echo "Datenbankfehler: " . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
die("Fehler: Mitarbeiter-ID oder Datum fehlt.");
|
||||
}
|
||||
|
||||
// ... [Hier könnten Sie PHP-Code für die Bearbeitung der Buchungen hinzufügen]
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tageseinträge bearbeiten</title>
|
||||
<!-- ... [Bootstrap-CSS und optional JavaScript] -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h3>Tageseinträge bearbeiten - <?php echo date('d.m.Y', strtotime($datum)); ?></h3>
|
||||
|
||||
<!-- Formular zum Bearbeiten der Zeitbuchungen -->
|
||||
<form id="mainForm" action="saveDayEntries.php" method="post">
|
||||
<input type="hidden" name="employee_id" value="<?php echo $user_id; ?>">
|
||||
<input type="hidden" name="datum" value="<?php echo $datum; ?>">
|
||||
<?php foreach ($buchungen as $index => $buchung): ?>
|
||||
<div class="form-group" id="entry_<?php echo $buchung['timestamp_id']; ?>">
|
||||
<label>Zeitbuchung <?php echo $index + 1; ?>:</label>
|
||||
<input type="datetime-local" class="form-control" name="buchungen[<?php echo $buchung['timestamp_id']; ?>][timestamp_datetime]" value="<?php echo $buchung['timestamp_datetime']; ?>">
|
||||
<select class="form-control" name="buchungen[<?php echo $buchung['timestamp_id']; ?>][timestamp_type]">
|
||||
<option value="KOMMEN" <?php if ($buchung['timestamp_type'] == 'KOMMEN') echo 'selected'; ?>>KOMMEN</option>
|
||||
<option value="GEHEN" <?php if ($buchung['timestamp_type'] == 'GEHEN') echo 'selected'; ?>>GEHEN</option>
|
||||
</select>
|
||||
|
||||
<a href="deleteDayEntry.php?timestamp_id=<?php echo $buchung['timestamp_id']; ?>" class="btn btn-danger">Löschen</a>
|
||||
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div id="newEnty"></div>
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</form>
|
||||
<br>
|
||||
<button onclick="addEntry()" class="btn btn-success">Neue Buchung hinzufügen</button>
|
||||
<br><br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let entryIndex = <?php echo count($buchungen); ?>;
|
||||
function addEntry() {
|
||||
entryIndex++;
|
||||
const container = document.createElement('div');
|
||||
container.className = 'form-group';
|
||||
container.innerHTML = `
|
||||
<label>Zeitbuchung ${entryIndex}:</label>
|
||||
<input type="datetime-local" class="form-control" name="buchungen[new_${entryIndex}][timestamp_datetime]" placeholder="YYYY-MM-DD HH:MM:SS">
|
||||
<select class="form-control" name="buchungen[new_${entryIndex}][timestamp_type]">
|
||||
<option value="KOMMEN">KOMMEN</option>
|
||||
<option value="GEHEN">GEHEN</option>
|
||||
</select>
|
||||
|
||||
`;
|
||||
document.getElementById('newEnty').appendChild(container);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
session_start();
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/functions.inc.php");
|
||||
//Überprüfe, dass der User eingeloggt ist
|
||||
//Der Aufruf von check_user() muss in alle internen Seiten eingebaut sein
|
||||
$user = check_user();
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h2>Stempelkarten-System</h2>
|
||||
|
||||
<?php
|
||||
// Überprüfen, ob eine Benutzer-ID in der Session vorhanden ist
|
||||
if (!isset($_SESSION['userid'])) {
|
||||
die("Kein Benutzer angemeldet.");
|
||||
}
|
||||
|
||||
#$user_id = $_SESSION['userid'];
|
||||
|
||||
$user_id = $_GET['employee_id'] ?? null;
|
||||
$datum = $_GET['datum'] ?? null;
|
||||
|
||||
if ($user_id && $datum) {
|
||||
try {
|
||||
// Holen Sie alle Zeitbuchungen des Tages für den Mitarbeiter
|
||||
$query = "SELECT * FROM timestamps WHERE employee_id = :employee_id AND DATE(timestamp_datetime) = :datum ORDER BY timestamp_datetime ASC";
|
||||
$stmt = $pdo->prepare($query);
|
||||
$stmt->bindParam(':employee_id', $user_id, PDO::PARAM_INT);
|
||||
$stmt->bindParam(':datum', $datum);
|
||||
$stmt->execute();
|
||||
$buchungen = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch(PDOException $e) {
|
||||
echo "Datenbankfehler: " . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
die("Fehler: Mitarbeiter-ID oder Datum fehlt.");
|
||||
}
|
||||
|
||||
// ... [Hier könnten Sie PHP-Code für die Bearbeitung der Buchungen hinzufügen]
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tageseinträge bearbeiten</title>
|
||||
<!-- ... [Bootstrap-CSS und optional JavaScript] -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h3>Tageseinträge bearbeiten - <?php echo date('d.m.Y', strtotime($datum)); ?></h3>
|
||||
|
||||
<!-- Formular zum Bearbeiten der Zeitbuchungen -->
|
||||
<form id="mainForm" action="saveDayEntries.php" method="post">
|
||||
<input type="hidden" name="employee_id" value="<?php echo $user_id; ?>">
|
||||
<input type="hidden" name="datum" value="<?php echo $datum; ?>">
|
||||
<?php foreach ($buchungen as $index => $buchung): ?>
|
||||
<div class="form-group" id="entry_<?php echo $buchung['timestamp_id']; ?>">
|
||||
<label>Zeitbuchung <?php echo $index + 1; ?>:</label>
|
||||
<input type="datetime-local" class="form-control" name="buchungen[<?php echo $buchung['timestamp_id']; ?>][timestamp_datetime]" value="<?php echo $buchung['timestamp_datetime']; ?>">
|
||||
<select class="form-control" name="buchungen[<?php echo $buchung['timestamp_id']; ?>][timestamp_type]">
|
||||
<option value="KOMMEN" <?php if ($buchung['timestamp_type'] == 'KOMMEN') echo 'selected'; ?>>KOMMEN</option>
|
||||
<option value="GEHEN" <?php if ($buchung['timestamp_type'] == 'GEHEN') echo 'selected'; ?>>GEHEN</option>
|
||||
</select>
|
||||
|
||||
<a href="deleteDayEntry.php?timestamp_id=<?php echo $buchung['timestamp_id']; ?>" class="btn btn-danger">Löschen</a>
|
||||
|
||||
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div id="newEnty"></div>
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
</form>
|
||||
<br>
|
||||
<button onclick="addEntry()" class="btn btn-success">Neue Buchung hinzufügen</button>
|
||||
<br><br>
|
||||
<button type="button" class="btn btn-secondary" onclick="history.back();">Zurück</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let entryIndex = <?php echo count($buchungen); ?>;
|
||||
function addEntry() {
|
||||
entryIndex++;
|
||||
const container = document.createElement('div');
|
||||
container.className = 'form-group';
|
||||
container.innerHTML = `
|
||||
<label>Zeitbuchung ${entryIndex}:</label>
|
||||
<input type="datetime-local" class="form-control" name="buchungen[new_${entryIndex}][timestamp_datetime]" placeholder="YYYY-MM-DD HH:MM:SS">
|
||||
<select class="form-control" name="buchungen[new_${entryIndex}][timestamp_type]">
|
||||
<option value="KOMMEN">KOMMEN</option>
|
||||
<option value="GEHEN">GEHEN</option>
|
||||
</select>
|
||||
|
||||
`;
|
||||
document.getElementById('newEnty').appendChild(container);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
Reference in New Issue
Block a user