201 lines
7.0 KiB
Plaintext
201 lines
7.0 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 break-after-page">
|
|
<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] *:not-print:p-2 *:text-center auto-rows-min divide-neutral-300 divide-x-1 divide-y-1">
|
|
<p class="bg-neutral-300 border-neutral-600">{ kw }</p>
|
|
<p class="bg-neutral-300 border-neutral-600">Kommen</p>
|
|
<p class="bg-neutral-300 border-neutral-600">Gehen</p>
|
|
<p class="bg-neutral-300 border-neutral-600">Arbeitsart</p>
|
|
<p class="bg-neutral-300 border-neutral-600">Stunden</p>
|
|
<p class="bg-neutral-300 border-neutral-600">Pause</p>
|
|
<p class="bg-neutral-300 border-neutral-600 border-r-0">Überstunden</p>
|
|
for index, day := range workDays {
|
|
{{
|
|
if index == len(workDays)-1 {
|
|
noBorder = "border-b-0"
|
|
}
|
|
}}
|
|
<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")
|
|
if day.Day.Weekday() == time.Friday {
|
|
<p class="col-span-full bg-neutral-300">Wochenende</p>
|
|
}
|
|
}
|
|
</div>
|
|
</content>
|
|
}
|
|
|
|
templ PDFReportEmployeTable(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 break-after-page">
|
|
<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>
|
|
<table class="*:*:*:border-1 *:text-center border-1 border-collapse">
|
|
<tr>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">{ kw }</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Kommen</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Gehen</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Arbeitsart</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Stunden</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Pause</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7 border-r-0">Überstunden</th>
|
|
</tr>
|
|
for index, day := range workDays {
|
|
{{
|
|
if index == len(workDays)-1 {
|
|
noBorder = "border-b-0"
|
|
}
|
|
}}
|
|
<tr>
|
|
<td class={ noBorder }>{ day.Day.Format("02.01.2006") }</td>
|
|
<td colspan="3">
|
|
<table class={ "w-full border-collapse" + noBorder }>
|
|
for bookingI := 0; bookingI < len(day.Bookings); bookingI+= 2 {
|
|
<tr class="flex">
|
|
<td class="border-r-1 grow">{ day.Bookings[bookingI].Timestamp.Format("15:04") }</td>
|
|
<td class="border-r-1 grow">{ day.Bookings[bookingI+1].Timestamp.Format("15:04") }</td>
|
|
<td class="grow">{ day.Bookings[bookingI].BookingType.Name } </td>
|
|
</tr>
|
|
}
|
|
if (day.Absence != models.Absence{}) {
|
|
if len(day.Bookings) > 0 {
|
|
<tr class="border-t-1">
|
|
<td colspan="2" class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</td>
|
|
</tr>
|
|
}
|
|
else {
|
|
<tr>
|
|
<td colspan="2" class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</td>
|
|
</tr>
|
|
}
|
|
|
|
}
|
|
</table>
|
|
</td>
|
|
{{ work, pause, overtime := day.GetAllWorkTimes(e) }}
|
|
@ColorDuration(work, noBorder)
|
|
@ColorDuration(pause, noBorder)
|
|
@ColorDuration(overtime, noBorder + " border-r-0")
|
|
if day.Day.Weekday() == time.Friday {
|
|
<tr>
|
|
<td colspan="7" class="col-span-full bg-neutral-300">Wochenende</td>
|
|
</tr>
|
|
}
|
|
</tr>
|
|
}
|
|
</table>
|
|
</content>
|
|
<div class="p-8 relative flex flex-col gap-4 break-after-page">
|
|
<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>
|
|
<table class="*:*:*:border-1 *:text-center border-1 border-collapse">
|
|
<tr>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">{ kw }</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Kommen</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Gehen</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Arbeitsart</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Stunden</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7">Pause</th>
|
|
<th class="bg-neutral-300 border-neutral-600 w-1/7 border-r-0">Überstunden</th>
|
|
</tr>
|
|
for index, day := range workDays {
|
|
{{
|
|
if index == len(workDays)-1 {
|
|
noBorder = "border-b-0"
|
|
}
|
|
}}
|
|
<tr>
|
|
<td class={ noBorder }>{ day.Day.Format("02.01.2006") }</td>
|
|
<td colspan="3">
|
|
<table class={ "w-full border-collapse" + noBorder }>
|
|
for bookingI := 0; bookingI < len(day.Bookings); bookingI+= 2 {
|
|
<tr class="flex">
|
|
<td class="border-r-1 grow">{ day.Bookings[bookingI].Timestamp.Format("15:04") }</td>
|
|
<td class="border-r-1 grow">{ day.Bookings[bookingI+1].Timestamp.Format("15:04") }</td>
|
|
<td class="grow">{ day.Bookings[bookingI].BookingType.Name } </td>
|
|
</tr>
|
|
}
|
|
if (day.Absence != models.Absence{}) {
|
|
if len(day.Bookings) > 0 {
|
|
<tr class="border-t-1">
|
|
<td colspan="2" class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</td>
|
|
</tr>
|
|
}
|
|
else {
|
|
<tr>
|
|
<td colspan="2" class="col-span-full">{ day.Absence.AbwesenheitTyp.Name }</td>
|
|
</tr>
|
|
}
|
|
|
|
}
|
|
</table>
|
|
</td>
|
|
{{ work, pause, overtime := day.GetAllWorkTimes(e) }}
|
|
@ColorDuration(work, noBorder)
|
|
@ColorDuration(pause, noBorder)
|
|
@ColorDuration(overtime, noBorder + " border-r-0")
|
|
if day.Day.Weekday() == time.Friday {
|
|
<tr>
|
|
<td colspan="7" class="col-span-full bg-neutral-300">Wochenende</td>
|
|
</tr>
|
|
}
|
|
</tr>
|
|
}
|
|
</table>
|
|
</div>
|
|
}
|
|
|
|
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>
|
|
}
|