Sollstunden in Übersicht eingefügt
This commit is contained in:
parent
15ad2cd495
commit
99f1ba9336
7
users.py
7
users.py
@ -38,9 +38,12 @@ class user:
|
|||||||
completepath = f"{self.userfolder}/{year}-{month}.txt"
|
completepath = f"{self.userfolder}/{year}-{month}.txt"
|
||||||
return completepath
|
return completepath
|
||||||
|
|
||||||
def timestamp(self):
|
def timestamp(self, stamptime=-1):
|
||||||
filename = self.get_stamp_file()
|
filename = self.get_stamp_file()
|
||||||
timestamp = int(time.time())
|
if stamptime == -1:
|
||||||
|
stamptime = time.time()
|
||||||
|
print(stamptime)
|
||||||
|
timestamp = int(stamptime)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Öffne die Datei im Anhang-Modus ('a')
|
# Öffne die Datei im Anhang-Modus ('a')
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
|
1743652800
|
||||||
|
1743667140
|
||||||
|
1743923400
|
||||||
1743965819
|
1743965819
|
||||||
1743965909
|
1743965909
|
||||||
1743966000
|
|
||||||
1743966022
|
|
||||||
1743966045
|
1743966045
|
||||||
1743966047
|
1743967800
|
||||||
1743966049
|
|
||||||
1743544200
|
|
||||||
1744659900
|
|
||||||
1744889948
|
1744889948
|
||||||
1744889966
|
1744889966
|
||||||
1744989797
|
1744989797
|
||||||
@ -22,7 +20,17 @@
|
|||||||
1744991291
|
1744991291
|
||||||
1744991473
|
1744991473
|
||||||
1744991477
|
1744991477
|
||||||
|
1744991770
|
||||||
|
1744991777
|
||||||
1745181046
|
1745181046
|
||||||
1745181050
|
1745181050
|
||||||
1745240760
|
1745240760
|
||||||
1745240762
|
1745390818
|
||||||
|
1745390894
|
||||||
|
1745390894
|
||||||
|
1745391029
|
||||||
|
1745391037
|
||||||
|
1745391056
|
||||||
|
1745391058
|
||||||
|
1745391059
|
||||||
|
1743660240
|
||||||
|
@ -4,44 +4,34 @@
|
|||||||
"password": "123456789",
|
"password": "123456789",
|
||||||
"workhours": {
|
"workhours": {
|
||||||
"2024-04-01": {
|
"2024-04-01": {
|
||||||
"1": "8",
|
"1": "11",
|
||||||
"2": "8",
|
"2": "12",
|
||||||
"3": "8",
|
"3": "13",
|
||||||
"4": "4",
|
"4": "14",
|
||||||
"5": "5",
|
"5": "15",
|
||||||
"6": "4",
|
"6": "16",
|
||||||
"7": "0",
|
"7": "17",
|
||||||
"vacation": "35"
|
"vacation": "35"
|
||||||
},
|
},
|
||||||
"2025-04-23": {
|
|
||||||
"0": 0,
|
|
||||||
"1": 0,
|
|
||||||
"2": 0,
|
|
||||||
"3": 0,
|
|
||||||
"4": 0,
|
|
||||||
"5": 0,
|
|
||||||
"6": 0,
|
|
||||||
"vacation": 0
|
|
||||||
},
|
|
||||||
"2025-05-13": {
|
"2025-05-13": {
|
||||||
"0": 0,
|
"1": "0",
|
||||||
"1": 0,
|
"2": "0",
|
||||||
"2": 0,
|
"3": "0",
|
||||||
"3": 0,
|
"4": "0",
|
||||||
"4": 0,
|
"5": "0",
|
||||||
"5": 0,
|
"6": "0",
|
||||||
"6": 0,
|
"7": "0",
|
||||||
"vacation": 0
|
"vacation": "0"
|
||||||
},
|
},
|
||||||
"2025-04-22": {
|
"2025-04-22": {
|
||||||
"0": 0,
|
"1": "1",
|
||||||
"1": 0,
|
"2": "2",
|
||||||
"2": 0,
|
"3": "3",
|
||||||
"3": 0,
|
"4": "4",
|
||||||
"4": 0,
|
"5": "5",
|
||||||
"5": 0,
|
"6": "6",
|
||||||
"6": 0,
|
"7": "7",
|
||||||
"vacation": 0
|
"vacation": "0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
150
web_ui.py
150
web_ui.py
@ -98,13 +98,14 @@ def page_admin():
|
|||||||
# Basisstruktur
|
# Basisstruktur
|
||||||
with ui.card():
|
with ui.card():
|
||||||
with ui.row():
|
with ui.row():
|
||||||
def update_user():
|
|
||||||
pass
|
|
||||||
|
|
||||||
userlist = list_users()
|
userlist = list_users()
|
||||||
ui.markdown("Benutzer:")
|
ui.markdown("Benutzer:")
|
||||||
time_user = ui.select(options=userlist)
|
time_user = ui.select(options=userlist)
|
||||||
time_user.value = userlist[0]
|
time_user.value = userlist[0]
|
||||||
|
def update_user():
|
||||||
|
pass
|
||||||
ui.button("Aktualisieren", on_click=update_user)
|
ui.button("Aktualisieren", on_click=update_user)
|
||||||
|
|
||||||
# Tabelle konstruieren
|
# Tabelle konstruieren
|
||||||
@ -153,68 +154,125 @@ def page_admin():
|
|||||||
def update_month_and_year():
|
def update_month_and_year():
|
||||||
|
|
||||||
with ui.grid(columns=6) as table_grid:
|
with ui.grid(columns=6) as table_grid:
|
||||||
ui.markdown("Datum")
|
ui.markdown("**Datum**")
|
||||||
ui.markdown("Buchungen")
|
ui.markdown("**Buchungen**")
|
||||||
ui.markdown("Soll")
|
ui.markdown("**Soll**")
|
||||||
ui.markdown("Ist")
|
ui.markdown("**Ist**")
|
||||||
ui.markdown("Saldo")
|
ui.markdown("**Saldo**")
|
||||||
ui.space()
|
ui.space()
|
||||||
|
|
||||||
current_user = user(time_user.value)
|
current_user = user(time_user.value)
|
||||||
timestamps = current_user.get_timestamps(year=select_year.value, month=select_month.value)
|
timestamps = current_user.get_timestamps(year=select_year.value, month=select_month.value)
|
||||||
|
|
||||||
for day in range(1, monthrange(int(select_year.value), int(select_month.value))[1] + 1):
|
for day in range(1, monthrange(int(select_year.value), int(select_month.value))[1] + 1):
|
||||||
ui.markdown(f"{day}. {calendar.month_name[int(select_month.value)]}")
|
day_in_list = datetime.datetime(int(select_year.value), int(select_month.value), day)
|
||||||
|
|
||||||
|
ui.markdown(f"{day_in_list.strftime('%a')}., {day}. {calendar.month_name[int(select_month.value)]}")
|
||||||
|
|
||||||
# ---> Hier die Schleife für die Buchungen
|
# ---> Hier die Schleife für die Buchungen
|
||||||
#ui.markdown('BUCHUNGEN')
|
|
||||||
with ui.row():
|
with ui.row():
|
||||||
counter = 0
|
counter = 0
|
||||||
for i in timestamps:
|
for i in timestamps:
|
||||||
actual_timestamp = datetime.datetime.fromtimestamp(int(i))
|
actual_timestamp = datetime.datetime.fromtimestamp(int(i))
|
||||||
timestamp_day = actual_timestamp.strftime('%-d')
|
timestamp_day = actual_timestamp.strftime('%-d')
|
||||||
|
|
||||||
def edit_entry(t_stamp, day):
|
|
||||||
|
|
||||||
with ui.dialog() as edit_dialog, ui.card():
|
|
||||||
ui.markdown("###Eintrag bearbeiten")
|
|
||||||
timestamp = datetime.datetime.fromtimestamp(int(t_stamp))
|
|
||||||
input_time = ui.time().classes('w-full justify-center')
|
|
||||||
input_time.value = timestamp.strftime('%H:%M')
|
|
||||||
|
|
||||||
def save_entry(day):
|
|
||||||
position = timestamps.index(t_stamp)
|
|
||||||
new_time_stamp = datetime.datetime(int(select_year.value), int(select_month.value), day, int(input_time.value[:2]), int(input_time.value[-2:]))
|
|
||||||
print(new_time_stamp)
|
|
||||||
timestamps[position] = str(int(new_time_stamp.timestamp())) +"\n"
|
|
||||||
#print(timestamps)
|
|
||||||
current_user = user(time_user.value)
|
|
||||||
current_user.write_edited_timestamps(timestamps, select_year.value, select_month.value)
|
|
||||||
|
|
||||||
def del_entry():
|
|
||||||
pass
|
|
||||||
|
|
||||||
with ui.row():
|
|
||||||
ui.button("Speichern", on_click=lambda day=day: save_entry(day))
|
|
||||||
ui.button("Löschen", on_click=del_entry)
|
|
||||||
ui.button("Abbrechen", on_click=edit_dialog.close)
|
|
||||||
|
|
||||||
edit_dialog.open()
|
|
||||||
|
|
||||||
|
|
||||||
if int(timestamp_day) == int(day):
|
if int(timestamp_day) == int(day):
|
||||||
counter += 1
|
def edit_entry(t_stamp, day):
|
||||||
print(actual_timestamp)
|
with ui.dialog() as edit_dialog, ui.card():
|
||||||
current_button = ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=counter: edit_entry(t_stamp, day))
|
ui.markdown("###Eintrag bearbeiten")
|
||||||
if counter % 2 == 0:
|
timestamp = datetime.datetime.fromtimestamp(int(t_stamp))
|
||||||
current_button.props('color=red')
|
input_time = ui.time().classes('w-full justify-center')
|
||||||
else:
|
input_time.value = timestamp.strftime('%H:%M')
|
||||||
current_button.props('color=green')
|
|
||||||
|
def save_entry(day):
|
||||||
|
|
||||||
|
position = timestamps.index(t_stamp)
|
||||||
|
new_time_stamp = datetime.datetime(int(select_year.value), int(select_month.value), day, int(input_time.value[:2]), int(input_time.value[-2:]))
|
||||||
|
timestamps[position] = str(
|
||||||
|
int(new_time_stamp.timestamp())) + "\n"
|
||||||
|
# print(timestamps)
|
||||||
|
current_user = user(time_user.value)
|
||||||
|
current_user.write_edited_timestamps(timestamps, select_year.value, select_month.value)
|
||||||
|
edit_dialog.close()
|
||||||
|
calendar_card.clear()
|
||||||
|
update_month_and_year()
|
||||||
|
month_header.set_content(f"###Buchungen für {calendar.month_name[int(select_month.value)]} {select_year.value}")
|
||||||
|
ui.notify("Eintrag gespeichert")
|
||||||
|
|
||||||
|
def del_entry():
|
||||||
|
timestamps.remove(t_stamp)
|
||||||
|
timestamps.sort()
|
||||||
|
current_user = user(time_user.value)
|
||||||
|
current_user.write_edited_timestamps(timestamps, select_year.value, select_month.value)
|
||||||
|
edit_dialog.close()
|
||||||
|
calendar_card.clear()
|
||||||
|
update_month_and_year()
|
||||||
|
month_header.set_content(f"###Buchungen für {calendar.month_name[int(select_month.value)]} {select_year.value}")
|
||||||
|
ui.notify("Eintrag gelöscht")
|
||||||
|
|
||||||
|
with ui.row():
|
||||||
|
ui.button("Speichern",
|
||||||
|
on_click=lambda day=day: save_entry(day))
|
||||||
|
ui.button("Löschen", on_click=del_entry)
|
||||||
|
ui.button("Abbrechen", on_click=edit_dialog.close)
|
||||||
|
|
||||||
|
edit_dialog.open()
|
||||||
|
counter += 1
|
||||||
|
|
||||||
|
current_button = ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=day: edit_entry(t_stamp, day))
|
||||||
|
#if counter % 2 == 0:
|
||||||
|
# current_button.props('color=red')
|
||||||
|
#else:
|
||||||
|
# current_button.props('color=green')
|
||||||
|
|
||||||
|
# Arbeitszeitsoll bestimmen
|
||||||
|
workhour_entries = list(current_user.workhours)
|
||||||
|
workhour_entries.sort()
|
||||||
|
|
||||||
|
found_match = False
|
||||||
|
for entry in reversed(workhour_entries):
|
||||||
|
|
||||||
|
if datetime.datetime.strptime(entry, '%Y-%m-%d').timestamp() < day_in_list.timestamp() and found_match == False:
|
||||||
|
|
||||||
|
if int(day_in_list.strftime('%w')) == 0:
|
||||||
|
weekday_index = 7
|
||||||
|
else:
|
||||||
|
weekday_index = int(day_in_list.strftime('%w'))
|
||||||
|
ui.markdown(f"{current_user.workhours[entry][str(weekday_index)]} h")
|
||||||
|
found_match = True
|
||||||
|
|
||||||
|
|
||||||
|
# ui.markdown("Soll")
|
||||||
|
|
||||||
ui.markdown("Soll")
|
|
||||||
ui.markdown("Ist")
|
ui.markdown("Ist")
|
||||||
ui.markdown("+/-")
|
ui.markdown("+/-")
|
||||||
ui.button("Eintrag hinzufügen")
|
|
||||||
|
def add_entry(day):
|
||||||
|
with ui.dialog() as add_dialog, ui.card():
|
||||||
|
ui.markdown("###Eintrag hinzufügen")
|
||||||
|
input_time = ui.time().classes('w-full justify-center')
|
||||||
|
|
||||||
|
def add_entry_save():
|
||||||
|
if input_time.value == None:
|
||||||
|
ui.notify("Bitte eine Uhrzeit auswählen.")
|
||||||
|
return
|
||||||
|
|
||||||
|
new_time_stamp = datetime.datetime(int(select_year.value),
|
||||||
|
int(select_month.value), day,
|
||||||
|
int(input_time.value[:2]),
|
||||||
|
int(input_time.value[-2:])).timestamp()
|
||||||
|
current_user = user(time_user.value)
|
||||||
|
current_user.timestamp(stamptime=int(new_time_stamp))
|
||||||
|
calendar_card.clear()
|
||||||
|
update_month_and_year()
|
||||||
|
add_dialog.close()
|
||||||
|
ui.notify("Eintrag hinzugefügt")
|
||||||
|
|
||||||
|
ui.button("Speichern", on_click=add_entry_save)
|
||||||
|
ui.button("Abbrechen", on_click=add_dialog.close)
|
||||||
|
add_dialog.open()
|
||||||
|
ui.button("Eintrag hinzufügen", on_click=lambda day=day: add_entry(day))
|
||||||
table_grid.move(calendar_card)
|
table_grid.move(calendar_card)
|
||||||
update_month_and_year()
|
update_month_and_year()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user