Compare commits
1 Commits
2d0b117403
...
0.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
| ec69549d13 |
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func PDFHandler(w http.ResponseWriter, r *http.Request) {
|
func PDFHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
helper.RequiresLogin(Session, w, r)
|
helper.RequiresLogin(Session, w, r)
|
||||||
startDate, err := time.Parse("2006-01-02", "2025-09-01")
|
startDate, err := time.Parse("2006-01-02", "2025-08-01")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error")
|
log.Println("Error")
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ func PDFHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Println("Error getting user!")
|
log.Println("Error getting user!")
|
||||||
}
|
}
|
||||||
|
|
||||||
weeks := models.GetWorkDays(user, startDate, endDate)
|
weeks := models.GetWorkDays(user.CardUID, startDate, endDate)
|
||||||
|
|
||||||
log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
|
log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
|
||||||
templates.PDFReportEmploye(user, weeks, startDate, endDate).Render(r.Context(), w)
|
templates.PDFReportEmploye(user, weeks, startDate, endDate).Render(r.Context(), w)
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
||||||
|
|
||||||
workDays := models.GetWorkDays(user, tsFrom, tsTo)
|
workDays := models.GetWorkDays(user.CardUID, tsFrom, tsTo)
|
||||||
sort.Slice(workDays, func(i, j int) bool {
|
sort.Slice(workDays, func(i, j int) bool {
|
||||||
return workDays[i].Day.After(workDays[j].Day)
|
return workDays[i].Day.After(workDays[j].Day)
|
||||||
})
|
})
|
||||||
@@ -182,3 +182,82 @@ func createAbsence(absenceType int, user models.User, loc *time.Location, r *htt
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getBookingsAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
|
_user_pn := r.URL.Query().Get("personal_nummer")
|
||||||
|
user_pn, err := strconv.Atoi(_user_pn)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No personal numver found!")
|
||||||
|
http.Error(w, "No personal number found", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := models.GetUserByPersonalNr(user_pn)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No user found with the given personal number!")
|
||||||
|
http.Error(w, "No user found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO add config for timeoffset
|
||||||
|
tsFrom, err := parseTimestamp(r, "time_from", time.Now().AddDate(0, -1, 0).Format("2006-01-02"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing 'from' time", err)
|
||||||
|
http.Error(w, "Timestamp 'from' cannot be parsed!", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tsTo, err := parseTimestamp(r, "time_to", time.Now().Format("2006-01-02"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing 'to' time", err)
|
||||||
|
http.Error(w, "Timestamp 'to' cannot be parsed!", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
||||||
|
|
||||||
|
bookings, err := (*models.Booking).GetBookingsGrouped(nil, user.CardUID, tsFrom, tsTo)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting bookings: ", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(bookings)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updates a booking form the given json body
|
||||||
|
func updateBookingAPI(w http.ResponseWriter, r *http.Request) {
|
||||||
|
_booking_id := r.URL.Query().Get("counter_id")
|
||||||
|
if _booking_id == "" {
|
||||||
|
http.Error(w, "Missing bookingID query parameter", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
booking_id, err := strconv.Atoi(_booking_id)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Invalid bookingID query parameter", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bookingDB, err := (*models.Booking).GetBookingById(nil, booking_id)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error getting booking: ", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var booking models.Booking
|
||||||
|
dec := json.NewDecoder(r.Body)
|
||||||
|
dec.DisallowUnknownFields()
|
||||||
|
err = dec.Decode(&booking)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error parsing booking: ", err)
|
||||||
|
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if booking.CounterId != 0 && booking.CounterId != bookingDB.CounterId {
|
||||||
|
log.Println("Booking Ids do not match")
|
||||||
|
http.Error(w, "Booking Ids do not match", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bookingDB.Update(booking)
|
||||||
|
bookingDB.Save()
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(bookingDB)
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,5 +17,4 @@ require (
|
|||||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
go.uber.org/atomic v1.7.0 // indirect
|
||||||
golang.org/x/sys v0.36.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt3
|
|||||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -25,12 +25,8 @@ func GetKW(t time.Time) int {
|
|||||||
return kw
|
return kw
|
||||||
}
|
}
|
||||||
|
|
||||||
func FormatDuration(d time.Duration) string {
|
|
||||||
return FormatDurationFill(d, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Converts duration to string
|
// Converts duration to string
|
||||||
func FormatDurationFill(d time.Duration, fill bool) string {
|
func FormatDuration(d time.Duration) string {
|
||||||
hours := int(d.Abs().Hours())
|
hours := int(d.Abs().Hours())
|
||||||
minutes := int(d.Abs().Minutes()) % 60
|
minutes := int(d.Abs().Minutes()) % 60
|
||||||
sign := ""
|
sign := ""
|
||||||
@@ -45,13 +41,6 @@ func FormatDurationFill(d time.Duration, fill bool) string {
|
|||||||
case minutes > 0:
|
case minutes > 0:
|
||||||
return fmt.Sprintf("%s%dmin", sign, minutes)
|
return fmt.Sprintf("%s%dmin", sign, minutes)
|
||||||
default:
|
default:
|
||||||
if fill {
|
|
||||||
return "0min"
|
|
||||||
}
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsSameDate(a, b time.Time) bool {
|
|
||||||
return a.Truncate(24 * time.Hour).Equal(b.Truncate(24 * time.Hour))
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
type AbsenceType struct {
|
type AbsenceType struct {
|
||||||
Id int8
|
Id int8
|
||||||
Name string
|
Name string
|
||||||
WorkTime int8
|
WorkTime float32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Absence struct {
|
type Absence struct {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -162,6 +163,37 @@ func (b *Booking) GetBookingsByCardID(card_uid string, tsFrom time.Time, tsTo ti
|
|||||||
return bookings, nil
|
return bookings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Booking) GetBookingsGrouped(card_uid string, tsFrom time.Time, tsTo time.Time) ([]WorkDay, error) {
|
||||||
|
var grouped = make(map[string][]Booking)
|
||||||
|
bookings, err := b.GetBookingsByCardID(card_uid, tsFrom, tsTo)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to get bookings", err)
|
||||||
|
return []WorkDay{}, nil
|
||||||
|
}
|
||||||
|
for _, booking := range bookings {
|
||||||
|
day := booking.Timestamp.Truncate(24 * time.Hour)
|
||||||
|
key := day.Format("2006-01-02")
|
||||||
|
grouped[key] = append(grouped[key], booking)
|
||||||
|
}
|
||||||
|
|
||||||
|
var result []WorkDay
|
||||||
|
for key, bookings := range grouped {
|
||||||
|
day, _ := time.Parse("2006-01-02", key)
|
||||||
|
sort.Slice(bookings, func(i, j int) bool {
|
||||||
|
return bookings[i].Timestamp.Before(bookings[j].Timestamp)
|
||||||
|
})
|
||||||
|
workDay := WorkDay{Day: day, Bookings: bookings}
|
||||||
|
workDay.getWorkTime()
|
||||||
|
result = append(result, workDay)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(result, func(i, j int) bool {
|
||||||
|
return result[i].Day.After(result[j].Day)
|
||||||
|
})
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b Booking) Save() {
|
func (b Booking) Save() {
|
||||||
qStr, err := DB.Prepare((`UPDATE "anwesenheit" SET "card_uid" = $2, "geraet_id" = $3, "check_in_out" = $4, "timestamp" = $5 WHERE "counter_id" = $1;`))
|
qStr, err := DB.Prepare((`UPDATE "anwesenheit" SET "card_uid" = $2, "geraet_id" = $3, "check_in_out" = $4, "timestamp" = $5 WHERE "counter_id" = $1;`))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package models_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"arbeitszeitmessung/models"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var testBookingType = models.BookingType{
|
|
||||||
Id: 1,
|
|
||||||
Name: "Büro",
|
|
||||||
}
|
|
||||||
|
|
||||||
var testBookings8hrs = []models.Booking{models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 1,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}, models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 2,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}}
|
|
||||||
|
|
||||||
var testBookings6hrs = []models.Booking{models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 1,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}, models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 2,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 14:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}}
|
|
||||||
|
|
||||||
var testBookings10hrs = []models.Booking{models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 1,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}, models.Booking{
|
|
||||||
CardUID: "aaaa-aaaa",
|
|
||||||
CheckInOut: 2,
|
|
||||||
Timestamp: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 18:00")),
|
|
||||||
BookingType: testBookingType,
|
|
||||||
}}
|
|
||||||
@@ -22,9 +22,6 @@ type DBFixture struct {
|
|||||||
|
|
||||||
func SetupDBFixture(t *testing.T) *DBFixture {
|
func SetupDBFixture(t *testing.T) *DBFixture {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if helper.GetEnv("TEST_SQL", "false") != "true" {
|
|
||||||
t.Skip("Skipping Test because TEST_SQL is not 'true'!")
|
|
||||||
}
|
|
||||||
|
|
||||||
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
||||||
dbPort := helper.GetEnv("POSTGRES_PORT", "5433")
|
dbPort := helper.GetEnv("POSTGRES_PORT", "5433")
|
||||||
|
|||||||
@@ -198,6 +198,17 @@ func (u *User) IsTeamLeader() bool {
|
|||||||
return len(team) > 0
|
return len(team) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *User) GetWeek(tsFrom time.Time) WorkWeek {
|
||||||
|
var bookings []WorkDay
|
||||||
|
weekStart := tsFrom.AddDate(0, 0, -1*int(tsFrom.Local().Weekday())-1)
|
||||||
|
bookings, err := (*Booking).GetBookingsGrouped(nil, u.CardUID, weekStart, time.Now())
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error fetching bookings!")
|
||||||
|
return WorkWeek{WorkDays: bookings}
|
||||||
|
}
|
||||||
|
return WorkWeek{WorkDays: bookings}
|
||||||
|
}
|
||||||
|
|
||||||
// gets the first week, that needs to be submitted
|
// gets the first week, that needs to be submitted
|
||||||
func (u *User) GetNextWeek() WorkWeek {
|
func (u *User) GetNextWeek() WorkWeek {
|
||||||
var week WorkWeek
|
var week WorkWeek
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type WorkDay struct {
|
|||||||
Absence Absence
|
Absence Absence
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetWorkDays(user User, tsFrom, tsTo time.Time) []WorkDay {
|
func GetWorkDays(card_uid string, tsFrom, tsTo time.Time) []WorkDay {
|
||||||
var workDays []WorkDay
|
var workDays []WorkDay
|
||||||
var workSec, pauseSec float64
|
var workSec, pauseSec float64
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ ORDER BY d.work_date ASC;`)
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer qStr.Close()
|
defer qStr.Close()
|
||||||
rows, err := qStr.Query(user.CardUID, tsFrom, tsTo)
|
rows, err := qStr.Query(card_uid, tsFrom, tsTo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error getting rows!")
|
log.Println("Error getting rows!")
|
||||||
return workDays
|
return workDays
|
||||||
@@ -125,20 +125,21 @@ ORDER BY d.work_date ASC;`)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if absenceType.Valid {
|
if absenceType.Valid {
|
||||||
workDay.Absence, err = NewAbsence(user.CardUID, int(absenceType.Int16), workDay.Day)
|
workDay.Absence, err = NewAbsence(card_uid, int(absenceType.Int16), workDay.Day)
|
||||||
workDay.CalcRealWorkTime(user)
|
// log.Println("Found absence", workDay.Absence)
|
||||||
}
|
}
|
||||||
|
|
||||||
if workDay.Day.Equal(time.Now().Truncate(24 * time.Hour)) {
|
if workDay.Day.Equal(time.Now().Truncate(24 * time.Hour)) {
|
||||||
workDay.CalcRealWorkTime(user)
|
workDay.getWorkTime()
|
||||||
workDay.CalcWorkPauseDiff(user)
|
|
||||||
} else {
|
} else {
|
||||||
workDay.CalcWorkPauseDiff(user)
|
workDay.calcPauseTime()
|
||||||
}
|
}
|
||||||
if emptyDays && workDay.Day.Weekday() >= 1 && workDay.Day.Weekday() <= 5 {
|
if emptyDays && workDay.Day.Weekday() >= 1 && workDay.Day.Weekday() <= 5 {
|
||||||
workDays = append(workDays, workDay)
|
workDays = append(workDays, workDay)
|
||||||
} else if len(workDay.Bookings) > 0 || (workDay.Absence != Absence{}) {
|
} else if len(workDay.Bookings) > 0 || (workDay.Absence != Absence{}) {
|
||||||
workDays = append(workDays, workDay)
|
workDays = append(workDays, workDay)
|
||||||
|
// } else {
|
||||||
|
// log.Println("no booking on day", workDay.Day.Format("02.01.2006"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err = rows.Err(); err != nil {
|
if err = rows.Err(); err != nil {
|
||||||
@@ -147,16 +148,8 @@ ORDER BY d.work_date ASC;`)
|
|||||||
return workDays
|
return workDays
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkDay) CalcWorkPauseDiff(user User) (work, pause time.Duration) {
|
func (d *WorkDay) calcPauseTime() {
|
||||||
if d.workTime == 0 {
|
if d.workTime > 6*time.Hour && d.pauseTime < 45*time.Minute {
|
||||||
d.CalcRealWorkTime(user)
|
|
||||||
}
|
|
||||||
if d.Absence.AbwesenheitTyp.WorkTime > 0 {
|
|
||||||
return d.workTime, d.pauseTime
|
|
||||||
}
|
|
||||||
if d.workTime <= 6*time.Hour || d.pauseTime > 45*time.Minute {
|
|
||||||
return d.workTime, d.pauseTime
|
|
||||||
}
|
|
||||||
if d.workTime <= (9*time.Hour) && d.pauseTime < 30*time.Minute {
|
if d.workTime <= (9*time.Hour) && d.pauseTime < 30*time.Minute {
|
||||||
diff := 30*time.Minute - d.pauseTime
|
diff := 30*time.Minute - d.pauseTime
|
||||||
d.workTime -= diff
|
d.workTime -= diff
|
||||||
@@ -166,37 +159,34 @@ func (d *WorkDay) CalcWorkPauseDiff(user User) (work, pause time.Duration) {
|
|||||||
d.workTime -= diff
|
d.workTime -= diff
|
||||||
d.pauseTime += diff
|
d.pauseTime += diff
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return d.workTime, d.pauseTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkDay) CalcRealWorkTime(user User) time.Duration {
|
// Gets the duration someone worked that day
|
||||||
if (len(d.Bookings) < 1 && d.Absence == Absence{}) {
|
func (d *WorkDay) getWorkTime() {
|
||||||
return 0
|
if len(d.Bookings) < 1 {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
var realWorkTime, realPauseTime time.Duration
|
var workTime, pauseTime time.Duration
|
||||||
var lastBooking Booking
|
var lastBooking Booking
|
||||||
for _, booking := range d.Bookings {
|
for _, booking := range d.Bookings {
|
||||||
if booking.CheckInOut%2 == 1 {
|
if booking.CheckInOut%2 == 1 {
|
||||||
if !lastBooking.Timestamp.IsZero() {
|
if !lastBooking.Timestamp.IsZero() {
|
||||||
realPauseTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
pauseTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
realWorkTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
workTime += booking.Timestamp.Sub(lastBooking.Timestamp)
|
||||||
}
|
}
|
||||||
lastBooking = booking
|
lastBooking = booking
|
||||||
}
|
}
|
||||||
if helper.IsSameDate(d.Day, time.Now()) && len(d.Bookings)%2 == 1 {
|
// checks if booking is today and has no gehen yet, so the time since last kommen booking is added to workTime
|
||||||
realWorkTime += time.Since(lastBooking.Timestamp.Local())
|
if d.Day.Day() == time.Now().Day() && len(d.Bookings)%2 == 1 {
|
||||||
|
workTime += time.Since(lastBooking.Timestamp.Local())
|
||||||
}
|
}
|
||||||
if d.Absence.AbwesenheitTyp.WorkTime > 0 {
|
d.workTime = workTime
|
||||||
realWorkTime = time.Duration(user.ArbeitszeitPerTag * float32(time.Hour)).Round(time.Minute)
|
d.pauseTime = pauseTime
|
||||||
log.Println("Rewriting worktime", realWorkTime)
|
|
||||||
}
|
|
||||||
d.workTime = realWorkTime
|
|
||||||
d.pauseTime = realPauseTime
|
|
||||||
|
|
||||||
return realWorkTime
|
d.calcPauseTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkDay) GetWorkTimeString() (work string, pause string) {
|
func (d *WorkDay) GetWorkTimeString() (work string, pause string) {
|
||||||
@@ -205,10 +195,6 @@ func (d *WorkDay) GetWorkTimeString() (work string, pause string) {
|
|||||||
return workString, pauseString
|
return workString, pauseString
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkDay) GetAllWorkTimes(user User) (work, pause, overtime time.Duration) {
|
|
||||||
return d.workTime.Round(time.Minute), d.pauseTime.Round(time.Minute), d.CalcOvertime(user)
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns bool wheter the workday was ended with an automatic logout
|
// returns bool wheter the workday was ended with an automatic logout
|
||||||
func (d *WorkDay) RequiresAction() bool {
|
func (d *WorkDay) RequiresAction() bool {
|
||||||
if len(d.Bookings) == 0 {
|
if len(d.Bookings) == 0 {
|
||||||
@@ -225,13 +211,15 @@ func (d *WorkDay) GetWorkDayProgress(user User) uint8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *WorkDay) CalcOvertime(user User) time.Duration {
|
func (d *WorkDay) CalcOvertime(user User) time.Duration {
|
||||||
if d.workTime == 0 {
|
|
||||||
d.CalcWorkPauseDiff(user)
|
|
||||||
}
|
|
||||||
if helper.IsWeekend(d.Day) && len(d.Bookings) == 0 {
|
if helper.IsWeekend(d.Day) && len(d.Bookings) == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
var overtime time.Duration
|
var overtime time.Duration
|
||||||
overtime = d.workTime - time.Duration(user.ArbeitszeitPerTag*float32(time.Hour)).Round(time.Minute)
|
overtime = d.workTime - time.Duration(user.ArbeitszeitPerTag*float32(time.Hour)).Round(time.Minute)
|
||||||
|
// weekday is WE
|
||||||
|
if (d.Absence != Absence{}) {
|
||||||
|
overtime = 0
|
||||||
|
}
|
||||||
|
|
||||||
return overtime
|
return overtime
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
package models_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"arbeitszeitmessung/helper"
|
|
||||||
"arbeitszeitmessung/models"
|
|
||||||
"log"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CatchError[T any](val T, err error) T {
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
return val
|
|
||||||
}
|
|
||||||
|
|
||||||
var testWorkDay = models.WorkDay{
|
|
||||||
Day: CatchError(time.Parse("2006-01-02", "2025-01-01")),
|
|
||||||
Bookings: testBookings8hrs,
|
|
||||||
TimeFrom: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 08:00")),
|
|
||||||
TimeTo: CatchError(time.Parse("2006-01-02 15:04", "2025-01-01 16:30")),
|
|
||||||
Absence: models.Absence{},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCalcRealWorkTime(t *testing.T) {
|
|
||||||
workTime := testWorkDay.CalcRealWorkTime(testUser)
|
|
||||||
if workTime != time.Hour*8 {
|
|
||||||
t.Errorf("Calc Worktime Default not working, time should be 8h, but was %s", helper.FormatDuration(workTime))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCalcWorkPauseDiff(t *testing.T) {
|
|
||||||
type testCase struct {
|
|
||||||
Name string
|
|
||||||
bookings []models.Booking
|
|
||||||
expectedWorkTime time.Duration
|
|
||||||
expectedPauseTime time.Duration
|
|
||||||
expectedOvertime time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
testCases := []testCase{testCase{
|
|
||||||
Name: "6hrs no pause",
|
|
||||||
bookings: testBookings6hrs,
|
|
||||||
expectedWorkTime: 6 * time.Hour,
|
|
||||||
expectedPauseTime: 0,
|
|
||||||
expectedOvertime: -2 * time.Hour,
|
|
||||||
},
|
|
||||||
testCase{
|
|
||||||
Name: "8hrs - 30min pause",
|
|
||||||
bookings: testBookings8hrs,
|
|
||||||
expectedWorkTime: 7*time.Hour + 30*time.Minute,
|
|
||||||
expectedPauseTime: 30 * time.Minute,
|
|
||||||
expectedOvertime: -30 * time.Minute,
|
|
||||||
},
|
|
||||||
testCase{
|
|
||||||
Name: "10hrs - 45min pause",
|
|
||||||
bookings: testBookings10hrs,
|
|
||||||
expectedWorkTime: 9*time.Hour + 15*time.Minute,
|
|
||||||
expectedPauseTime: 45 * time.Minute,
|
|
||||||
expectedOvertime: 1*time.Hour + 15*time.Minute,
|
|
||||||
}}
|
|
||||||
|
|
||||||
for _, test := range testCases {
|
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
|
||||||
testWorkDay.Bookings = test.bookings
|
|
||||||
testWorkDay.CalcRealWorkTime(testUser)
|
|
||||||
testWorkDay.CalcWorkPauseDiff(testUser)
|
|
||||||
testWorkDay.CalcOvertime(testUser)
|
|
||||||
workTime, pauseTime, overTime := testWorkDay.GetAllWorkTimes(testUser)
|
|
||||||
if workTime != test.expectedWorkTime {
|
|
||||||
t.Errorf("Calculated wrong workTime: should be %s, but was %s", helper.FormatDuration(test.expectedWorkTime), helper.FormatDuration(workTime))
|
|
||||||
}
|
|
||||||
if pauseTime != test.expectedPauseTime {
|
|
||||||
t.Errorf("Calculated wrong pauseTime: should be %s, but was %s", helper.FormatDuration(test.expectedPauseTime), helper.FormatDuration(pauseTime))
|
|
||||||
}
|
|
||||||
if overTime != test.expectedOvertime {
|
|
||||||
t.Errorf("Calculated wrong overtime: should be %s, but was %s", helper.FormatDuration(test.expectedOvertime), helper.FormatDuration(overTime))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -45,7 +45,7 @@ func NewWorkWeek(user User, tsMonday time.Time, populate bool) WorkWeek {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorkWeek) PopulateWithBookings(worktime time.Duration, overtime time.Duration) {
|
func (w *WorkWeek) PopulateWithBookings(worktime time.Duration, overtime time.Duration) {
|
||||||
w.WorkDays = GetWorkDays(w.User, w.WeekStart, w.WeekStart.Add(7*24*time.Hour))
|
w.WorkDays = GetWorkDays(w.User.CardUID, w.WeekStart, w.WeekStart.Add(7*24*time.Hour))
|
||||||
if absences, err := GetAbsencesByCardUID(w.User.CardUID, w.WeekStart, w.WeekStart.Add(7*24*time.Hour)); err == nil {
|
if absences, err := GetAbsencesByCardUID(w.User.CardUID, w.WeekStart, w.WeekStart.Add(7*24*time.Hour)); err == nil {
|
||||||
w.Absences = absences
|
w.Absences = absences
|
||||||
} else {
|
} else {
|
||||||
@@ -108,11 +108,10 @@ func (w *WorkWeek) aggregateWorkTime() time.Duration {
|
|||||||
for _, day := range w.WorkDays {
|
for _, day := range w.WorkDays {
|
||||||
workTime += day.workTime
|
workTime += day.workTime
|
||||||
}
|
}
|
||||||
// for _, absence := range w.Absences {
|
for _, absences := range w.Absences {
|
||||||
// log.Println(absence)
|
absenceWorkTime := absences.AbwesenheitTyp.WorkTime - (absences.AbwesenheitTyp.WorkTime - w.User.ArbeitszeitPerTag) // workTime Equivalent of Absence is capped at user Worktime per Day
|
||||||
// absenceWorkTime := float32(8) // := absences.AbwesenheitTyp.WorkTime - (absences.AbwesenheitTyp.WorkTime - w.User.ArbeitszeitPerTag) // workTime Equivalent of Absence is capped at user Worktime per Day
|
workTime += time.Duration(absenceWorkTime * float32(time.Hour)).Round(time.Minute)
|
||||||
// workTime += time.Duration(absenceWorkTime * float32(time.Hour)).Round(time.Minute)
|
}
|
||||||
// }
|
|
||||||
return workTime
|
return workTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ func TestNewWorkWeekNoPopulate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCheckStatus(t *testing.T) {
|
func TestCheckStatus(t *testing.T) {
|
||||||
SetupDBFixture(t)
|
|
||||||
testWeek := SetupWorkWeekFixture(t)
|
testWeek := SetupWorkWeekFixture(t)
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
@@ -198,12 +198,12 @@
|
|||||||
.col-span-3 {
|
.col-span-3 {
|
||||||
grid-column: span 3 / span 3;
|
grid-column: span 3 / span 3;
|
||||||
}
|
}
|
||||||
.col-span-5 {
|
|
||||||
grid-column: span 5 / span 5;
|
|
||||||
}
|
|
||||||
.col-span-6 {
|
.col-span-6 {
|
||||||
grid-column: span 6 / span 6;
|
grid-column: span 6 / span 6;
|
||||||
}
|
}
|
||||||
|
.col-span-7 {
|
||||||
|
grid-column: span 7 / span 7;
|
||||||
|
}
|
||||||
.col-span-full {
|
.col-span-full {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
}
|
}
|
||||||
@@ -367,17 +367,17 @@
|
|||||||
.resize {
|
.resize {
|
||||||
resize: both;
|
resize: both;
|
||||||
}
|
}
|
||||||
.auto-rows-min {
|
|
||||||
grid-auto-rows: min-content;
|
|
||||||
}
|
|
||||||
.grid-cols-2 {
|
.grid-cols-2 {
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
.grid-cols-5 {
|
.grid-cols-5 {
|
||||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
.grid-cols-\[3fr_2fr_2fr_2fr_3fr_3fr_3fr\] {
|
.grid-cols-\[auto_1fr_1fr_1fr_1fr_1fr\] {
|
||||||
grid-template-columns: 3fr 2fr 2fr 2fr 3fr 3fr 3fr;
|
grid-template-columns: auto 1fr 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
.grid-cols-\[auto_1fr_1fr_1fr_1fr_1fr_1fr\] {
|
||||||
|
grid-template-columns: auto 1fr 1fr 1fr 1fr 1fr 1fr;
|
||||||
}
|
}
|
||||||
.grid-cols-subgrid {
|
.grid-cols-subgrid {
|
||||||
grid-template-columns: subgrid;
|
grid-template-columns: subgrid;
|
||||||
@@ -432,11 +432,6 @@
|
|||||||
border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
border-bottom-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.divide-neutral-300 {
|
|
||||||
:where(& > :not(:last-child)) {
|
|
||||||
border-color: var(--color-neutral-300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.justify-self-end {
|
.justify-self-end {
|
||||||
justify-self: flex-end;
|
justify-self: flex-end;
|
||||||
}
|
}
|
||||||
@@ -453,14 +448,6 @@
|
|||||||
border-style: var(--tw-border-style);
|
border-style: var(--tw-border-style);
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
}
|
}
|
||||||
.border-r-0 {
|
|
||||||
border-right-style: var(--tw-border-style);
|
|
||||||
border-right-width: 0px;
|
|
||||||
}
|
|
||||||
.border-b-0 {
|
|
||||||
border-bottom-style: var(--tw-border-style);
|
|
||||||
border-bottom-width: 0px;
|
|
||||||
}
|
|
||||||
.border-neutral-200 {
|
.border-neutral-200 {
|
||||||
border-color: var(--color-neutral-200);
|
border-color: var(--color-neutral-200);
|
||||||
}
|
}
|
||||||
@@ -494,6 +481,9 @@
|
|||||||
.mask-repeat {
|
.mask-repeat {
|
||||||
mask-repeat: repeat;
|
mask-repeat: repeat;
|
||||||
}
|
}
|
||||||
|
.p-0 {
|
||||||
|
padding: calc(var(--spacing) * 0);
|
||||||
|
}
|
||||||
.p-1 {
|
.p-1 {
|
||||||
padding: calc(var(--spacing) * 1);
|
padding: calc(var(--spacing) * 1);
|
||||||
}
|
}
|
||||||
@@ -503,6 +493,9 @@
|
|||||||
.p-8 {
|
.p-8 {
|
||||||
padding: calc(var(--spacing) * 8);
|
padding: calc(var(--spacing) * 8);
|
||||||
}
|
}
|
||||||
|
.px-2 {
|
||||||
|
padding-inline: calc(var(--spacing) * 2);
|
||||||
|
}
|
||||||
.px-3 {
|
.px-3 {
|
||||||
padding-inline: calc(var(--spacing) * 3);
|
padding-inline: calc(var(--spacing) * 3);
|
||||||
}
|
}
|
||||||
@@ -537,9 +530,6 @@
|
|||||||
.text-accent {
|
.text-accent {
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
}
|
}
|
||||||
.text-neutral-300 {
|
|
||||||
color: var(--color-neutral-300);
|
|
||||||
}
|
|
||||||
.text-neutral-500 {
|
.text-neutral-500 {
|
||||||
color: var(--color-neutral-500);
|
color: var(--color-neutral-500);
|
||||||
}
|
}
|
||||||
@@ -582,16 +572,6 @@
|
|||||||
--tw-duration: 300ms;
|
--tw-duration: 300ms;
|
||||||
transition-duration: 300ms;
|
transition-duration: 300ms;
|
||||||
}
|
}
|
||||||
.\*\:p-2 {
|
|
||||||
:is(& > *) {
|
|
||||||
padding: calc(var(--spacing) * 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.\*\:text-center {
|
|
||||||
:is(& > *) {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.group-hover\:text-black {
|
.group-hover\:text-black {
|
||||||
&:is(:where(.group):hover *) {
|
&:is(:where(.group):hover *) {
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.943
|
// templ: version: v0.3.833
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.943
|
// templ: version: v0.3.833
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package templates
|
package templates
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"arbeitszeitmessung/helper"
|
|
||||||
"arbeitszeitmessung/models"
|
"arbeitszeitmessung/models"
|
||||||
|
"arbeitszeitmessung/helper"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Time, tsEnd time.Time) {
|
templ PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Time, tsEnd time.Time) {
|
||||||
{{
|
{{
|
||||||
_, kw := tsStart.ISOWeek()
|
_, kw := tsStart.ISOWeek()
|
||||||
noBorder := ""
|
|
||||||
}}
|
}}
|
||||||
@Base()
|
@Base()
|
||||||
<content class="p-8 relative flex flex-col gap-4">
|
<content class="p-8 relative flex flex-col gap-4">
|
||||||
@@ -19,50 +18,33 @@ templ PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Ti
|
|||||||
<p>Arbeitszeit: <span></span></p>
|
<p>Arbeitszeit: <span></span></p>
|
||||||
<p>Überstunden: <span></span></p>
|
<p>Überstunden: <span></span></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-rows-6 grid-cols-[3fr_2fr_2fr_2fr_3fr_3fr_3fr] *:p-2 *:text-center auto-rows-min divide-neutral-300 divide-x-1 divide-y-1">
|
<div class="grid grid-rows-6 grid-cols-[auto_1fr_1fr_1fr_1fr_1fr_1fr] divide-x-1 divide-y-1">
|
||||||
<p class="">{ kw }</p>
|
<p class="p-2 text-center">{ kw }</p>
|
||||||
<p class="">Kommen</p>
|
<p class="p-2 text-center">Kommen</p>
|
||||||
<p class="">Gehen</p>
|
<p class="p-2 text-center">Gehen</p>
|
||||||
<p class="">Arbeitsart</p>
|
<p class="p-2 text-center">Arbeitsart</p>
|
||||||
<p class="">Stunden</p>
|
<p class="p-2 text-center">Stunden gesamt</p>
|
||||||
<p class="">Pause</p>
|
<p class="p-2 text-center">Pause</p>
|
||||||
<p class="border-r-0">Überstunden</p>
|
<p class="p-2 text-center">Überstunden</p>
|
||||||
for index, day := range workDays {
|
for _, day := range workDays{
|
||||||
{{
|
|
||||||
if index == len(workDays)-1 {
|
|
||||||
noBorder = "border-b-0"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
if day.Day.Weekday() == time.Monday {
|
if day.Day.Weekday() == time.Monday {
|
||||||
<p class="col-span-full bg-neutral-300">Wochenende</p>
|
<p class="p-2 col-span-7 text-center bg-neutral-300">Wochenende</p>
|
||||||
}
|
}
|
||||||
<p class={ noBorder }>{ day.Day.Format("02.01.2006") }</p>
|
<p class="p-2 text-center">{ day.Day.Format("02.01.2006") }</p>
|
||||||
|
|
||||||
<div class={ "grid grid-cols-subgrid col-span-3 " + noBorder }>
|
<div class="grid grid-cols-subgrid col-span-3">
|
||||||
for bookingI := 0; bookingI < len(day.Bookings); bookingI+= 2 {
|
for bookingI := 0; bookingI < len(day.Bookings); bookingI+= 2 {
|
||||||
<p>{ day.Bookings[bookingI].Timestamp.Format("15:04") }</p>
|
<p class="p-2 text-center">{ day.Bookings[bookingI].Timestamp.Format("15:04") }</p>
|
||||||
<p>{ day.Bookings[bookingI+1].Timestamp.Format("15:04") }</p>
|
<p class="p-2 text-center">{ day.Bookings[bookingI+1].Timestamp.Format("15:04") }</p>
|
||||||
<p>{ day.Bookings[bookingI].BookingType.Name } </p>
|
<p class="p-2 text-center">{ day.Bookings[bookingI].BookingType.Name } </p>
|
||||||
}
|
|
||||||
if (day.Absence != models.Absence{}) {
|
|
||||||
<p class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</p>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{{ work, pause, overtime := day.GetAllWorkTimes(e) }}
|
{{ work, pause := day.GetWorkTimeString() }}
|
||||||
@ColorDuration(work, noBorder)
|
<p class="p-2 text-center">{ work }</p>
|
||||||
@ColorDuration(pause, noBorder)
|
<p class="p-2 text-center">{ pause }</p>
|
||||||
@ColorDuration(overtime, noBorder + " border-r-0")
|
<p class="p-2 text-center">{ helper.FormatDuration(day.CalcOvertime(e)) }</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</content>
|
</content>
|
||||||
}
|
}
|
||||||
|
|
||||||
templ ColorDuration(d time.Duration, classes string){
|
|
||||||
{{
|
|
||||||
color := ""
|
|
||||||
if d.Abs() < time.Minute{
|
|
||||||
color = "text-neutral-300"
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
<p class={ color + " " + classes }>{ helper.FormatDurationFill(d, true) }</p>
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.943
|
// templ: version: v0.3.833
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
@@ -37,7 +37,6 @@ func PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Tim
|
|||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
|
||||||
_, kw := tsStart.ISOWeek()
|
_, kw := tsStart.ISOWeek()
|
||||||
noBorder := ""
|
|
||||||
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
@@ -49,7 +48,7 @@ func PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Tim
|
|||||||
var templ_7745c5c3_Var2 string
|
var templ_7745c5c3_Var2 string
|
||||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006"))
|
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 18, Col: 52}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 17, Col: 52}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
@@ -62,257 +61,148 @@ func PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Tim
|
|||||||
var templ_7745c5c3_Var3 string
|
var templ_7745c5c3_Var3 string
|
||||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006"))
|
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 18, Col: 98}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 17, Col: 98}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span></p><p>Arbeitszeit: <span></span></p><p>Überstunden: <span></span></p></div><div class=\"grid grid-rows-6 grid-cols-[3fr_2fr_2fr_2fr_3fr_3fr_3fr] *:p-2 *:text-center auto-rows-min divide-neutral-300 divide-x-1 divide-y-1\"><p class=\"\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span></p><p>Arbeitszeit: <span></span></p><p>Überstunden: <span></span></p></div><div class=\"grid grid-rows-6 grid-cols-[auto_1fr_1fr_1fr_1fr_1fr_1fr] divide-x-1 divide-y-1\"><p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var4 string
|
var templ_7745c5c3_Var4 string
|
||||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(kw)
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(kw)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 23, Col: 19}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 22, Col: 34}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</p><p class=\"\">Kommen</p><p class=\"\">Gehen</p><p class=\"\">Arbeitsart</p><p class=\"\">Stunden</p><p class=\"\">Pause</p><p class=\"border-r-0\">Überstunden</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</p><p class=\"p-2 text-center\">Kommen</p><p class=\"p-2 text-center\">Gehen</p><p class=\"p-2 text-center\">Arbeitsart</p><p class=\"p-2 text-center\">Stunden gesamt</p><p class=\"p-2 text-center\">Pause</p><p class=\"p-2 text-center\">Überstunden</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
for index, day := range workDays {
|
for _, day := range workDays {
|
||||||
|
|
||||||
if index == len(workDays)-1 {
|
|
||||||
noBorder = "border-b-0"
|
|
||||||
}
|
|
||||||
if day.Day.Weekday() == time.Monday {
|
if day.Day.Weekday() == time.Monday {
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<p class=\"col-span-full bg-neutral-300\">Wochenende</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<p class=\"p-2 col-span-7 text-center bg-neutral-300\">Wochenende</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " ")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " <p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var5 = []any{noBorder}
|
var templ_7745c5c3_Var5 string
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var5...)
|
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(day.Day.Format("02.01.2006"))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 33, Col: 61}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<p class=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</p><div class=\"grid grid-cols-subgrid col-span-3\">")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
for bookingI := 0; bookingI < len(day.Bookings); bookingI += 2 {
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var6 string
|
var templ_7745c5c3_Var6 string
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var5).String())
|
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI].Timestamp.Format("15:04"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 1, Col: 0}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 37, Col: 82}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</p><p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var7 string
|
var templ_7745c5c3_Var7 string
|
||||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(day.Day.Format("02.01.2006"))
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI+1].Timestamp.Format("15:04"))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 39, Col: 56}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 38, Col: 84}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</p><p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var8 = []any{"grid grid-cols-subgrid col-span-3 " + noBorder}
|
var templ_7745c5c3_Var8 string
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var8...)
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI].BookingType.Name)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 39, Col: 73}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<div class=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</p>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</div>")
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
work, pause := day.GetWorkTimeString()
|
||||||
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var9 string
|
var templ_7745c5c3_Var9 string
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var8).String())
|
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(work)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 1, Col: 0}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 43, Col: 38}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\">")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</p><p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
for bookingI := 0; bookingI < len(day.Bookings); bookingI += 2 {
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<p>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var10 string
|
var templ_7745c5c3_Var10 string
|
||||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI].Timestamp.Format("15:04"))
|
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(pause)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 43, Col: 59}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 44, Col: 39}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</p><p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</p><p class=\"p-2 text-center\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var11 string
|
var templ_7745c5c3_Var11 string
|
||||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI+1].Timestamp.Format("15:04"))
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(day.CalcOvertime(e)))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 44, Col: 61}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 45, Col: 76}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</p><p>")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</p>")
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var12 string
|
|
||||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(day.Bookings[bookingI].BookingType.Name)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 45, Col: 50}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</p>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (day.Absence != models.Absence{}) {
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</div></content>")
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<p class=\"col-span-full\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var13 string
|
|
||||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(day.Absence.AbwesenheitTyp.Name)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 48, Col: 64}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</p>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
work, pause, overtime := day.GetAllWorkTimes(e)
|
|
||||||
templ_7745c5c3_Err = ColorDuration(work, noBorder).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = ColorDuration(pause, noBorder).Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = ColorDuration(overtime, noBorder+" border-r-0").Render(ctx, templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</div></content>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func ColorDuration(d time.Duration, classes string) 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 {
|
|
||||||
return templ_7745c5c3_CtxErr
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
|
||||||
if !templ_7745c5c3_IsBuffer {
|
|
||||||
defer func() {
|
|
||||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
|
||||||
if templ_7745c5c3_Err == nil {
|
|
||||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
ctx = templ.InitializeContext(ctx)
|
|
||||||
templ_7745c5c3_Var14 := templ.GetChildren(ctx)
|
|
||||||
if templ_7745c5c3_Var14 == nil {
|
|
||||||
templ_7745c5c3_Var14 = templ.NopComponent
|
|
||||||
}
|
|
||||||
ctx = templ.ClearChildren(ctx)
|
|
||||||
|
|
||||||
color := ""
|
|
||||||
if d.Abs() < time.Minute {
|
|
||||||
color = "text-neutral-300"
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var15 = []any{color + " " + classes}
|
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var15...)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<p class=\"")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var16 string
|
|
||||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var15).String())
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 1, Col: 0}
|
|
||||||
}
|
|
||||||
_, 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, 23, "\">")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var17 string
|
|
||||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDurationFill(d, true))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 67, Col: 71}
|
|
||||||
}
|
|
||||||
_, 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, 24, "</p>")
|
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.943
|
// templ: version: v0.3.833
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.943
|
// templ: version: v0.3.833
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
Reference in New Issue
Block a user