zeiterfassung für admin eingefügt
This commit is contained in:
@@ -432,6 +432,25 @@ def time_tracking():
|
|||||||
|
|
||||||
return redirect(url_for('dashboard'))
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
|
@app.route('/admin/time_tracking', methods=['GET'])
|
||||||
|
def admin_time_tracking():
|
||||||
|
if not is_admin():
|
||||||
|
flash("Zugriff verweigert!", "red")
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
|
db = get_db()
|
||||||
|
# Hole alle Zeiteinträge (JOIN mit users, damit wir den username sehen)
|
||||||
|
time_entries = db.execute("""
|
||||||
|
SELECT t.id, t.user_id, t.activity, t.start_time, t.end_time,
|
||||||
|
u.username
|
||||||
|
FROM time_entries t
|
||||||
|
JOIN users u ON t.user_id = u.id
|
||||||
|
ORDER BY t.start_time DESC
|
||||||
|
""").fetchall()
|
||||||
|
|
||||||
|
return render_template('admin_time_entries.html', time_entries=time_entries)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# DASHBOARD
|
# DASHBOARD
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|||||||
@@ -165,6 +165,11 @@ Admin-Bereich
|
|||||||
<p class="text-sm text-gray-400 mt-6">Wähle oben in der Benutzerverwaltung „Lesezeichen“ für einen Nutzer aus, um konkrete Einträge zu sehen.</p>
|
<p class="text-sm text-gray-400 mt-6">Wähle oben in der Benutzerverwaltung „Lesezeichen“ für einen Nutzer aus, um konkrete Einträge zu sehen.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
<a href="{{ url_for('admin_time_tracking') }}"
|
||||||
|
class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded text-sm">
|
||||||
|
Zeiterfassung einsehen
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- Grid Ende -->
|
</div> <!-- Grid Ende -->
|
||||||
|
|
||||||
|
|||||||
64
Dashboard_V2/templates/admin_time_entries.html
Normal file
64
Dashboard_V2/templates/admin_time_entries.html
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Zeiterfassung aller Benutzer{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container mx-auto py-8 px-4">
|
||||||
|
<h1 class="text-2xl font-bold mb-4">Zeiterfassung (alle Benutzer)</h1>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<div class="bg-{{category}}-500 text-white p-2 mb-2 rounded">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="table-auto w-full text-left">
|
||||||
|
<thead>
|
||||||
|
<tr class="border-b">
|
||||||
|
<th class="px-2 py-1">ID</th>
|
||||||
|
<th class="px-2 py-1">Benutzer</th>
|
||||||
|
<th class="px-2 py-1">Aktivität</th>
|
||||||
|
<th class="px-2 py-1">Start</th>
|
||||||
|
<th class="px-2 py-1">Ende</th>
|
||||||
|
<th class="px-2 py-1">Dauer</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for entry in time_entries %}
|
||||||
|
<tr class="border-b">
|
||||||
|
<td class="px-2 py-1">{{ entry.id }}</td>
|
||||||
|
<td class="px-2 py-1">{{ entry.username }}</td>
|
||||||
|
<td class="px-2 py-1">{{ entry.activity }}</td>
|
||||||
|
<td class="px-2 py-1">{{ entry.start_time }}</td>
|
||||||
|
<td class="px-2 py-1">
|
||||||
|
{% if entry.end_time %}
|
||||||
|
{{ entry.end_time }}
|
||||||
|
{% else %}
|
||||||
|
<span class="text-sm text-gray-600">läuft …</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-1">
|
||||||
|
{% if entry.end_time %}
|
||||||
|
<!-- Beispielhafter Zeitunterschied in Minuten -->
|
||||||
|
{% set duration = (entry.end_time|datetime - entry.start_time|datetime).total_seconds() / 60 %}
|
||||||
|
{{ duration|round(2) }} Minuten
|
||||||
|
{% else %}
|
||||||
|
...
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="{{ url_for('admin_panel') }}"
|
||||||
|
class="inline-block bg-blue-500 text-white px-4 py-2 rounded mt-4 hover:bg-blue-600">
|
||||||
|
Zurück zum Admin-Menü
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
Reference in New Issue
Block a user