diff --git a/__pycache__/users.cpython-311.pyc b/__pycache__/users.cpython-311.pyc index 6bfcc6c..3659f8b 100644 Binary files a/__pycache__/users.cpython-311.pyc and b/__pycache__/users.cpython-311.pyc differ diff --git a/ui.py b/ui.py index fae4ab2..3255751 100644 --- a/ui.py +++ b/ui.py @@ -6,8 +6,9 @@ import locale locale.setlocale(locale.LC_ALL, '') from time import strftime -from definitions import app_title, app_version -from users import * +from definitions import app_title, app_version, status_in +from users import user as uo +from users import list_users # Pinpad @@ -122,7 +123,8 @@ class win_userlist(tk.Toplevel): button_row_index = button_row_index + 1 class win_stamping(tk.Toplevel): - def __init__(self, user): + def __init__(self, parent, user): + super().__init__(parent) def update_time(): string_time = strftime('%A, der %d.%m.%Y - %H:%M:%S') nonlocal digital_clock @@ -131,13 +133,49 @@ class win_stamping(tk.Toplevel): self.title(app_title + " " + app_version) + # Benutzer feststellen + + current_user = uo(user) + # Digital clock label configuration digital_clock = tk.Label(self) digital_clock.grid(row=0, column=0, columnspan=3, padx=10, pady=10) # Initial call to update_time function update_time() - stamping = tk.Button(self) + # Benutzer anzeigen + tk.Label(self, text=current_user.fullname).grid(row=1, column=0, pady=10, columnspan=3) + + todays_hours = tk.Label(self, text="Arbeitsstunden erscheinen hier") + todays_hours.grid(row=2, column=0, pady=10, columnspan=3) + + in_button = tk.Button(self, text="Einstempeln", bg="green") + out_button = tk.Button(self, text="Ausstempeln", bg="red") + + if current_user.stamp_status() == status_in: + in_button.configure(state="disabled") + out_button.configure(state="active") + out_button.focus_set() + else: + in_button.configure(state="active") + out_button.configure(state="disabled") + in_button.focus_set() + in_button.grid(row=3, column = 0) + out_button.grid(row=3, column=2) + + button_frame = tk.Frame(self, relief="groove") + button_frame.grid(row=4, column=0, columnspan=3, pady=10) + + overview_workinghours = tk.Button(button_frame, text="Übersicht Arbeitszeiten") + overview_missed = tk.Button(button_frame, text="Übersicht Fehlzeiten") + overview_data = tk.Button(button_frame, text="Stammdaten") + + overview_workinghours.grid(row=0, column=0, sticky="ew") + overview_missed.grid(row=1, column=0, sticky="ew") + overview_data.grid(row=2, column=0, sticky="ew") + + button_close = tk.Button(self, text="Schließen") + button_close.grid(row=5, column=1) #======================================================== @@ -155,6 +193,9 @@ class mainwindow(tk.Tk): tk.Button(self, text='Userlist Window', command=self.open_userlist).pack(expand=True) + tk.Button(self, + text='Stamping Window', + command=self.open_stamping).pack(expand=True) def open_pinpad(self): window = win_pinpad(self) @@ -164,6 +205,9 @@ class mainwindow(tk.Tk): window = win_userlist(self) window.grab_set() + def open_stamping(self): + window = win_stamping(self, user="testuser") + window.grab_set() if __name__ == "__main__": diff --git a/users.py b/users.py index 8c0f7dc..ad76842 100644 --- a/users.py +++ b/users.py @@ -5,6 +5,7 @@ import os import datetime import time +import json from definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out @@ -16,6 +17,19 @@ class user: self.settingsfile = self.userfolder + "/" + usersettingsfilename self.photofile = self.userfolder + "/" + photofilename + # Stammdaten einlesen + try: + with open(self.settingsfile) as json_file: + data = json.load(json_file) + json_file.close() + except: + pass + #Hier muss noch Fehlerbehandlungcode hin + + self.fullname = data["name"] + self.password = data["password"] + self.workhours = data["workhours"] + def get_stamp_file(self): year = str(datetime.datetime.now().year) month = str(datetime.datetime.now().month) diff --git a/users/testuser/2025-4.txt b/users/testuser/2025-4.txt index b06d023..421273c 100644 --- a/users/testuser/2025-4.txt +++ b/users/testuser/2025-4.txt @@ -5,3 +5,4 @@ 1743966047 1743966049 1743967346 +1744889948 diff --git a/users/testuser/settings.json b/users/testuser/settings.json new file mode 100644 index 0000000..aa4dbda --- /dev/null +++ b/users/testuser/settings.json @@ -0,0 +1,27 @@ +{ + "username": "testuser", + "name": "Der neue Tester", + "password": "123456789", + "workhours": { + "2024-04-01": { + "0": "0", + "1": "8", + "2": "8", + "3": "8", + "4": "8", + "5": "8", + "6": "0", + "vacation": "30" + }, + "2024-04-07": { + "0": "0", + "1": "6", + "2": "6", + "3": "6", + "4": "8", + "5": "6", + "6": "0", + "vacation": "28" + } + } +} \ No newline at end of file