erster Commit draft Dateien

This commit is contained in:
F 2026-01-04 16:59:49 +01:00
parent 3820e6a809
commit 0ea116052d
14 changed files with 435 additions and 1 deletions

View file

@ -1,3 +1,12 @@
# FSCash
Dokumentiere Ausgaben on-the-go als Webapp
Dokumentiere Ausgaben on-the-go als Webapp
Das erste Release soll enthalten:
- mariadb setup
- apache2 setup
- Auswahl des UI frameworks
- login
- Anzeige bestehender Ausgaben des aktuellen Monats
- "+" Button zum Aufruf der Eingabemaske
- Eingabemaske für Ausgaben
- Speichern der Ausgaben in mariadb

104
html/assets/css/style.css Normal file
View file

@ -0,0 +1,104 @@
/* Basis-Stile */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
/* Cookie-Hinweis */
.cookie-notice {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #333;
color: #fff;
padding: 10px;
text-align: center;
z-index: 1000;
}
/* Modal */
.modal {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 1001;
}
.modal-content {
background: #fff;
padding: 20px;
border-radius: 5px;
width: 90%;
max-width: 400px;
}
/* Navigation */
.nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
background: #333;
color: #fff;
}
.nav-list {
display: none;
list-style: none;
padding: 0;
margin: 0;
}
.nav-list li {
padding: 5px 0;
}
.hamburger {
display: block;
background: none;
border: none;
color: #fff;
font-size: 24px;
cursor: pointer;
}
.logout {
color: #fff;
text-decoration: none;
}
/* Tabelle */
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
/* Button */
.btn-new {
display: block;
background: #4CAF50;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
margin: 20px 0;
}
/* Responsive */
@media (min-width: 768px) {
.nav-list {
display: flex;
}
.hamburger {
display: none;
}
}

9
html/assets/js/script.js Normal file
View file

@ -0,0 +1,9 @@
// Cookie-Hinweis ausblenden
document.getElementById('accept-cookies').addEventListener('click', function() {
document.getElementById('cookie-notice').style.display = 'none';
});
// Hamburger-Menü
document.querySelector('.hamburger').addEventListener('click', function() {
document.querySelector('.nav-list').classList.toggle('show');
});

21
html/config.php Normal file
View file

@ -0,0 +1,21 @@
<?php
session_start();
$host = 'localhost';
$db = 'finanzapp';
$user = 'root'; // Anpassen!
$pass = ''; // Anpassen!
$charset = 'utf8mb4';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
?>

83
html/dashboard.php Normal file
View file

@ -0,0 +1,83 @@
<?php
require 'config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: index.php');
exit;
}
// Login-Logik
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$_POST['username']]);
$user = $stmt->fetch();
if ($user && password_verify($_POST['password'], $user['password'])) {
$_SESSION['user_id'] = $user['id'];
} else {
header('Location: index.php');
exit;
}
}
// Daten abrufen
$stmt = $pdo->prepare("SELECT * FROM entries WHERE user_id = ?");
$stmt->execute([$_SESSION['user_id']]);
$entries = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FinanzApp - Dashboard</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<!-- Navigation -->
<nav class="nav">
<button class="hamburger">☰</button>
<ul class="nav-list">
<li><a href="menu1.php">Menüpunkt 1</a></li>
<li><a href="menu2.php">Menüpunkt 2</a></li>
<li><a href="menu3.php">Menüpunkt 3</a></li>
<li><a href="menu4.php">Menüpunkt 4</a></li>
<li><a href="menu5.php">Menüpunkt 5</a></li>
</ul>
<a href="logout.php" class="logout">Logout</a>
</nav>
<!-- Tabelle -->
<table>
<thead>
<tr>
<th>Datum</th>
<?php if (!isset($_COOKIE['mobile'])): ?>
<th>Kategorie</th>
<th>Zahlweise</th>
<?php endif; ?>
<th>Betreff</th>
<th>Betrag</th>
</tr>
</thead>
<tbody>
<?php foreach ($entries as $entry): ?>
<tr>
<td><?= htmlspecialchars($entry['date']) ?></td>
<?php if (!isset($_COOKIE['mobile'])): ?>
<td><?= htmlspecialchars($entry['category'] ?? '') ?></td>
<td><?= htmlspecialchars($entry['payment_method'] ?? '') ?></td>
<?php endif; ?>
<td><?= htmlspecialchars($entry['subject']) ?></td>
<td><?= htmlspecialchars($entry['amount']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- Neu-Button -->
<a href="new_entry.php" class="btn-new">Neu</a>
</div>
<script src="assets/js/script.js"></script>
</body>
</html>

37
html/index.php Normal file
View file

@ -0,0 +1,37 @@
<?php
require 'config.php';
if (isset($_SESSION['user_id'])) {
header('Location: dashboard.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FinanzApp - Login</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<!-- Cookie-Hinweis -->
<div id="cookie-notice" class="cookie-notice">
<p>Diese Website verwendet nur technisch notwendige Cookies.</p>
<button id="accept-cookies">OK</button>
</div>
<!-- Modal Login Dialog -->
<div id="login-modal" class="modal">
<div class="modal-content">
<h2>Login</h2>
<form action="dashboard.php" method="post">
<input type="text" name="username" placeholder="Benutzername" required>
<input type="password" name="password" placeholder="Passwort" required>
<button type="submit">Einloggen</button>
</form>
</div>
</div>
<script src="assets/js/script.js"></script>
</body>
</html>

6
html/logout.php Normal file
View file

@ -0,0 +1,6 @@
<?php
session_start();
session_destroy();
header('Location: index.php');
exit;
?>

22
html/menu1.php Normal file
View file

@ -0,0 +1,22 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Menüpunkt X</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Menüpunkt X</h1>
<p>Hier kommt der Inhalt für Menüpunkt X.</p>
</div>
</body>
</html>

22
html/menu2.php Normal file
View file

@ -0,0 +1,22 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Menüpunkt X</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Menüpunkt X</h1>
<p>Hier kommt der Inhalt für Menüpunkt X.</p>
</div>
</body>
</html>

22
html/menu3.php Normal file
View file

@ -0,0 +1,22 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Menüpunkt X</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Menüpunkt X</h1>
<p>Hier kommt der Inhalt für Menüpunkt X.</p>
</div>
</body>
</html>

22
html/menu4.php Normal file
View file

@ -0,0 +1,22 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Menüpunkt X</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Menüpunkt X</h1>
<p>Hier kommt der Inhalt für Menüpunkt X.</p>
</div>
</body>
</html>

22
html/menu5.php Normal file
View file

@ -0,0 +1,22 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Menüpunkt X</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Menüpunkt X</h1>
<p>Hier kommt der Inhalt für Menüpunkt X.</p>
</div>
</body>
</html>

29
html/new_entry.php Normal file
View file

@ -0,0 +1,29 @@
<?php
require 'config.php';
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=1.0">
<title>FinanzApp - Neuer Eintrag</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container">
<h1>Neuer Eintrag</h1>
<form action="dashboard.php" method="post">
<input type="date" name="date" required>
<input type="text" name="category" placeholder="Kategorie">
<input type="text" name="subject" placeholder="Betreff" required>
<input type="number" step="0.01" name="amount" placeholder="Betrag" required>
<input type="text" name="payment_method" placeholder="Zahlweise">
<button type="submit">Speichern</button>
</form>
</div>
</body>
</html>

26
init_sql.sql Normal file
View file

@ -0,0 +1,26 @@
-- Datenbank erstellen
CREATE DATABASE IF NOT EXISTS finanzapp;
USE finanzapp;
-- Tabelle für Benutzer
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
-- Tabelle für Einträge
CREATE TABLE IF NOT EXISTS entries (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
date DATE NOT NULL,
category VARCHAR(50),
subject VARCHAR(255) NOT NULL,
amount DECIMAL(10,2) NOT NULL,
payment_method VARCHAR(50),
FOREIGN KEY (user_id) REFERENCES users(id)
);
-- Testbenutzer einfügen (Passwort: "test123")
INSERT INTO users (username, password) VALUES ('testuser', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi');