diff --git a/Backend/Makefile b/Backend/Makefile index 34598d0..53655ef 100644 --- a/Backend/Makefile +++ b/Backend/Makefile @@ -2,5 +2,15 @@ test: mkdir -p .test go test ./... -coverprofile=.test/coverage.out -json > .test/report.json -scan: - sonar-scanner -Dsonar.token=sqa_ca8394c93a728d6cff96703955288d8902c15200 +# scan: +# sonar-scanner -Dsonar.token=sqa_ca8394c93a728d6cff96703955288d8902c15200 + +# complete live run +live: + make -j2 live/templ live/tailwindcss + +live/templ: + templ generate --watch --proxy="http://localhost:8080" --cmd="go run ." --open-browser=false + +live/tailwind: + npx --yes tailwindcss -i ./input.css -o ./assets/styles.css --minify --watch diff --git a/Backend/endpoints/pdf-create.go b/Backend/endpoints/pdf-create.go index 443a2a1..2ccfad6 100644 --- a/Backend/endpoints/pdf-create.go +++ b/Backend/endpoints/pdf-create.go @@ -45,7 +45,8 @@ func convertDaysToTypst(days []models.IWorkDay, u models.User) ([]typstDay, erro func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDayPart { var typstDayParts []typstDayPart - if day.IsWorkDay() { + switch day.Type() { + case models.DayTypeWorkday: workDay, _ := day.(*models.WorkDay) for i := 0; i < len(workDay.Bookings); i += 2 { var typstDayPart typstDayPart @@ -64,13 +65,12 @@ func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDay IsWorkDay: true, }) } - if workdayAbsence := workDay.GetWorktimeAbsence(); (workdayAbsence != models.Absence{}) { - typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: workdayAbsence.AbwesenheitTyp.Name}) + case models.DayTypeCompound: + for _, c := range day.(*models.CompoundDay).DayParts { + typstDayParts = append(typstDayParts, convertDayToTypstDayParts(c, user)...) } - - } else { - absentDay, _ := day.(*models.Absence) - typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: absentDay.AbwesenheitTyp.Name}) + default: + typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: day.ToString()}) } return typstDayParts } @@ -91,7 +91,7 @@ func PDFCreateController(w http.ResponseWriter, r *http.Request) { employes, err := models.GetUserByPersonalNrMulti(personalNumbers) if err != nil { slog.Warn("Error getting employes!", slog.Any("Error", err)) - return + // return } n := 0 @@ -102,6 +102,9 @@ func PDFCreateController(w http.ResponseWriter, r *http.Request) { } } employes = employes[:n] + if helper.GetEnv("GO_ENV", "production") == "debug" { + employes = append(employes, user) + } reportData := createReports(employes, startDate) diff --git a/Backend/models/absence.go b/Backend/models/absence.go index afeb79e..8b7e789 100644 --- a/Backend/models/absence.go +++ b/Backend/models/absence.go @@ -22,6 +22,11 @@ type Absence struct { DateTo time.Time } +// IsEmpty implements [IWorkDay]. +func (a *Absence) IsEmpty() bool { + return false +} + func NewAbsence(card_uid string, abwesenheit_typ int, datum time.Time) (Absence, error) { if abwesenheit_typ < 0 { return Absence{ @@ -95,7 +100,7 @@ func (a *Absence) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (w } func (a *Absence) ToString() string { - return "Abwesenheit" + return a.AbwesenheitTyp.Name } func (a *Absence) IsWorkDay() bool { @@ -107,7 +112,7 @@ func (a *Absence) IsKurzArbeit() bool { } func (a *Absence) GetDayProgress(u User) int8 { - return 100 + return a.AbwesenheitTyp.WorkTime } func (a *Absence) RequiresAction() bool { diff --git a/Backend/models/compoundDay.go b/Backend/models/compoundDay.go new file mode 100644 index 0000000..618d919 --- /dev/null +++ b/Backend/models/compoundDay.go @@ -0,0 +1,105 @@ +package models + +import ( + "log/slog" + "time" +) + +type CompoundDay struct { + Day time.Time + DayParts []IWorkDay +} + +func NewCompondDay(date time.Time, dayParts ...IWorkDay) *CompoundDay { + return &CompoundDay{Day: date, DayParts: dayParts} +} + +func (c *CompoundDay) AddDayPart(dayPart IWorkDay) { + c.DayParts = append(c.DayParts, dayPart) +} + +func (c *CompoundDay) GetWorkDay() WorkDay { + workday, ok := c.DayParts[0].(*WorkDay) + if ok { + return *workday + } + return WorkDay{} +} + +// IsEmpty implements [IWorkDay]. +func (c *CompoundDay) IsEmpty() bool { + return len(c.DayParts) > 0 +} + +// Date implements [IWorkDay]. +func (c *CompoundDay) Date() time.Time { + return c.Day +} + +// GetDayProgress implements [IWorkDay]. +func (c *CompoundDay) GetDayProgress(u User) int8 { + var dayProcess int8 + for _, day := range c.DayParts { + dayProcess += day.GetDayProgress(u) + } + return dayProcess +} + +// GetOvertime implements [IWorkDay]. +func (c *CompoundDay) GetOvertime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { + + var overtime time.Duration + for _, day := range c.DayParts { + overtime += day.GetOvertime(u, base, includeKurzarbeit) + } + return overtime +} + +// GetPausetime implements [IWorkDay]. +func (c *CompoundDay) GetPausetime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { + var pausetime time.Duration + for _, day := range c.DayParts { + pausetime += day.GetPausetime(u, base, includeKurzarbeit) + } + return pausetime +} + +// GetTimes implements [IWorkDay]. +func (c *CompoundDay) GetTimes(u User, base WorktimeBase, includeKurzarbeit bool) (work time.Duration, pause time.Duration, overtime time.Duration) { + return c.GetWorktime(u, base, includeKurzarbeit), c.GetPausetime(u, base, includeKurzarbeit), c.GetOvertime(u, base, includeKurzarbeit) +} + +// GetWorktime implements [IWorkDay]. +func (c *CompoundDay) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { + var worktime time.Duration + for _, day := range c.DayParts { + worktime += day.GetWorktime(u, base, includeKurzarbeit) + slog.Info("Calc worktime for day", "day", day, "worktime", worktime.String()) + } + return worktime +} + +// IsKurzArbeit implements [IWorkDay]. +func (c *CompoundDay) IsKurzArbeit() bool { + return false +} + +// IsWorkDay implements [IWorkDay]. +func (c *CompoundDay) IsWorkDay() bool { + return true +} + +// RequiresAction implements [IWorkDay]. +func (c *CompoundDay) RequiresAction() bool { + return false +} + +// ToString implements [IWorkDay]. +func (c *CompoundDay) ToString() string { + return "Compound Day" +} + +// Type implements [IWorkDay]. +func (c *CompoundDay) Type() DayType { + return DayTypeCompound +} diff --git a/Backend/models/iworkday.go b/Backend/models/iworkday.go index aff96ba..6305842 100644 --- a/Backend/models/iworkday.go +++ b/Backend/models/iworkday.go @@ -1,8 +1,6 @@ package models import ( - "arbeitszeitmessung/helper" - "log" "log/slog" "time" ) @@ -19,57 +17,73 @@ type IWorkDay interface { GetPausetime(User, WorktimeBase, bool) time.Duration GetTimes(User, WorktimeBase, bool) (work, pause, overtime time.Duration) GetOvertime(User, WorktimeBase, bool) time.Duration + IsEmpty() bool } type DayType int const ( - DayTypeWorkday DayType = 1 - DayTypeAbsence DayType = 2 - DayTypeHoliday DayType = 3 + DayTypeWorkday DayType = 1 + DayTypeAbsence DayType = 2 + DayTypeHoliday DayType = 3 + DayTypeCompound DayType = 4 ) func GetDays(user User, tsFrom, tsTo time.Time, orderedForward bool) []IWorkDay { var allDays map[string]IWorkDay = make(map[string]IWorkDay) - for _, day := range GetWorkDays(user, tsFrom, tsTo) { - allDays[day.Date().Format(time.DateOnly)] = &day - } + workdays := GetWorkDays(user, tsFrom, tsTo) absences, err := GetAbsencesByCardUID(user.CardUID, tsFrom, tsTo) if err != nil { - log.Println("Error gettings absences for all Days!", err) + slog.Warn("Error gettings absences!", slog.Any("Error", err)) return nil } holidays, err := GetHolidaysFromTo(tsFrom, tsTo) if err != nil { - slog.Warn("Error getting holidays from DB!", slog.Any("Error", err)) + slog.Warn("Error getting holidays!", slog.Any("Error", err)) + return nil } - for _, day := range absences { - if helper.IsWeekend(day.Date()) { + + for _, day := range workdays { + allDays[day.Date().Format(time.DateOnly)] = &day + } + + for _, absentDay := range absences { + // Kurzarbeit should be integrated in workday + existingDay, ok := allDays[absentDay.Date().Format(time.DateOnly)] + if !ok { + allDays[absentDay.Date().Format(time.DateOnly)] = &absentDay continue } - // Absence should be integrated in workday switch { - case day.AbwesenheitTyp.WorkTime < 0: - if workDay, ok := allDays[day.Date().Format(time.DateOnly)].(*WorkDay); ok { + case absentDay.AbwesenheitTyp.WorkTime < 0: + if workDay, ok := allDays[absentDay.Date().Format(time.DateOnly)].(*WorkDay); ok { workDay.kurzArbeit = true - workDay.kurzArbeitAbsence = day - } - case day.AbwesenheitTyp.WorkTime < 100: - if workDay, ok := allDays[day.Date().Format(time.DateOnly)].(*WorkDay); ok { - workDay.worktimeAbsece = day + workDay.kurzArbeitAbsence = absentDay } + case !existingDay.IsEmpty(): + allDays[absentDay.Date().Format(time.DateOnly)] = NewCompondDay(absentDay.Date(), existingDay, &absentDay) default: - allDays[day.Date().Format(time.DateOnly)] = &day + allDays[absentDay.Date().Format(time.DateOnly)] = &absentDay } } - for _, day := range holidays { - if helper.IsWeekend(day.Date()) { + for _, holiday := range holidays { + existingDay, ok := allDays[holiday.Date().Format(time.DateOnly)] + if !ok { + allDays[holiday.Date().Format(time.DateOnly)] = &holiday continue } - allDays[day.Date().Format(time.DateOnly)] = &day - slog.Debug("Logging Holiday: ", slog.String("HolidayName", allDays[day.Date().Format(time.DateOnly)].ToString()), slog.Any("Overtime", day.GetOvertime(user, WorktimeBaseDay, false).String()), "wokrtie", float32(day.worktime)/100) + slog.Info("Existing Day", "day", existingDay) + switch { + case existingDay.Type() == DayTypeCompound: + allDays[holiday.Date().Format(time.DateOnly)].(*CompoundDay).AddDayPart(&holiday) + case existingDay.Type() != DayTypeCompound && !existingDay.IsEmpty(): + allDays[holiday.Date().Format(time.DateOnly)] = NewCompondDay(holiday.Date(), existingDay, &holiday) + default: + allDays[holiday.Date().Format(time.DateOnly)] = &holiday + } + slog.Debug("Logging Holiday: ", slog.String("HolidayName", allDays[holiday.Date().Format(time.DateOnly)].ToString()), slog.Any("Overtime", holiday.GetOvertime(user, WorktimeBaseDay, false).String()), "wokrtie", float32(holiday.worktime)/100) } sortedDays := sortDays(allDays, orderedForward) diff --git a/Backend/models/publicHoliday.go b/Backend/models/publicHoliday.go index 97dce3e..567a610 100644 --- a/Backend/models/publicHoliday.go +++ b/Backend/models/publicHoliday.go @@ -14,6 +14,11 @@ type PublicHoliday struct { worktime int8 } +// IsEmpty implements [IWorkDay]. +func (p *PublicHoliday) IsEmpty() bool { + return false +} + func NewHolidayFromFeiertag(f feiertage.Feiertag) PublicHoliday { return PublicHoliday{ Feiertag: f, @@ -106,9 +111,9 @@ func (p *PublicHoliday) RequiresAction() bool { func (p *PublicHoliday) GetWorktime(u User, base WorktimeBase, includeKurzarbeit bool) time.Duration { switch base { case WorktimeBaseDay: - return u.ArbeitszeitProTagFrac(float32(p.worktime / 100)) + return u.ArbeitszeitProTagFrac(float32(p.worktime) / 100) case WorktimeBaseWeek: - return u.ArbeitszeitProWocheFrac(float32(p.worktime/100) * 0.2) + return u.ArbeitszeitProWocheFrac(float32(p.worktime) / 500) } return 0 } diff --git a/Backend/models/workDay.go b/Backend/models/workDay.go index afdcdc9..c995275 100644 --- a/Backend/models/workDay.go +++ b/Backend/models/workDay.go @@ -23,6 +23,11 @@ type WorkDay struct { worktimeAbsece Absence } +// IsEmpty implements [IWorkDay]. +func (d *WorkDay) IsEmpty() bool { + return len(d.Bookings) == 0 +} + type WorktimeBase int const ( diff --git a/Backend/templates/pages.templ b/Backend/templates/pages.templ index 01b142f..55735f8 100644 --- a/Backend/templates/pages.templ +++ b/Backend/templates/pages.templ @@ -1,6 +1,7 @@ package templates import "arbeitszeitmessung/models" +import "arbeitszeitmessung/helper" templ Base() { @@ -29,9 +30,7 @@ templ LoginPage(success bool, errorMsg string) { } templ SettingsPage(status int) { - {{ - user := ctx.Value("user").(models.User) - }} + {{ user := ctx.Value("user").(models.User) }} @Base() @headerComponent()
Nutzername: { user.Vorname } { user.Name }
Personalnummer: { user.PersonalNummer }
Arbeitszeit pro Tag: { helper.FormatDuration(user.ArbeitszeitProTag()) }
Arbeitszeit pro Woche: { helper.FormatDuration(user.ArbeitszeitProWoche()) }
Nutzer von Weboberfläche abmelden.
Arbeitszeit pro Tag: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var8 string + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(user.ArbeitszeitProTag())) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 108} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
Arbeitszeit pro Woche: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(user.ArbeitszeitProWoche())) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 62, Col: 112} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
{ helper.FormatGermanDayOfWeek(day.Date()) }: { day.Date().Format("02.01.2006") }
Keine Anwesenheit
Bitte anpassen
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Vorname) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 93, Col: 53} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Name) + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(week.User.Vorname) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 93, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 90, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "
Arbeitszeit: ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var18 string - templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDuration(week.Worktime))) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 110, Col: 79} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
Überstunden: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
Arbeitszeit: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var19 string - templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDurationFill(week.Overtime, true))) + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDuration(week.Worktime))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 111, Col: 90} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 107, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
Überstunden: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var20 string + templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s", helper.FormatDurationFill(week.Overtime, true))) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 108, Col: 90} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "
Woche: ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "
Woche: ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d-%d", kw, year)) + var templ_7745c5c3_Var21 string + templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%02d-%d", kw, year)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 123, Col: 86} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 120, Col: 86} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "
Unterschiedliche Arbeitszeit zwischen Abrechnung und individuellen Buchungen
bitte zuerst Buchungen anpassen
Die Woche kann erst am nächsten Montag gesendet werden!
an Vorgesetzten senden
an Vorgesetzten gesendet
vom Vorgesetzten bestätigt
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var25 string - templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 173, Col: 19} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var26 string - templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name) + templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 173, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 170, Col: 19} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "
- { a.AbwesenheitTyp.Name } + { a.ToString() } if a.IsMultiDay() { bis { a.DateTo.Format("02.01.2006") } } @@ -94,6 +91,13 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) {
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format(time.DateOnly)) + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(a.ToString()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 80, Col: 80} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 82, Col: 17} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\">
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(a.AbwesenheitTyp.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 85, Col: 26} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if a.IsMultiDay() { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "bis ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "bis ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var21 string - templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("02.01.2006")) + var templ_7745c5c3_Var17 string + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("02.01.2006")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 87, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 84, Col: 70} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var27 string - templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 119, Col: 91} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var28 string - templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs("booking_" + strconv.Itoa(booking.CounterId)) + templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 120, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 123, Col: 91} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\" type=\"time\" value=\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "\" type=\"time\" value=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var30 string - templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(booking.GetBookingType()) + templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 121, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 124, Col: 126} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
submitted
{ helper.FormatDuration(pause) }
{ helper.FormatDuration(overtime) } @@ -130,20 +129,25 @@ templ defaultDayComponent(day models.IWorkDay) { switch day.Type() { case models.DayTypeWorkday: {{ workDay, _ := day.(*models.WorkDay) }} + @workdayComponent(workDay) @newAbsenceComponent() - if len(workDay.Bookings) < 1 { -
Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!
{ c.ToString() }
{ day.ToString() }
{ d.ToString() }
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -355,7 +354,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 120, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 119, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -388,7 +387,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs("time-" + day.Date().Format(time.DateOnly)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 129, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 128, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -414,7 +413,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component { switch day.Type() { case models.DayTypeWorkday: workDay, _ := day.(*models.WorkDay) - templ_7745c5c3_Err = newAbsenceComponent().Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = workdayComponent(workDay).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -422,33 +421,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - if len(workDay.Bookings) < 1 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var20 string + templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(c.ToString()) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 148, Col: 26} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString()) + var templ_7745c5c3_Var21 string + templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(day.ToString()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 148, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 152, Col: 25} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -493,7 +509,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component { }) } -func absentInput(a models.Absence) templ.Component { +func workdayComponent(workDay *models.WorkDay) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -509,64 +525,72 @@ func absentInput(a models.Absence) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var21 := templ.GetChildren(ctx) - if templ_7745c5c3_Var21 == nil { - templ_7745c5c3_Var21 = templ.NopComponent + templ_7745c5c3_Var22 := templ.GetChildren(ctx) + if templ_7745c5c3_Var22 == nil { + templ_7745c5c3_Var22 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "Keine Buchung gefunden. Bitte Arbeitsstunden oder Grund der Abwesenheit eingeben!