Auswahlboxen statt Textfelder bei neuem Eintrag
This commit is contained in:
parent
11104d55c6
commit
3db61b2973
2 changed files with 71 additions and 18 deletions
|
|
@ -51,7 +51,7 @@ h1 {
|
|||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
.form-group input,select {
|
||||
width: 95%;
|
||||
padding: 8px 15px;
|
||||
border: 1px solid #ddd;
|
||||
|
|
@ -60,7 +60,7 @@ h1 {
|
|||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
.form-group input:focus,select:focus {
|
||||
border-color: var(--primary-color);
|
||||
outline: none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,22 @@ if (!isset($_SESSION['user_id'])) {
|
|||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
||||
<title>FSCash - Neuer Eintrag</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
$data_saved = "nix";
|
||||
$loggedInUserId = "nix";
|
||||
$debug = "";
|
||||
$users = [];
|
||||
$categories = [];
|
||||
|
||||
// save-Logik
|
||||
if (!empty($_POST) && isset($DEBUG)) { // $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
|
@ -43,6 +58,7 @@ if (!empty($_POST) && isset($DEBUG)) { // $_SERVER['REQUEST_METHOD'] === 'POST'
|
|||
// Statement ausführen
|
||||
$stmt->execute();
|
||||
$data_saved = "true";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Fehlerbehandlung
|
||||
$data_saved = "Fehler: "; // . $e->getMessage();
|
||||
|
|
@ -50,21 +66,33 @@ if (!empty($_POST) && isset($DEBUG)) { // $_SERVER['REQUEST_METHOD'] === 'POST'
|
|||
|
||||
}
|
||||
|
||||
// Aktuelles Datum im Format YYYY-MM-DD erzeugen
|
||||
$currentDate = date('Y-m-d');
|
||||
try {
|
||||
// Alle Benutzer aus der Tabelle 'users' laden
|
||||
$stmtUsers = $pdo->prepare("SELECT * FROM users;");
|
||||
$stmtUsers->execute();
|
||||
$users = $stmtUsers->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user['id'] == $_SESSION['user_id']) {
|
||||
$loggedInUserId = $user['id'];
|
||||
break; // Schleife beenden, sobald gefunden
|
||||
}
|
||||
}
|
||||
|
||||
// Alle Kategorien aus der Tabelle 'categories' laden
|
||||
$stmtCategories = $pdo->prepare("SELECT * FROM categories");
|
||||
$debug = $stmtCategories->queryString; // Enthält das reine SQL-Statement
|
||||
$stmtCategories->execute();
|
||||
$categories = $stmtCategories->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$data_saved = "Fehler: "; // . $e->getMessage();
|
||||
}
|
||||
// Aktuelles Datum im Format YYYY-MM-DD erzeugen
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.8">
|
||||
<title>FSCash - Neuer Eintrag</title>
|
||||
<link rel="stylesheet" href="assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php echo "<!-- data_saved:" . $data_saved . " Datum: " . $date . " Datum2: " . $currentDate . " -->"; ?>
|
||||
<?php echo "<!-- data_saved:" . $data_saved . " Datum2: " . $currentDate . " -->"; ?>
|
||||
<?php if ($data_saved != "nix"): ?>
|
||||
<div id="data-notice" class="data-notice">
|
||||
Data
|
||||
|
|
@ -85,19 +113,44 @@ if (!empty($_POST) && isset($DEBUG)) { // $_SERVER['REQUEST_METHOD'] === 'POST'
|
|||
<a href="logout.php" class="logout">Logout</a>
|
||||
</nav>
|
||||
|
||||
<h1>Neuer Eintrag</h1>
|
||||
<!-- <h1>Neuer Eintrag</h1> -->
|
||||
<form action="new_entry.php" method="post" class="form-container">
|
||||
<div class="form-group">
|
||||
<input type="date" name="date" value="<?php echo $currentDate; ?>" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="user_id" hidden>
|
||||
<select name="user_id" id="user_id">
|
||||
<?php foreach ($users as $user): ?>
|
||||
<option value="<?php echo htmlspecialchars($user['id']); ?>"
|
||||
<?php if ($user['id'] == $loggedInUserId): ?> selected <?php endif; ?>
|
||||
>
|
||||
<?php echo htmlspecialchars($user['username']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Person (Multiselect, alle vorselektiert) -->
|
||||
<div class="form-group">
|
||||
<input type="text" name="person" placeholder="Zahler:In" required>
|
||||
<label for="person">für wen</label>
|
||||
<select name="person[]" id="person" multiple required size="4">
|
||||
<?php foreach ($users as $user): ?>
|
||||
<option value="<?php echo htmlspecialchars($user['id']); ?>" selected>
|
||||
<?php echo htmlspecialchars($user['username']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Category (Einkaufen vorselektiert) -->
|
||||
<div class="form-group">
|
||||
<input type="text" name="category" placeholder="Kategorie">
|
||||
<!-- label for="category">Kategorie</label -->
|
||||
<select name="category" id="category" required>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<option value="<?php echo htmlspecialchars($category['category_id']); ?>"
|
||||
<?php echo ($category['name'] === 'Einkaufen' ? 'selected' : ''); ?>>
|
||||
<?php echo htmlspecialchars($category['name']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="subject" placeholder="Betreff" required>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue