Files
arbeitszeitmessung/Backend/templates/pdf.templ
tom 2d0b117403
All checks were successful
Tests / Run Go Tests (push) Successful in 33s
added Gleitzeit + Kurzarbeit closes #23
2025-09-13 14:12:39 +02:00

69 lines
2.1 KiB
Plaintext

package templates
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
"time"
)
templ PDFReportEmploye(e models.User, workDays []models.WorkDay, tsStart time.Time, tsEnd time.Time) {
{{
_, kw := tsStart.ISOWeek()
noBorder := ""
}}
@Base()
<content class="p-8 relative flex flex-col gap-4">
<div>
<h1 class="text-2xl font-bold">Kim Mustermensch</h1>
<p>Zeitraum: <span>{ tsStart.Format("02.01.2006") }</span> - <span>{ tsEnd.Format("02.01.2006") }</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="">{ kw }</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>
for index, day := range workDays {
{{
if index == len(workDays)-1 {
noBorder = "border-b-0"
}
}}
if day.Day.Weekday() == time.Monday {
<p class="col-span-full bg-neutral-300">Wochenende</p>
}
<p class={ noBorder }>{ day.Day.Format("02.01.2006") }</p>
<div class={ "grid grid-cols-subgrid col-span-3 " + noBorder }>
for bookingI := 0; bookingI < len(day.Bookings); bookingI+= 2 {
<p>{ day.Bookings[bookingI].Timestamp.Format("15:04") }</p>
<p>{ day.Bookings[bookingI+1].Timestamp.Format("15:04") }</p>
<p>{ day.Bookings[bookingI].BookingType.Name } </p>
}
if (day.Absence != models.Absence{}) {
<p class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</p>
}
</div>
{{ work, pause, overtime := day.GetAllWorkTimes(e) }}
@ColorDuration(work, noBorder)
@ColorDuration(pause, noBorder)
@ColorDuration(overtime, noBorder + " border-r-0")
}
</div>
</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>
}