package templates
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
"fmt"
"net/url"
"strconv"
"time"
)
templ inputForm() {
{{
urlParams := ctx.Value("urlParams").(url.Values)
user := ctx.Value("user").(models.User)
}}
{ user.Vorname + " " + user.Name }
Überstunden
{ user.Overtime }
}
templ defaultDayComponent(day models.IWorkDay) {
if day.IsWorkDay() {
{{
workDay, _ := day.(*models.WorkDay)
}}
@workDayComponent(*workDay, false)
} else {
{{
absentDay, _ := day.(*models.Absence)
}}
@timeGaugeComponent(100, false)
{ day.Date().Format("Mon") }: { day.Date().Format("02.01.2006") }
@lineComponent()
{ absentDay.AbwesenheitTyp.Name } bis { absentDay.DateTo.Format("02.01.2006") }
@changeButtonComponent("time-" + absentDay.Date().Format("2006-01-02"))
}
}
templ workDayComponent(workDay models.WorkDay, submitted bool) {
{{
// work, pause := workDay.GetWorkTimeString()
user := ctx.Value("user").(models.User)
work, pause, overtime := workDay.GetAllWorkTimesReal(user)
// overtime := helper.FormatDuration(workDay.CalcOvertime(user))
justify := ""
if len(workDay.Bookings) <= 1 {
justify = "justify-content: center"
}
}}
@timeGaugeComponent(workDay.GetDayProgress(user), workDay.Day.Equal(time.Now().Truncate(24*time.Hour)))
{ workDay.Day.Format("Mon") }: { workDay.Day.Format("02.01.2006") }
if (workDay.RequiresAction()) {
Bitte anpassen
} else {
if work > 0 {
Arbeitszeit:
{ helper.FormatDuration(work) }
}
if pause > 0 {
{ helper.FormatDuration(pause) }
}
if overtime > 0 {
{ helper.FormatDuration(overtime) }
}
}
@changeButtonComponent("time-" + workDay.Day.Format("2006-01-02"))
}
templ changeButtonComponent(id string) {
}
templ timeGaugeComponent(progress int8, today bool) {
{{
var bgColor string
switch {
case (0 > progress):
bgColor = "bg-red-600"
break
case (progress > 0 && progress < 95):
bgColor = "bg-orange-500"
break
case (95 <= progress && progress <= 105):
bgColor = "bg-accent"
break
case (progress > 105):
bgColor = "bg-purple-600"
break
default:
bgColor = "bg-neutral-400"
break
}
}}
if today {
} else {
}
}
templ lineComponent() {
}
templ absenceComponent(d models.WorkDay) {
}
templ newBookingComponent(d models.WorkDay) {
}
templ bookingComponent(booking models.Booking) {
}
templ LegendComponent() {
Arbeitszeit unter regulär
}