Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74bce88cc0 | |||
| 5a5e776e8b | |||
| 02b5d88d34 | |||
| 6ab48eb534 | |||
| 7e5eaebca9 | |||
| ac59d2642f | |||
| cf5238f024 | |||
| 4bc5594dc5 | |||
| a634b7a69e | |||
| e1f0f85401 | |||
| b6644f3584 | |||
| 7eda8eb538 | |||
| 0d7696cbc6 | |||
| 5001f24d9b | |||
| ea8e78fd9f | |||
| 6da58d6753 | |||
| 89eb5d255d | |||
| 1b8fb747e8 | |||
| 74cded42d8 | |||
| 22350142fc | |||
| 659fb80049 | |||
| cbc4028f8d | |||
| e4d423385a | |||
| c9c2d801b0 | |||
| 94c7c8a36e | |||
| d69ec600cd | |||
| 95d5c4ab9d | |||
| bf841ad5c6 | |||
| a1aae9dc56 | |||
| 750fb1ff58 | |||
| f4e9915e7f | |||
| 18046bbe18 |
@@ -2,7 +2,8 @@ name: Arbeitszeitmessung Deploy
|
||||
run-name: ${{ gitea.actor }} is building and deploying arbeitszeitmesssung
|
||||
on:
|
||||
push:
|
||||
tags: "*"
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
testing:
|
||||
|
||||
@@ -15,15 +15,17 @@ jobs:
|
||||
POSTGRES_DB: arbeitszeitmessung
|
||||
env:
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_API_USER: root
|
||||
POSTGRES_API_PASS: password
|
||||
POSTGRES_DB: arbeitszeitmessung
|
||||
POSTGRES_PORT: 5432
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
with:
|
||||
# Disabling shallow clone is recommended for improving relevancy of reporting
|
||||
fetch-depth: 0
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
@@ -45,4 +47,25 @@ jobs:
|
||||
restore-keys: |-
|
||||
arbeitszeitmessung-
|
||||
- name: Run Go Tests
|
||||
run: cd Backend && go test ./...
|
||||
run: cd Backend && mkdir .test && go test ./... -coverprofile=.test/coverage.out -json > .test/report.json
|
||||
- name: Verify coverage report exists
|
||||
run: |
|
||||
if [ -f "Backend/.test/coverage.out" ]; then
|
||||
echo "Coverage report found"
|
||||
else
|
||||
echo "Coverage report not found"
|
||||
fi
|
||||
- uses: SonarSource/sonarqube-scan-action@v6
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||
with:
|
||||
projectBaseDir: Backend
|
||||
args: >
|
||||
-Dsonar.projectVersion=${{ gitea.sha_short }}
|
||||
- uses: SonarSource/sonarqube-quality-gate-action@v1
|
||||
timeout-minutes: 5
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
with:
|
||||
scanMetadataReportFile: Backend/.scannerwork/report-task.txt
|
||||
|
||||
@@ -13,7 +13,7 @@ RUN go mod download && go mod verify
|
||||
COPY . .
|
||||
RUN go build -o server .
|
||||
|
||||
FROM alpine
|
||||
FROM alpine:3.22
|
||||
RUN apk add --no-cache tzdata
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/server /app/server
|
||||
|
||||
@@ -14,7 +14,8 @@ func OpenDatabase() (models.IDatabase, error) {
|
||||
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
||||
dbUser := helper.GetEnv("POSTGRES_API_USER", "api_nutzer")
|
||||
dbPassword := helper.GetEnv("POSTGRES_API_PASS", "password")
|
||||
dbTz := helper.GetEnv("TZ", "Europe/Berlin")
|
||||
|
||||
connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable&TimeZone=Europe/Berlin", dbUser, dbPassword, dbHost, dbName)
|
||||
connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable&TimeZone=%s", dbUser, dbPassword, dbHost, dbName, dbTz)
|
||||
return sql.Open("postgres", connStr)
|
||||
}
|
||||
|
||||
229
Backend/endpoints/pdf-create.go
Normal file
229
Backend/endpoints/pdf-create.go
Normal file
@@ -0,0 +1,229 @@
|
||||
package endpoints
|
||||
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/helper/paramParser"
|
||||
"arbeitszeitmessung/models"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/Dadido3/go-typst"
|
||||
)
|
||||
|
||||
const DE_DATE string = "02.01.2006"
|
||||
|
||||
func convertDaysToTypst(days []models.IWorkDay, u models.User) ([]typstDay, error) {
|
||||
var typstDays []typstDay
|
||||
for _, day := range days {
|
||||
var thisTypstDay typstDay
|
||||
work, pause, overtime := day.GetTimesVirtual(u, models.WorktimeBaseWeek)
|
||||
thisTypstDay.Date = day.Date().Format(DE_DATE)
|
||||
thisTypstDay.Worktime = helper.FormatDurationFill(work, true)
|
||||
thisTypstDay.Pausetime = helper.FormatDurationFill(pause, true)
|
||||
thisTypstDay.Overtime = helper.FormatDurationFill(overtime, true)
|
||||
thisTypstDay.IsFriday = day.Date().Weekday() == time.Friday
|
||||
|
||||
thisTypstDay.DayParts = convertDayToTypstDayParts(day, u)
|
||||
typstDays = append(typstDays, thisTypstDay)
|
||||
}
|
||||
return typstDays, nil
|
||||
}
|
||||
|
||||
func convertDayToTypstDayParts(day models.IWorkDay, user models.User) []typstDayPart {
|
||||
var typstDayParts []typstDayPart
|
||||
if day.IsWorkDay() {
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
for i := 0; i < len(workDay.Bookings); i += 2 {
|
||||
var typstDayPart typstDayPart
|
||||
typstDayPart.BookingFrom = workDay.Bookings[i].Timestamp.Format("15:04")
|
||||
typstDayPart.BookingTo = workDay.Bookings[i+1].Timestamp.Format("15:04")
|
||||
typstDayPart.WorkType = workDay.Bookings[i].BookingType.Name
|
||||
typstDayPart.IsWorkDay = true
|
||||
typstDayParts = append(typstDayParts, typstDayPart)
|
||||
}
|
||||
if day.IsKurzArbeit() {
|
||||
tsFrom, tsTo := workDay.GenerateKurzArbeitBookings(user)
|
||||
typstDayParts = append(typstDayParts, typstDayPart{
|
||||
BookingFrom: tsFrom.Format("15:04"),
|
||||
BookingTo: tsTo.Format("15:04"),
|
||||
WorkType: "Kurzarbeit",
|
||||
IsWorkDay: true,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
absentDay, _ := day.(*models.Absence)
|
||||
typstDayParts = append(typstDayParts, typstDayPart{IsWorkDay: false, WorkType: absentDay.AbwesenheitTyp.Name})
|
||||
}
|
||||
return typstDayParts
|
||||
}
|
||||
|
||||
func renderPDF(days []typstDay, metadata typstMetadata) (bytes.Buffer, error) {
|
||||
var markup bytes.Buffer
|
||||
var output bytes.Buffer
|
||||
|
||||
if err := typst.InjectValues(&markup, map[string]any{"meta": metadata, "days": days}); err != nil {
|
||||
return output, err
|
||||
}
|
||||
|
||||
// Import the template and invoke the template function with the custom data.
|
||||
// Show is used to replace the current document with whatever content the template function in `template.typ` returns.
|
||||
markup.WriteString(`
|
||||
#import "templates/abrechnung.typ": abrechnung
|
||||
#show: doc => abrechnung(meta, days)
|
||||
`)
|
||||
|
||||
// Compile the prepared markup with Typst and write the result it into `output.pdf`.
|
||||
// f, err := os.Create("output.pdf")
|
||||
// if err != nil {
|
||||
// log.Panicf("Failed to create output file: %v.", err)
|
||||
// }
|
||||
// defer f.Close()
|
||||
//
|
||||
|
||||
// typstCLI := typst.CLI{}
|
||||
typstCLI := typst.DockerExec{
|
||||
ContainerName: helper.GetEnv("TYPST_CONTAINER", "arbeitszeitmessung-doc-creator"),
|
||||
}
|
||||
if err := typstCLI.Compile(&markup, &output, nil); err != nil {
|
||||
return output, err
|
||||
}
|
||||
return output, nil
|
||||
}
|
||||
|
||||
func PDFCreateController(w http.ResponseWriter, r *http.Request) {
|
||||
helper.RequiresLogin(Session, w, r)
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
user, err := models.GetUserFromSession(Session, r.Context())
|
||||
if err != nil {
|
||||
log.Println("Error getting user!")
|
||||
return
|
||||
}
|
||||
pp := paramParser.New(r.URL.Query())
|
||||
startDate := pp.ParseTimestampFallback("start_date", time.DateOnly, time.Now())
|
||||
var members []models.User = make([]models.User, 0)
|
||||
output, err := createReports(user, members, startDate)
|
||||
if err != nil {
|
||||
slog.Warn("Could not create pdf report", slog.Any("Error", err))
|
||||
}
|
||||
|
||||
w.Header().Set("Content-type", "application/pdf")
|
||||
output.WriteTo(w)
|
||||
w.WriteHeader(200)
|
||||
|
||||
default:
|
||||
http.Error(w, "Method not allowed!", http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
func createReports(user models.User, employes []models.User, startDate time.Time) (bytes.Buffer, error) {
|
||||
if startDate.Day() > 1 {
|
||||
startDate = startDate.AddDate(0, 0, -(startDate.Day() - 1))
|
||||
}
|
||||
endDate := startDate.AddDate(0, 1, -1)
|
||||
return createEmployeReport(user, startDate, endDate)
|
||||
}
|
||||
|
||||
func createEmployeReport(employee models.User, startDate, endDate time.Time) (bytes.Buffer, error) {
|
||||
targetHours := (employee.ArbeitszeitProWoche() / 5) * time.Duration(helper.GetWorkingDays(startDate, endDate))
|
||||
workingDays := models.GetDays(employee, startDate, endDate, false)
|
||||
|
||||
slog.Debug("Baseline Working hours", "targetHours", targetHours.Hours())
|
||||
|
||||
var actualHours time.Duration
|
||||
for _, day := range workingDays {
|
||||
actualHours += day.TimeWorkVirtual(employee)
|
||||
}
|
||||
worktimeBalance := actualHours - targetHours
|
||||
|
||||
typstDays, err := convertDaysToTypst(workingDays, employee)
|
||||
if err != nil {
|
||||
log.Panicf("Failed to convert days!")
|
||||
}
|
||||
|
||||
metadata := typstMetadata{
|
||||
EmployeeName: fmt.Sprintf("%s %s", employee.Vorname, employee.Name),
|
||||
TimeRange: fmt.Sprintf("%s - %s", startDate.Format(DE_DATE), endDate.Format(DE_DATE)),
|
||||
Overtime: helper.FormatDurationFill(worktimeBalance, true),
|
||||
WorkTime: helper.FormatDurationFill(actualHours, true),
|
||||
OvertimeTotal: "",
|
||||
CurrentTimestamp: time.Now().Format("02.01.2006 - 15:04 Uhr"),
|
||||
}
|
||||
|
||||
return renderPDF(typstDays, metadata)
|
||||
}
|
||||
|
||||
func PDFHandler(w http.ResponseWriter, r *http.Request) {
|
||||
helper.RequiresLogin(Session, w, r)
|
||||
startDate := time.Now()
|
||||
|
||||
if startDate.Day() > 1 {
|
||||
startDate = startDate.AddDate(0, 0, -(startDate.Day() - 1))
|
||||
}
|
||||
endDate := startDate.AddDate(0, 1, -1)
|
||||
|
||||
user, err := models.GetUserFromSession(Session, r.Context())
|
||||
if err != nil {
|
||||
log.Println("Error getting user!")
|
||||
}
|
||||
|
||||
//TODO: only accepted weeks
|
||||
|
||||
weeks := models.GetDays(user, startDate, endDate, false)
|
||||
var aggregatedOvertime, aggregatedWorkTime time.Duration
|
||||
for _, day := range weeks {
|
||||
aggregatedOvertime += day.TimeOvertimeReal(user)
|
||||
aggregatedWorkTime += day.TimeWorkVirtual(user)
|
||||
}
|
||||
|
||||
typstDays, err := convertDaysToTypst(weeks, user)
|
||||
if err != nil {
|
||||
log.Panicf("Failed to convert days!")
|
||||
}
|
||||
metadata := typstMetadata{
|
||||
EmployeeName: fmt.Sprintf("%s %s", user.Vorname, user.Name),
|
||||
TimeRange: fmt.Sprintf("%s - %s", startDate.Format(DE_DATE), endDate.Format(DE_DATE)),
|
||||
Overtime: helper.FormatDurationFill(aggregatedOvertime, true),
|
||||
WorkTime: helper.FormatDurationFill(aggregatedWorkTime, true),
|
||||
OvertimeTotal: "",
|
||||
CurrentTimestamp: time.Now().Format("02.01.2006 - 15:04 Uhr"),
|
||||
}
|
||||
|
||||
output, err := renderPDF(typstDays, metadata)
|
||||
if err != nil {
|
||||
slog.Warn("Could not create pdf report", slog.Any("Error", err))
|
||||
}
|
||||
|
||||
w.Header().Set("Content-type", "application/pdf")
|
||||
output.WriteTo(w)
|
||||
w.WriteHeader(200)
|
||||
}
|
||||
|
||||
type typstMetadata struct {
|
||||
TimeRange string `json:"time-range"`
|
||||
EmployeeName string `json:"employee-name"`
|
||||
WorkTime string `json:"worktime"`
|
||||
Overtime string `json:"overtime"`
|
||||
OvertimeTotal string `json:"overtime-total"`
|
||||
CurrentTimestamp string `json:"current-timestamp"`
|
||||
}
|
||||
|
||||
type typstDayPart struct {
|
||||
BookingFrom string `json:"booking-from"`
|
||||
BookingTo string `json:"booking-to"`
|
||||
WorkType string `json:"worktype"`
|
||||
IsWorkDay bool `json:"is-workday"`
|
||||
}
|
||||
|
||||
type typstDay struct {
|
||||
Date string `json:"date"`
|
||||
DayParts []typstDayPart `json:"day-parts"`
|
||||
Worktime string `json:"worktime"`
|
||||
Pausetime string `json:"pausetime"`
|
||||
Overtime string `json:"overtime"`
|
||||
IsFriday bool `json:"is-weekend"`
|
||||
}
|
||||
@@ -4,38 +4,22 @@ import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/models"
|
||||
"arbeitszeitmessung/templates"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func PDFHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func PDFFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||
helper.RequiresLogin(Session, w, r)
|
||||
startDate, err := parseTimestamp(r, "start", time.Now().Format("2006-01-02"))
|
||||
if err != nil {
|
||||
log.Println("Error parsing 'start_date' time", err)
|
||||
http.Error(w, "Timestamp 'start_date' cannot be parsed!", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if startDate.Day() > 1 {
|
||||
startDate = startDate.AddDate(0, 0, -(startDate.Day() - 1))
|
||||
}
|
||||
endDate := startDate.AddDate(0, 1, -1)
|
||||
|
||||
user, err := models.GetUserFromSession(Session, r.Context())
|
||||
if err != nil {
|
||||
log.Println("Error getting user!")
|
||||
slog.Warn("Error getting user!", slog.Any("Error", err))
|
||||
// TODO add error handling
|
||||
}
|
||||
|
||||
//TODO: only accepted weeks
|
||||
|
||||
weeks := models.GetDays(user, startDate, endDate, false)
|
||||
var aggregatedOvertime, aggregatedWorkTime time.Duration
|
||||
for _, day := range weeks {
|
||||
aggregatedOvertime += day.TimeOvertimeReal(user)
|
||||
aggregatedWorkTime += day.TimeWorkVirtual(user)
|
||||
teamMembers, err := user.GetTeamMembers()
|
||||
if err != nil {
|
||||
slog.Warn("Error getting team members!", slog.Any("Error", err))
|
||||
}
|
||||
|
||||
// log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
|
||||
templates.PDFReportEmploye(user, aggregatedOvertime, aggregatedWorkTime, weeks, startDate, endDate).Render(r.Context(), w)
|
||||
templates.PDFForm(teamMembers).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package endpoints
|
||||
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/helper/paramParser"
|
||||
"arbeitszeitmessung/models"
|
||||
"arbeitszeitmessung/templates"
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -30,17 +30,17 @@ func submitReport(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Error parsing form", err)
|
||||
return
|
||||
}
|
||||
userPN, _ := strconv.Atoi(r.FormValue("user"))
|
||||
_weekTs := r.FormValue("week")
|
||||
weekTs, err := time.Parse(time.DateOnly, _weekTs)
|
||||
pp := paramParser.New(r.Form)
|
||||
userPN, err := pp.ParseInt("user")
|
||||
weekTs := pp.ParseTimestampFallback("week", time.DateOnly, time.Now())
|
||||
user, err := models.GetUserByPersonalNr(userPN)
|
||||
workWeek := models.NewWorkWeek(user, weekTs, true)
|
||||
|
||||
if err != nil {
|
||||
log.Println("Could not get user!")
|
||||
return
|
||||
}
|
||||
|
||||
workWeek := models.NewWorkWeek(user, weekTs, true)
|
||||
|
||||
switch r.FormValue("method") {
|
||||
case "send":
|
||||
err = workWeek.SendWeek()
|
||||
@@ -62,14 +62,11 @@ func showWeeks(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
submissionDate := r.URL.Query().Get("submission_date")
|
||||
lastSub := user.GetLastWorkWeekSubmission()
|
||||
if submissionDate != "" {
|
||||
submissionDate, err := time.Parse("2006-01-02", submissionDate)
|
||||
if err == nil {
|
||||
lastSub = helper.GetMonday(submissionDate)
|
||||
}
|
||||
}
|
||||
|
||||
pp := paramParser.New(r.URL.Query())
|
||||
submissionDate := pp.ParseTimestampFallback("submission_date", time.DateOnly, user.GetLastWorkWeekSubmission())
|
||||
lastSub := helper.GetMonday(submissionDate)
|
||||
|
||||
userWeek := models.NewWorkWeek(user, lastSub, true)
|
||||
|
||||
var workWeeks []models.WorkWeek
|
||||
|
||||
@@ -2,14 +2,15 @@ package endpoints
|
||||
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/helper/paramParser"
|
||||
"arbeitszeitmessung/models"
|
||||
"arbeitszeitmessung/templates"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
@@ -52,7 +53,7 @@ func parseTimestamp(r *http.Request, getKey string, fallback string) (time.Time,
|
||||
if getTimestamp == "" {
|
||||
getTimestamp = fallback
|
||||
}
|
||||
Timestamp, err := time.Parse("2006-01-02", getTimestamp)
|
||||
Timestamp, err := time.Parse(time.DateOnly, getTimestamp)
|
||||
if err != nil {
|
||||
return time.Now(), err
|
||||
}
|
||||
@@ -67,26 +68,15 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
pp := paramParser.New(r.URL.Query())
|
||||
|
||||
// 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
|
||||
}
|
||||
tsFrom := pp.ParseTimestampFallback("time_from", time.DateOnly, time.Now().AddDate(0, -1, 0))
|
||||
tsTo := pp.ParseTimestampFallback("time_to", time.DateOnly, time.Now())
|
||||
|
||||
tsTo = tsTo.AddDate(0, 0, 1) // so that today is inside
|
||||
|
||||
days := models.GetDays(user, tsFrom, tsTo, true)
|
||||
sort.Slice(days, func(i, j int) bool {
|
||||
return days[i].Date().After(days[j].Date())
|
||||
})
|
||||
|
||||
lastSub := user.GetLastWorkWeekSubmission()
|
||||
var aggregatedOvertime time.Duration
|
||||
@@ -116,6 +106,7 @@ func getBookings(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func updateBooking(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
pp := paramParser.New(r.Form)
|
||||
var loc *time.Location
|
||||
loc, err := time.LoadLocation(helper.GetEnv("TZ", "Europe/Berlin"))
|
||||
if err != nil {
|
||||
@@ -136,10 +127,9 @@ func updateBooking(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var check_in_out int
|
||||
check_in_out, err = strconv.Atoi(r.FormValue("check_in_out"))
|
||||
check_in_out, err := pp.ParseInt("check_in_out")
|
||||
if err != nil {
|
||||
log.Println("Error parsing check_in_out", err)
|
||||
slog.Warn("Error parsing check_in_out")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -193,13 +183,13 @@ func updateAbsence(r *http.Request) error {
|
||||
loc = time.Local
|
||||
}
|
||||
|
||||
dateFrom, err := time.ParseInLocation("2006-01-02", r.FormValue("date_from"), loc)
|
||||
dateFrom, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_from"), loc)
|
||||
if err != nil {
|
||||
log.Println("Error parsing date_from input for absence", err)
|
||||
return err
|
||||
}
|
||||
|
||||
dateTo, err := time.ParseInLocation("2006-01-02", r.FormValue("date_to"), loc)
|
||||
dateTo, err := time.ParseInLocation(time.DateOnly, r.FormValue("date_to"), loc)
|
||||
if err != nil {
|
||||
log.Println("Error parsing date_to input for absence", err)
|
||||
return err
|
||||
@@ -261,22 +251,3 @@ func updateAbsence(r *http.Request) error {
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func createAbsence(absenceType int, user models.User, loc *time.Location, r *http.Request) {
|
||||
absenceDate, err := time.ParseInLocation("2006-01-02", r.FormValue("date"), loc)
|
||||
if err != nil {
|
||||
log.Println("Cannot get date from input! Skipping absence creation", err)
|
||||
return
|
||||
}
|
||||
|
||||
absence, err := models.NewAbsence(user.CardUID, absenceType, absenceDate)
|
||||
if err != nil {
|
||||
log.Println("Error creating absence!", err)
|
||||
return
|
||||
}
|
||||
err = absence.Insert()
|
||||
if err != nil {
|
||||
log.Println("Error inserting absence!", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,5 @@ func showUserPage(w http.ResponseWriter, r *http.Request, status int) {
|
||||
if user, err := models.GetUserFromSession(Session, r.Context()); err == nil {
|
||||
ctx = context.WithValue(r.Context(), "user", user)
|
||||
}
|
||||
templates.UserPage(status).Render(ctx, w)
|
||||
templates.SettingsPage(status).Render(ctx, w)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ require github.com/a-h/templ v0.3.943
|
||||
require github.com/alexedwards/scs/v2 v2.8.0
|
||||
|
||||
require (
|
||||
github.com/Dadido3/go-typst v0.8.0
|
||||
github.com/golang-migrate/migrate/v4 v4.18.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
)
|
||||
@@ -16,6 +17,14 @@ require (
|
||||
require (
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/smasher164/xid v0.1.2 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/mod v0.29.0 // indirect
|
||||
golang.org/x/sync v0.17.0 // indirect
|
||||
golang.org/x/sys v0.37.0 // indirect
|
||||
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/tools v0.38.0 // indirect
|
||||
)
|
||||
|
||||
tool golang.org/x/tools/cmd/deadcode
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/Dadido3/go-typst v0.8.0 h1:uTLYprhkrBjwsCXRRuyYUFL0fpYHa2kIYoOB/CGqVNs=
|
||||
github.com/Dadido3/go-typst v0.8.0/go.mod h1:QYis9sT70u65kn1SkFfyPRmHsPxgoxWbAixwfPReOZA=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/a-h/templ v0.3.943 h1:o+mT/4yqhZ33F3ootBiHwaY4HM5EVaOJfIshvd5UNTY=
|
||||
@@ -54,6 +56,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/smasher164/xid v0.1.2 h1:erplXSdBRIIw+MrwjJ/m8sLN2XY16UGzpTA0E2Ru6HA=
|
||||
github.com/smasher164/xid v0.1.2/go.mod h1:tgivm8CQl19fH1c5y+8F4mA+qY6n2i6qDRBlY/6nm+I=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
@@ -68,7 +72,19 @@ 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.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
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.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 h1:LvzTn0GQhWuvKH/kVRS3R3bVAsdQWI7hvfLHGgh9+lU=
|
||||
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -14,7 +14,7 @@ type FileLog struct {
|
||||
var Logs map[string]FileLog = make(map[string]FileLog)
|
||||
|
||||
func NewAudit() (i *log.Logger, close func() error) {
|
||||
LOG_FILE := "logs/" + time.Now().Format("2006-01-02") + ".log"
|
||||
LOG_FILE := "logs/" + time.Now().Format(time.DateOnly) + ".log"
|
||||
logFile, err := os.OpenFile(LOG_FILE, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
|
||||
93
Backend/helper/paramParser/main.go
Normal file
93
Backend/helper/paramParser/main.go
Normal file
@@ -0,0 +1,93 @@
|
||||
package paramParser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ParamsParser struct {
|
||||
urlParams url.Values
|
||||
}
|
||||
|
||||
type NoValueError struct {
|
||||
Key string
|
||||
}
|
||||
|
||||
func (e *NoValueError) Error() string {
|
||||
return fmt.Sprintf("No value found for key %s", e.Key)
|
||||
}
|
||||
|
||||
func New(params url.Values) ParamsParser {
|
||||
return ParamsParser{
|
||||
urlParams: params,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseTimestampFallback(key string, format string, fallback time.Time) time.Time {
|
||||
if !p.urlParams.Has(key) {
|
||||
return fallback
|
||||
}
|
||||
paramTimestamp := p.urlParams.Get(key)
|
||||
if timestamp, err := time.Parse(format, paramTimestamp); err == nil {
|
||||
return timestamp
|
||||
} else {
|
||||
slog.Warn("Error parsing HTTP Params to time.Time", slog.Any("key", key), slog.Any("error", err))
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseTimestamp(key string, format string) (time.Time, error) {
|
||||
if !p.urlParams.Has(key) {
|
||||
return time.Time{}, &NoValueError{Key: key}
|
||||
}
|
||||
paramTimestamp := p.urlParams.Get(key)
|
||||
if timestamp, err := time.Parse(format, paramTimestamp); err == nil {
|
||||
return timestamp, nil
|
||||
} else {
|
||||
slog.Debug("Error parsing HTTP Params to time.Time", slog.Any("key", key), slog.Any("error", err))
|
||||
return timestamp, err
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseStringFallback(key string, fallback string) string {
|
||||
if !p.urlParams.Has(key) {
|
||||
return fallback
|
||||
}
|
||||
return p.urlParams.Get(key)
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseString(key string, fallback string) (string, error) {
|
||||
if !p.urlParams.Has(key) {
|
||||
return "", &NoValueError{Key: key}
|
||||
}
|
||||
return p.urlParams.Get(key), nil
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseIntFallback(key string, fallback int) int {
|
||||
if !p.urlParams.Has(key) {
|
||||
return fallback
|
||||
}
|
||||
paramInt := p.urlParams.Get(key)
|
||||
if result, err := strconv.Atoi(paramInt); err == nil {
|
||||
return result
|
||||
} else {
|
||||
slog.Warn("Error parsing HTTP Params to Int", slog.Any("key", key), slog.Any("error", err))
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ParamsParser) ParseInt(key string) (int, error) {
|
||||
if !p.urlParams.Has(key) {
|
||||
return 0, &NoValueError{Key: key}
|
||||
}
|
||||
paramInt := p.urlParams.Get(key)
|
||||
if result, err := strconv.Atoi(paramInt); err == nil {
|
||||
return result, nil
|
||||
} else {
|
||||
slog.Debug("Error parsing HTTP Params to Int", slog.Any("key", key), slog.Any("error", err))
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
@@ -55,3 +55,23 @@ func FormatDurationFill(d time.Duration, fill bool) string {
|
||||
func IsSameDate(a, b time.Time) bool {
|
||||
return a.Truncate(24 * time.Hour).Equal(b.Truncate(24 * time.Hour))
|
||||
}
|
||||
|
||||
func GetWorkingDays(startDate, endDate time.Time) int {
|
||||
if endDate.Before(startDate) {
|
||||
return 0
|
||||
}
|
||||
var count int = 0
|
||||
for d := startDate.Truncate(24 * time.Hour); !d.After(endDate); d = d.Add(24 * time.Hour) {
|
||||
if !IsWeekend(d) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func FormatGermanDayOfWeek(t time.Time) string {
|
||||
return days[t.Weekday()][:2]
|
||||
}
|
||||
|
||||
var days = [...]string{
|
||||
"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package helper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetMonday(t *testing.T) {
|
||||
isMonday, err := time.Parse("2006-01-02", "2025-07-14")
|
||||
notMonday, err := time.Parse("2006-01-02", "2025-07-16")
|
||||
isMonday, err := time.Parse(time.DateOnly, "2025-07-14")
|
||||
notMonday, err := time.Parse(time.DateOnly, "2025-07-16")
|
||||
if err != nil || isMonday.Equal(notMonday) {
|
||||
t.Errorf("U stupid? %e", err)
|
||||
}
|
||||
@@ -17,7 +18,7 @@ func TestGetMonday(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatDuration(t *testing.T) {
|
||||
durations := []struct {
|
||||
testCases := []struct {
|
||||
name string
|
||||
duration time.Duration
|
||||
}{
|
||||
@@ -27,11 +28,57 @@ func TestFormatDuration(t *testing.T) {
|
||||
{"-1h 30min", time.Duration(-90 * time.Minute)},
|
||||
{"", 0},
|
||||
}
|
||||
for _, d := range durations {
|
||||
t.Run(d.name, func(t *testing.T) {
|
||||
if FormatDuration(d.duration) != d.name {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if FormatDuration(tc.duration) != tc.name {
|
||||
t.Error("Format missmatch in Formatduration.")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetWorkingDays(t *testing.T) {
|
||||
testCases := []struct {
|
||||
start string
|
||||
end string
|
||||
days int
|
||||
}{
|
||||
{"2025-10-01", "2025-10-02", 2},
|
||||
{"2025-10-02", "2025-10-01", 0},
|
||||
{"2025-10-01", "2025-10-31", 23},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("WorkingDayTest: %d days", tc.days), func(t *testing.T) {
|
||||
startDate, _ := time.Parse(time.DateOnly, tc.start)
|
||||
endDate, _ := time.Parse(time.DateOnly, tc.end)
|
||||
if GetWorkingDays(startDate, endDate) != tc.days {
|
||||
t.Error("Calculated workdays do not match target")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatGermanDayOfWeek(t *testing.T) {
|
||||
testCases := []struct {
|
||||
date string
|
||||
result string
|
||||
}{
|
||||
{"2025-12-01", "Mo"},
|
||||
{"2025-12-02", "Di"},
|
||||
{"2025-12-03", "Mi"},
|
||||
{"2025-12-04", "Do"},
|
||||
{"2025-12-05", "Fr"},
|
||||
{"2025-12-06", "Sa"},
|
||||
{"2025-12-07", "So"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("FormatWeekDayTest: %s date", tc.date), func(t *testing.T) {
|
||||
date, _ := time.Parse(time.DateOnly, tc.date)
|
||||
if FormatGermanDayOfWeek(date) != tc.result {
|
||||
t.Error("Formatted workday did not match!")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/models"
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
@@ -17,23 +16,25 @@ import (
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
var logLevel slog.LevelVar
|
||||
logLevel.Set(slog.LevelWarn)
|
||||
|
||||
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: &logLevel}))
|
||||
slog.SetDefault(logger)
|
||||
|
||||
err = godotenv.Load(".env")
|
||||
if err != nil {
|
||||
log.Println("No .env file found in directory!")
|
||||
slog.Info("No .env file found in directory!")
|
||||
}
|
||||
if helper.GetEnv("GO_ENV", "production") == "debug" {
|
||||
log.Println("Debug mode enabled")
|
||||
log.Println("Environment Variables")
|
||||
logLevel.Set(slog.LevelDebug)
|
||||
envs := os.Environ()
|
||||
for _, e := range envs {
|
||||
fmt.Println(e)
|
||||
}
|
||||
slog.Debug("Debug mode enabled", "Environment Variables", envs)
|
||||
}
|
||||
|
||||
models.DB, err = OpenDatabase()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
slog.Error("Error while opening the database", "Error", err)
|
||||
}
|
||||
|
||||
fs := http.FileServer(http.Dir("./static"))
|
||||
@@ -50,22 +51,24 @@ func main() {
|
||||
// server.HandleFunc("/user/login", endpoints.LoginHandler)
|
||||
// server.HandleFunc("/user/settings", endpoints.UserSettingsHandler)
|
||||
server.HandleFunc("/team", endpoints.TeamHandler)
|
||||
server.HandleFunc("/team/presence", endpoints.TeamPresenceHandler)
|
||||
server.HandleFunc("/pdf", endpoints.PDFHandler)
|
||||
server.HandleFunc("/presence", endpoints.TeamPresenceHandler)
|
||||
server.Handle("/pdf", ParamsMiddleware(endpoints.PDFFormHandler))
|
||||
server.HandleFunc("/pdf/generate", endpoints.PDFCreateController)
|
||||
server.Handle("/", http.RedirectHandler("/time", http.StatusPermanentRedirect))
|
||||
server.Handle("/static/", http.StripPrefix("/static/", fs))
|
||||
|
||||
serverSessionMiddleware := endpoints.Session.LoadAndSave(server)
|
||||
|
||||
// starting the http server
|
||||
fmt.Printf("Server is running at http://localhost:%s\n", helper.GetEnv("EXPOSED_PORT", "8080"))
|
||||
log.Fatal(http.ListenAndServe(":8080", serverSessionMiddleware))
|
||||
slog.Info("Server is running at http://localhost:8080")
|
||||
slog.Error("Error starting Server", "Error", http.ListenAndServe(":8080", serverSessionMiddleware))
|
||||
}
|
||||
|
||||
func ParamsMiddleware(next http.HandlerFunc) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
queryParams := r.URL.Query()
|
||||
ctx := context.WithValue(r.Context(), "urlParams", queryParams)
|
||||
slog.Debug("ParamsMiddleware added urlParams", slog.Any("urlParams", queryParams))
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -49,6 +49,55 @@ func (a *Absence) IsMultiDay() bool {
|
||||
return !a.DateFrom.Equal(a.DateTo)
|
||||
}
|
||||
|
||||
func (a *Absence) GetWorktimeReal(u User, base WorktimeBase) time.Duration {
|
||||
if a.AbwesenheitTyp.WorkTime <= 1 {
|
||||
return 0
|
||||
}
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
return u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
return u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (a *Absence) GetPausetimeReal(u User, base WorktimeBase) time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *Absence) GetOvertimeReal(u User, base WorktimeBase) time.Duration {
|
||||
if a.AbwesenheitTyp.WorkTime > 1 {
|
||||
return 0
|
||||
}
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
return -u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
return -u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *Absence) GetWorktimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetWorktimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetPausetimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetPausetimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetOvertimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return a.GetOvertimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetTimesReal(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return a.GetWorktimeReal(u, base), a.GetPausetimeReal(u, base), a.GetOvertimeReal(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) GetTimesVirtual(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return a.GetWorktimeVirtual(u, base), a.GetPausetimeVirtual(u, base), a.GetOvertimeVirtual(u, base)
|
||||
}
|
||||
|
||||
func (a *Absence) TimeWorkVirtual(u User) time.Duration {
|
||||
return a.TimeWorkReal(u)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -87,6 +88,27 @@ func (b *Booking) Verify() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Booking) IsSubmittedAndChecked() bool {
|
||||
qStr, err := DB.Prepare(`SELECT bestaetigt from wochen_report WHERE $1 = ANY(anwesenheiten);`)
|
||||
if err != nil {
|
||||
slog.Warn("Error when preparing SQL Statement", "error", err)
|
||||
return false
|
||||
}
|
||||
defer qStr.Close()
|
||||
var isSubmittedAndChecked bool = false
|
||||
|
||||
err = qStr.QueryRow(b.CounterId).Scan(&isSubmittedAndChecked)
|
||||
if err == sql.ErrNoRows {
|
||||
// No rows found ==> not even submitted
|
||||
return false
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
slog.Warn("Unexpected error when executing SQL Statement", "error", err)
|
||||
}
|
||||
return isSubmittedAndChecked
|
||||
}
|
||||
|
||||
func (b *Booking) Insert() error {
|
||||
if !checkLastBooking(*b) {
|
||||
return SameBookingError{}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
@@ -21,6 +22,14 @@ type IWorkDay interface {
|
||||
IsKurzArbeit() bool
|
||||
GetDayProgress(User) int8
|
||||
RequiresAction() bool
|
||||
GetWorktimeReal(User, WorktimeBase) time.Duration
|
||||
GetPausetimeReal(User, WorktimeBase) time.Duration
|
||||
GetOvertimeReal(User, WorktimeBase) time.Duration
|
||||
GetWorktimeVirtual(User, WorktimeBase) time.Duration
|
||||
GetPausetimeVirtual(User, WorktimeBase) time.Duration
|
||||
GetOvertimeVirtual(User, WorktimeBase) time.Duration
|
||||
GetTimesReal(User, WorktimeBase) (work, pause, overtime time.Duration)
|
||||
GetTimesVirtual(User, WorktimeBase) (work, pause, overtime time.Duration)
|
||||
}
|
||||
|
||||
type WorkDay struct {
|
||||
@@ -36,35 +45,150 @@ type WorkDay struct {
|
||||
kurzArbeitAbsence Absence
|
||||
}
|
||||
|
||||
type WorktimeBase string
|
||||
|
||||
const (
|
||||
WorktimeBaseWeek WorktimeBase = "week"
|
||||
WorktimeBaseDay WorktimeBase = "day"
|
||||
)
|
||||
|
||||
func GetDays(user User, tsFrom, tsTo time.Time, orderedForward bool) []IWorkDay {
|
||||
var allDays map[string]IWorkDay = make(map[string]IWorkDay)
|
||||
var sortedDays []IWorkDay
|
||||
|
||||
for _, day := range GetWorkDays(user, tsFrom, tsTo) {
|
||||
allDays[day.Date().Format("2006-01-02")] = &day
|
||||
allDays[day.Date().Format(time.DateOnly)] = &day
|
||||
}
|
||||
absences, err := GetAbsencesByCardUID(user.CardUID, tsFrom, tsTo)
|
||||
if err != nil {
|
||||
log.Println("Error gettings absences for all Days!", err)
|
||||
return sortedDays
|
||||
return nil
|
||||
}
|
||||
for _, day := range absences {
|
||||
if helper.IsWeekend(day.Date()) {
|
||||
continue
|
||||
}
|
||||
if day.AbwesenheitTyp.WorkTime == 1 {
|
||||
if workDay, ok := allDays[day.Date().Format("2006-01-02")].(*WorkDay); ok {
|
||||
if workDay, ok := allDays[day.Date().Format(time.DateOnly)].(*WorkDay); ok && len(workDay.Bookings) > 0 {
|
||||
workDay.kurzArbeit = true
|
||||
workDay.kurzArbeitAbsence = day
|
||||
}
|
||||
} else {
|
||||
allDays[day.Date().Format("2006-01-02")] = &day
|
||||
allDays[day.Date().Format(time.DateOnly)] = &day
|
||||
}
|
||||
}
|
||||
|
||||
for _, day := range allDays {
|
||||
sortedDays := sortDays(allDays, orderedForward)
|
||||
return sortedDays
|
||||
}
|
||||
|
||||
// Gets the time as is in the db (with corrected pause times)
|
||||
func (d *WorkDay) GetWorktimeReal(u User, base WorktimeBase) time.Duration {
|
||||
work, pause := calcWorkPause(d.Bookings)
|
||||
work, pause = correctWorkPause(work, pause)
|
||||
return work
|
||||
}
|
||||
|
||||
// Gets the corrected pause times based on db entries
|
||||
func (d *WorkDay) GetPausetimeReal(u User, base WorktimeBase) time.Duration {
|
||||
work, pause := calcWorkPause(d.Bookings)
|
||||
work, pause = correctWorkPause(work, pause)
|
||||
return pause
|
||||
}
|
||||
|
||||
// Returns the overtime based on the db entries
|
||||
func (d *WorkDay) GetOvertimeReal(u User, base WorktimeBase) time.Duration {
|
||||
work, pause := calcWorkPause(d.Bookings)
|
||||
work, pause = correctWorkPause(work, pause)
|
||||
|
||||
var targetHours time.Duration
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
targetHours = u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
targetHours = u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return work - targetHours
|
||||
}
|
||||
|
||||
// Returns the worktime based on absence or kurzarbeit
|
||||
func (d *WorkDay) GetWorktimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
if !d.IsKurzArbeit() {
|
||||
return d.GetWorktimeReal(u, base)
|
||||
}
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
return u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
return u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (d *WorkDay) GetPausetimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
return d.GetPausetimeReal(u, base)
|
||||
}
|
||||
|
||||
func (d *WorkDay) GetOvertimeVirtual(u User, base WorktimeBase) time.Duration {
|
||||
work := d.GetWorktimeVirtual(u, base)
|
||||
|
||||
var targetHours time.Duration
|
||||
switch base {
|
||||
case WorktimeBaseDay:
|
||||
targetHours = u.ArbeitszeitProTag()
|
||||
case WorktimeBaseWeek:
|
||||
targetHours = u.ArbeitszeitProWoche() / 5
|
||||
}
|
||||
return work - targetHours
|
||||
}
|
||||
|
||||
func (d *WorkDay) GetTimesReal(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return d.GetWorktimeReal(u, base), d.GetPausetimeReal(u, base), d.GetOvertimeReal(u, base)
|
||||
}
|
||||
|
||||
func (d *WorkDay) GetTimesVirtual(u User, base WorktimeBase) (work, pause, overtime time.Duration) {
|
||||
return d.GetWorktimeVirtual(u, base), d.GetPausetimeVirtual(u, base), d.GetOvertimeVirtual(u, base)
|
||||
}
|
||||
|
||||
func calcWorkPause(bookings []Booking) (work, pause time.Duration) {
|
||||
var lastBooking Booking
|
||||
for _, b := range bookings {
|
||||
if b.CheckInOut%2 == 1 {
|
||||
if !lastBooking.Timestamp.IsZero() {
|
||||
pause += b.Timestamp.Sub(lastBooking.Timestamp)
|
||||
}
|
||||
} else {
|
||||
work += b.Timestamp.Sub(lastBooking.Timestamp)
|
||||
}
|
||||
lastBooking = b
|
||||
}
|
||||
if len(bookings)%2 == 1 {
|
||||
work += time.Since(lastBooking.Timestamp.Local())
|
||||
}
|
||||
return work, pause
|
||||
}
|
||||
|
||||
func correctWorkPause(workIn, pauseIn time.Duration) (work, pause time.Duration) {
|
||||
if workIn <= 6*time.Hour || pauseIn > 45*time.Minute {
|
||||
return workIn, pauseIn
|
||||
}
|
||||
|
||||
var diff time.Duration
|
||||
if workIn <= (9*time.Hour) && pauseIn < 30*time.Minute {
|
||||
diff = 30*time.Minute - pauseIn
|
||||
} else if pauseIn < 45*time.Minute {
|
||||
diff = 45*time.Minute - pauseIn
|
||||
}
|
||||
work = workIn - diff
|
||||
pause = pauseIn + diff
|
||||
return work, pause
|
||||
}
|
||||
|
||||
func sortDays(days map[string]IWorkDay, forward bool) []IWorkDay {
|
||||
var sortedDays []IWorkDay
|
||||
for _, day := range days {
|
||||
sortedDays = append(sortedDays, day)
|
||||
}
|
||||
if orderedForward {
|
||||
if forward {
|
||||
sort.Slice(sortedDays, func(i, j int) bool {
|
||||
return sortedDays[i].Date().After(sortedDays[j].Date())
|
||||
})
|
||||
@@ -80,6 +204,19 @@ func (d *WorkDay) Date() time.Time {
|
||||
return d.Day
|
||||
}
|
||||
|
||||
func (d *WorkDay) GenerateKurzArbeitBookings(u User) (time.Time, time.Time) {
|
||||
var timeFrom, timeTo time.Time
|
||||
if d.workTime >= u.ArbeitszeitProTag() {
|
||||
return timeFrom, timeTo
|
||||
}
|
||||
|
||||
timeFrom = d.Bookings[len(d.Bookings)-1].Timestamp.Add(time.Minute)
|
||||
timeTo = timeFrom.Add(u.ArbeitszeitProTag() - d.workTime)
|
||||
slog.Debug("Added duration as Kurzarbeit", "date", d.Date().String(), "duration", timeTo.Sub(timeFrom).String())
|
||||
|
||||
return timeFrom, timeTo
|
||||
}
|
||||
|
||||
func (d *WorkDay) TimeWorkVirtual(u User) time.Duration {
|
||||
if d.IsKurzArbeit() {
|
||||
return u.ArbeitszeitProTag()
|
||||
@@ -107,6 +244,7 @@ func (d *WorkDay) TimeWorkReal(u User) time.Duration {
|
||||
if helper.IsSameDate(d.Date(), time.Now()) && len(d.Bookings)%2 == 1 {
|
||||
d.realWorkTime += time.Since(lastBooking.Timestamp.Local())
|
||||
}
|
||||
// slog.Debug("Calculated RealWorkTime for user", "user", u, slog.String("worktime", d.realWorkTime.String()))
|
||||
return d.realWorkTime
|
||||
}
|
||||
|
||||
@@ -144,7 +282,7 @@ func (d *WorkDay) TimePauseReal(u User) (work, pause time.Duration) {
|
||||
}
|
||||
|
||||
func (d *WorkDay) ToString() string {
|
||||
return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s", d.Date().Format("2006-01-02"), len(d.Bookings), helper.FormatDuration(d.workTime))
|
||||
return fmt.Sprintf("WorkDay: %s with %d bookings and worktime: %s", d.Date().Format(time.DateOnly), len(d.Bookings), helper.FormatDuration(d.workTime))
|
||||
}
|
||||
|
||||
func (d *WorkDay) IsWorkDay() bool {
|
||||
|
||||
@@ -16,7 +16,7 @@ func CatchError[T any](val T, err error) T {
|
||||
}
|
||||
|
||||
var testWorkDay = models.WorkDay{
|
||||
Day: CatchError(time.Parse("2006-01-02", "2025-01-01")),
|
||||
Day: CatchError(time.Parse(time.DateOnly, "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")),
|
||||
|
||||
@@ -4,7 +4,10 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
// Workweeks are
|
||||
@@ -17,10 +20,9 @@ type WorkWeek struct {
|
||||
User User
|
||||
WeekStart time.Time
|
||||
Worktime time.Duration
|
||||
WorkTimeVirtual time.Duration
|
||||
Overtime time.Duration
|
||||
Status WeekStatus
|
||||
overtimeDiff time.Duration
|
||||
worktimeDiff time.Duration
|
||||
}
|
||||
|
||||
type WeekStatus int8
|
||||
@@ -45,12 +47,17 @@ func NewWorkWeek(user User, tsMonday time.Time, populate bool) WorkWeek {
|
||||
}
|
||||
|
||||
func (w *WorkWeek) PopulateWithDays(worktime time.Duration, overtime time.Duration) {
|
||||
slog.Debug("Got Days with overtime and worktime", slog.String("worktime", worktime.String()), slog.String("overtime", overtime.String()))
|
||||
w.Days = GetDays(w.User, w.WeekStart, w.WeekStart.Add(6*24*time.Hour), false)
|
||||
|
||||
for _, day := range w.Days {
|
||||
w.Worktime += day.TimeWorkVirtual(w.User)
|
||||
work, _ := day.TimePauseReal(w.User)
|
||||
w.Worktime += work
|
||||
w.WorkTimeVirtual += day.TimeWorkVirtual(w.User)
|
||||
}
|
||||
w.Overtime = w.Worktime - w.User.ArbeitszeitProWoche()
|
||||
slog.Debug("Got worktime for user", "user", w.User, "worktime", w.Worktime.String(), "virtualWorkTime", w.WorkTimeVirtual.String())
|
||||
|
||||
w.Overtime = w.WorkTimeVirtual - w.User.ArbeitszeitProWoche()
|
||||
|
||||
w.Worktime = w.Worktime.Round(time.Minute)
|
||||
w.Overtime = w.Overtime.Round(time.Minute)
|
||||
@@ -61,8 +68,6 @@ func (w *WorkWeek) PopulateWithDays(worktime time.Duration, overtime time.Durati
|
||||
|
||||
if overtime != w.Overtime || worktime != w.Worktime {
|
||||
w.Status = WeekStatusDifferences
|
||||
w.overtimeDiff = overtime
|
||||
w.worktimeDiff = worktime
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,12 +132,13 @@ func (w *WorkWeek) GetSendWeeks(user User) []WorkWeek {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var week WorkWeek = WorkWeek{User: user}
|
||||
if err := rows.Scan(&week.Id, &week.WeekStart, &week.Worktime, &week.Overtime); err != nil {
|
||||
var workTime, overTime time.Duration
|
||||
if err := rows.Scan(&week.Id, &week.WeekStart, &workTime, &overTime); err != nil {
|
||||
log.Println("Error scanning row!", err)
|
||||
return weeks
|
||||
}
|
||||
|
||||
week.PopulateWithDays(week.Worktime, week.Overtime)
|
||||
week.PopulateWithDays(workTime, overTime)
|
||||
weeks = append(weeks, week)
|
||||
}
|
||||
if err = rows.Err(); err != nil {
|
||||
@@ -144,30 +150,70 @@ func (w *WorkWeek) GetSendWeeks(user User) []WorkWeek {
|
||||
|
||||
var ErrRunningWeek = errors.New("Week is in running week")
|
||||
|
||||
func (w *WorkWeek) GetBookingIds() (anwesenheitsIds, abwesenheitsIds []int64, err error) {
|
||||
qStr, err := DB.Prepare(`
|
||||
SELECT
|
||||
(SELECT array_agg(counter_id ORDER BY counter_id)
|
||||
FROM anwesenheit
|
||||
WHERE card_uid = $1
|
||||
AND timestamp::DATE >= $2
|
||||
AND timestamp::DATE < $3) AS anwesenheit,
|
||||
|
||||
(SELECT array_agg(counter_id ORDER BY counter_id)
|
||||
FROM abwesenheit
|
||||
WHERE card_uid = $1
|
||||
AND datum_from < $3
|
||||
AND datum_to >= $2) AS abwesenheit;
|
||||
`)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer qStr.Close()
|
||||
|
||||
slog.Debug("Inserting parameters into qStr:", "user card_uid", w.User.CardUID, "week_start", w.WeekStart, "week_end", w.WeekStart.AddDate(0, 0, 5))
|
||||
|
||||
err = qStr.QueryRow(w.User.CardUID, w.WeekStart, w.WeekStart.AddDate(0, 0, 5)).Scan(pq.Array(&anwesenheitsIds), pq.Array(&abwesenheitsIds))
|
||||
if err != nil {
|
||||
return anwesenheitsIds, abwesenheitsIds, err
|
||||
}
|
||||
return anwesenheitsIds, abwesenheitsIds, nil
|
||||
}
|
||||
|
||||
// creates a new entry in the woche_report table with the given workweek
|
||||
func (w *WorkWeek) SendWeek() error {
|
||||
var qStr *sql.Stmt
|
||||
var err error
|
||||
|
||||
slog.Info("Sending workWeek to team head", "week", w.WeekStart.String())
|
||||
|
||||
anwBookings, awBookings, err := w.GetBookingIds()
|
||||
if err != nil {
|
||||
slog.Warn("Error querying bookings from work week", slog.Any("error", err))
|
||||
return err
|
||||
}
|
||||
|
||||
slog.Debug("Recieved Booking Ids", "anwesenheiten", anwBookings)
|
||||
|
||||
if time.Since(w.WeekStart) < 5*24*time.Hour {
|
||||
log.Println("Cannot send week, because it's the running week!")
|
||||
slog.Warn("Cannot send week, because it's the running week!")
|
||||
return ErrRunningWeek
|
||||
}
|
||||
|
||||
if w.CheckStatus() != WeekStatusNone {
|
||||
qStr, err = DB.Prepare(`UPDATE "wochen_report" SET bestaetigt = FALSE, arbeitszeit = make_interval(secs => $3::numeric / 1000000000), ueberstunden = make_interval(secs => $4::numeric / 1000000000) WHERE personal_nummer = $1 AND woche_start = $2;`)
|
||||
qStr, err = DB.Prepare(`UPDATE "wochen_report" SET bestaetigt = FALSE, arbeitszeit = make_interval(secs => $3::numeric / 1000000000), ueberstunden = make_interval(secs => $4::numeric / 1000000000), anwesenheiten=$5, abwesenheiten=$6 WHERE personal_nummer = $1 AND woche_start = $2;`)
|
||||
if err != nil {
|
||||
log.Println("Error preparing SQL statement", err)
|
||||
slog.Warn("Error preparing SQL statement", "error", err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
qStr, err = DB.Prepare(`INSERT INTO wochen_report (personal_nummer, woche_start, arbeitszeit, ueberstunden) VALUES ($1, $2, make_interval(secs => $3::numeric / 1000000000), make_interval(secs => $4::numeric / 1000000000));`)
|
||||
qStr, err = DB.Prepare(`INSERT INTO wochen_report (personal_nummer, woche_start, arbeitszeit, ueberstunden, anwesenheiten, abwesenheiten) VALUES ($1, $2, make_interval(secs => $3::numeric / 1000000000), make_interval(secs => $4::numeric / 1000000000), $5, $6);`)
|
||||
if err != nil {
|
||||
log.Println("Error preparing SQL statement", err)
|
||||
slog.Warn("Error preparing SQL statement", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err = qStr.Exec(w.User.PersonalNummer, w.WeekStart, int64(w.Worktime), int64(w.Overtime))
|
||||
|
||||
_, err = qStr.Exec(w.User.PersonalNummer, w.WeekStart, int64(w.Worktime), int64(w.Overtime), pq.Array(anwBookings), pq.Array(awBookings))
|
||||
if err != nil {
|
||||
log.Println("Error executing query!", err)
|
||||
return err
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func SetupWorkWeekFixture(t *testing.T) models.WorkWeek {
|
||||
t.Helper()
|
||||
monday, err := time.Parse("2006-01-02", "2025-01-10")
|
||||
monday, err := time.Parse(time.DateOnly, "2025-01-10")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -16,7 +16,7 @@ func SetupWorkWeekFixture(t *testing.T) models.WorkWeek {
|
||||
}
|
||||
|
||||
func TestNewWorkWeekNoPopulate(t *testing.T) {
|
||||
monday, err := time.Parse("2006-01-02", "2025-01-10")
|
||||
monday, err := time.Parse(time.DateOnly, "2025-01-10")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
sonar.projectKey=Arbeitszeitmessung
|
||||
sonar.projectKey=arbeitszeitmessung
|
||||
sonar.sources=.
|
||||
sonar.exclusions=**/*_test.go
|
||||
sonar.exclusions=**/*_test.go, **/*_templ.go
|
||||
|
||||
sonar.tests=.
|
||||
sonar.test.inclusions=**/*_test.go
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
--color-red-700: oklch(50.5% 0.213 27.518);
|
||||
--color-orange-500: oklch(70.5% 0.213 47.604);
|
||||
--color-purple-600: oklch(55.8% 0.288 302.321);
|
||||
--color-slate-300: oklch(86.9% 0.022 252.894);
|
||||
--color-slate-600: oklch(44.6% 0.043 257.281);
|
||||
--color-slate-700: oklch(37.2% 0.044 257.287);
|
||||
--color-slate-800: oklch(27.9% 0.041 260.031);
|
||||
--color-neutral-100: oklch(97% 0 0);
|
||||
--color-neutral-200: oklch(92.2% 0 0);
|
||||
--color-neutral-300: oklch(87% 0 0);
|
||||
@@ -197,6 +200,15 @@
|
||||
.relative {
|
||||
position: relative;
|
||||
}
|
||||
.top-1 {
|
||||
top: calc(var(--spacing) * 1);
|
||||
}
|
||||
.top-1\/2 {
|
||||
top: calc(1/2 * 100%);
|
||||
}
|
||||
.top-2 {
|
||||
top: calc(var(--spacing) * 2);
|
||||
}
|
||||
.top-2\.5 {
|
||||
top: calc(var(--spacing) * 2.5);
|
||||
}
|
||||
@@ -206,9 +218,18 @@
|
||||
.right-1 {
|
||||
right: calc(var(--spacing) * 1);
|
||||
}
|
||||
.right-2 {
|
||||
right: calc(var(--spacing) * 2);
|
||||
}
|
||||
.right-2\.5 {
|
||||
right: calc(var(--spacing) * 2.5);
|
||||
}
|
||||
.left-1 {
|
||||
left: calc(var(--spacing) * 1);
|
||||
}
|
||||
.left-1\/2 {
|
||||
left: calc(1/2 * 100%);
|
||||
}
|
||||
.col-span-2 {
|
||||
grid-column: span 2 / span 2;
|
||||
}
|
||||
@@ -236,6 +257,9 @@
|
||||
.ml-1 {
|
||||
margin-left: calc(var(--spacing) * 1);
|
||||
}
|
||||
.ml-2 {
|
||||
margin-left: calc(var(--spacing) * 2);
|
||||
}
|
||||
.icon-\[material-symbols-light--cancel-outline\] {
|
||||
display: inline-block;
|
||||
width: 1.25em;
|
||||
@@ -342,6 +366,9 @@
|
||||
.inline {
|
||||
display: inline;
|
||||
}
|
||||
.inline-flex {
|
||||
display: inline-flex;
|
||||
}
|
||||
.table {
|
||||
display: table;
|
||||
}
|
||||
@@ -360,6 +387,12 @@
|
||||
.h-2 {
|
||||
height: calc(var(--spacing) * 2);
|
||||
}
|
||||
.h-3 {
|
||||
height: calc(var(--spacing) * 3);
|
||||
}
|
||||
.h-3\.5 {
|
||||
height: calc(var(--spacing) * 3.5);
|
||||
}
|
||||
.h-4 {
|
||||
height: calc(var(--spacing) * 4);
|
||||
}
|
||||
@@ -378,12 +411,21 @@
|
||||
.w-2 {
|
||||
width: calc(var(--spacing) * 2);
|
||||
}
|
||||
.w-3 {
|
||||
width: calc(var(--spacing) * 3);
|
||||
}
|
||||
.w-3\.5 {
|
||||
width: calc(var(--spacing) * 3.5);
|
||||
}
|
||||
.w-4 {
|
||||
width: calc(var(--spacing) * 4);
|
||||
}
|
||||
.w-5 {
|
||||
width: calc(var(--spacing) * 5);
|
||||
}
|
||||
.w-9 {
|
||||
width: calc(var(--spacing) * 9);
|
||||
}
|
||||
.w-9\/10 {
|
||||
width: calc(9/10 * 100%);
|
||||
}
|
||||
@@ -396,6 +438,9 @@
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.flex-shrink {
|
||||
flex-shrink: 1;
|
||||
}
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -411,9 +456,34 @@
|
||||
.basis-\[content\] {
|
||||
flex-basis: content;
|
||||
}
|
||||
.border-collapse {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.-translate-x-1 {
|
||||
--tw-translate-x: calc(var(--spacing) * -1);
|
||||
translate: var(--tw-translate-x) var(--tw-translate-y);
|
||||
}
|
||||
.-translate-x-1\/2 {
|
||||
--tw-translate-x: calc(calc(1/2 * 100%) * -1);
|
||||
translate: var(--tw-translate-x) var(--tw-translate-y);
|
||||
}
|
||||
.-translate-y-1 {
|
||||
--tw-translate-y: calc(var(--spacing) * -1);
|
||||
translate: var(--tw-translate-x) var(--tw-translate-y);
|
||||
}
|
||||
.-translate-y-1\/2 {
|
||||
--tw-translate-y: calc(calc(1/2 * 100%) * -1);
|
||||
translate: var(--tw-translate-x) var(--tw-translate-y);
|
||||
}
|
||||
.transform {
|
||||
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
|
||||
}
|
||||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.resize {
|
||||
resize: both;
|
||||
}
|
||||
.scroll-m-2 {
|
||||
scroll-margin: calc(var(--spacing) * 2);
|
||||
}
|
||||
@@ -547,6 +617,15 @@
|
||||
.border-neutral-600 {
|
||||
border-color: var(--color-neutral-600);
|
||||
}
|
||||
.border-slate-300 {
|
||||
border-color: var(--color-slate-300);
|
||||
}
|
||||
.border-slate-700 {
|
||||
border-color: var(--color-slate-700);
|
||||
}
|
||||
.border-slate-800 {
|
||||
border-color: var(--color-slate-800);
|
||||
}
|
||||
.bg-accent {
|
||||
background-color: var(--color-accent);
|
||||
}
|
||||
@@ -568,6 +647,9 @@
|
||||
.bg-red-600 {
|
||||
background-color: var(--color-red-600);
|
||||
}
|
||||
.mask-repeat {
|
||||
mask-repeat: repeat;
|
||||
}
|
||||
.p-1 {
|
||||
padding: calc(var(--spacing) * 1);
|
||||
}
|
||||
@@ -632,12 +714,28 @@
|
||||
.text-red-600 {
|
||||
color: var(--color-red-600);
|
||||
}
|
||||
.text-slate-600 {
|
||||
color: var(--color-slate-600);
|
||||
}
|
||||
.text-slate-700 {
|
||||
color: var(--color-slate-700);
|
||||
}
|
||||
.text-white {
|
||||
color: var(--color-white);
|
||||
}
|
||||
.uppercase {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
.opacity-0 {
|
||||
opacity: 0%;
|
||||
}
|
||||
.outline {
|
||||
outline-style: var(--tw-outline-style);
|
||||
outline-width: 1px;
|
||||
}
|
||||
.filter {
|
||||
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
||||
}
|
||||
@@ -646,6 +744,11 @@
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
||||
}
|
||||
.transition-all {
|
||||
transition-property: all;
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
||||
}
|
||||
.transition-colors {
|
||||
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
@@ -655,6 +758,10 @@
|
||||
--tw-duration: 300ms;
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
.select-none {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.\*\:text-center {
|
||||
:is(& > *) {
|
||||
text-align: center;
|
||||
@@ -711,11 +818,26 @@
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.peer-checked\:opacity-100 {
|
||||
&:is(:where(.peer):checked ~ *) {
|
||||
opacity: 100%;
|
||||
}
|
||||
}
|
||||
.placeholder\:text-neutral-400 {
|
||||
&::placeholder {
|
||||
color: var(--color-neutral-400);
|
||||
}
|
||||
}
|
||||
.checked\:border-slate-800 {
|
||||
&:checked {
|
||||
border-color: var(--color-slate-800);
|
||||
}
|
||||
}
|
||||
.checked\:bg-slate-800 {
|
||||
&:checked {
|
||||
background-color: var(--color-slate-800);
|
||||
}
|
||||
}
|
||||
.hover\:border-neutral-500 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
@@ -798,12 +920,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.max-md\:border-b-1 {
|
||||
@media (width < 48rem) {
|
||||
border-bottom-style: var(--tw-border-style);
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
}
|
||||
.max-md\:bg-neutral-300 {
|
||||
@media (width < 48rem) {
|
||||
background-color: var(--color-neutral-300);
|
||||
@@ -819,11 +935,6 @@
|
||||
grid-column: span 3 / span 3;
|
||||
}
|
||||
}
|
||||
.md\:col-span-4 {
|
||||
@media (width >= 48rem) {
|
||||
grid-column: span 4 / span 4;
|
||||
}
|
||||
}
|
||||
.md\:mx-\[10\%\] {
|
||||
@media (width >= 48rem) {
|
||||
margin-inline: 10%;
|
||||
@@ -849,6 +960,11 @@
|
||||
width: calc(1/2 * 100%);
|
||||
}
|
||||
}
|
||||
.md\:flex-row {
|
||||
@media (width >= 48rem) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
.md\:px-4 {
|
||||
@media (width >= 48rem) {
|
||||
padding-inline: calc(var(--spacing) * 4);
|
||||
@@ -1011,6 +1127,41 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@property --tw-translate-x {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0;
|
||||
}
|
||||
@property --tw-translate-y {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0;
|
||||
}
|
||||
@property --tw-translate-z {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0;
|
||||
}
|
||||
@property --tw-rotate-x {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-rotate-y {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-rotate-z {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-skew-x {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-skew-y {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-divide-x-reverse {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
@@ -1030,6 +1181,11 @@
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-outline-style {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: solid;
|
||||
}
|
||||
@property --tw-blur {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
@@ -1090,10 +1246,19 @@
|
||||
@layer properties {
|
||||
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
||||
*, ::before, ::after, ::backdrop {
|
||||
--tw-translate-x: 0;
|
||||
--tw-translate-y: 0;
|
||||
--tw-translate-z: 0;
|
||||
--tw-rotate-x: initial;
|
||||
--tw-rotate-y: initial;
|
||||
--tw-rotate-z: initial;
|
||||
--tw-skew-x: initial;
|
||||
--tw-skew-y: initial;
|
||||
--tw-divide-x-reverse: 0;
|
||||
--tw-border-style: solid;
|
||||
--tw-divide-y-reverse: 0;
|
||||
--tw-font-weight: initial;
|
||||
--tw-outline-style: solid;
|
||||
--tw-blur: initial;
|
||||
--tw-brightness: initial;
|
||||
--tw-contrast: initial;
|
||||
|
||||
BIN
Backend/static/logo.png
Normal file
BIN
Backend/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -1,18 +1,21 @@
|
||||
function clearEditState() {
|
||||
for (e of document.querySelectorAll(".edit")) {
|
||||
for (let e of document.querySelectorAll(".edit")) {
|
||||
e.classList.remove("edit");
|
||||
}
|
||||
toggleAbsenceEdit(false);
|
||||
}
|
||||
|
||||
function clearButtonState() {
|
||||
for (let b of document.querySelectorAll(".change-button-component")) {
|
||||
b.type = "button";
|
||||
}
|
||||
}
|
||||
|
||||
function editWorkday(element, event, id, isWorkDay) {
|
||||
console.log("editWorkday called", isWorkDay);
|
||||
event.preventDefault();
|
||||
var form = document.getElementById(id);
|
||||
let form = document.getElementById(id);
|
||||
if (form == null) {
|
||||
form = element
|
||||
.closest(".grid-sub")
|
||||
.querySelector(".all-booking-component > form");
|
||||
form = element.closest(".grid-sub").querySelector(".all-booking-component > form");
|
||||
}
|
||||
|
||||
clearEditState();
|
||||
@@ -21,38 +24,29 @@ function editWorkday(element, event, id, isWorkDay) {
|
||||
|
||||
if (isWorkDay) {
|
||||
element.classList.add("edit");
|
||||
if (element.classList.contains("edit")) {
|
||||
form.querySelectorAll("input, select").forEach((input) => {
|
||||
if (element.type == "button") {
|
||||
for (let input of form.querySelectorAll("input, select")) {
|
||||
input.disabled = false;
|
||||
});
|
||||
}
|
||||
clearButtonState();
|
||||
element.type = "submit";
|
||||
} else {
|
||||
form.submit();
|
||||
}
|
||||
} else {
|
||||
var absenceForm = document.getElementById("absence_form");
|
||||
const absenceForm = document.getElementById("absence_form");
|
||||
|
||||
if (id != 0) {
|
||||
syncFields(form, absenceForm, [
|
||||
"date_from",
|
||||
"date_to",
|
||||
"aw_type",
|
||||
"aw_id",
|
||||
]);
|
||||
if (id == 0) {
|
||||
absenceForm.querySelector("[name=date_from]").value = form.id.replace("time-", "");
|
||||
absenceForm.querySelector("[name=date_to]").value = form.id.replace("time-", "");
|
||||
} else {
|
||||
absenceForm.querySelector("[name=date_from]").value = form.id.replace(
|
||||
"time-",
|
||||
"",
|
||||
);
|
||||
absenceForm.querySelector("[name=date_to]").value = form.id.replace(
|
||||
"time-",
|
||||
"",
|
||||
);
|
||||
syncFields(form, absenceForm, ["date_from", "date_to", "aw_type", "aw_id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleAbsenceEdit(state) {
|
||||
var form = document.getElementById("absence_form");
|
||||
const form = document.getElementById("absence_form");
|
||||
if (state) {
|
||||
form.classList.remove("hidden");
|
||||
form.scrollIntoView({
|
||||
@@ -66,22 +60,28 @@ function toggleAbsenceEdit(state) {
|
||||
}
|
||||
|
||||
function syncFields(from, to, fieldsToSync) {
|
||||
fieldsToSync.forEach((name) => {
|
||||
const src = from.querySelector(`[name=${name}]`);
|
||||
const target = to.querySelector(`[name=${name}]`);
|
||||
for (let field of fieldsToSync) {
|
||||
const src = from.querySelector(`[name=${field}]`);
|
||||
const target = to.querySelector(`[name=${field}]`);
|
||||
if (!src || !target) return;
|
||||
target.value = src.value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function navigateWeek(element, event, direction) {
|
||||
var dateInput = element.closest("form").querySelector("input[type=date]");
|
||||
var date = dateInput.valueAsDate;
|
||||
const dateInput = element.closest("form").querySelector("input[type=date]");
|
||||
const date = dateInput.valueAsDate;
|
||||
date.setDate(date.getDate() + 7 * direction);
|
||||
date.setHours(10);
|
||||
dateInput.valueAsDate = date;
|
||||
}
|
||||
|
||||
function logoutUser() {
|
||||
fetch("/user/logout", {}).then(() => window.location.reload());
|
||||
fetch("/user/logout", {}).then(() => globalThis.location.reload());
|
||||
}
|
||||
|
||||
function checkAll(pattern, state) {
|
||||
for (let input of document.querySelectorAll(`input[id^=${pattern}]`)) {
|
||||
input.checked = state;
|
||||
}
|
||||
}
|
||||
|
||||
92
Backend/template.typ
Normal file
92
Backend/template.typ
Normal file
@@ -0,0 +1,92 @@
|
||||
#let table-header(..headers) = {
|
||||
table.header(
|
||||
..headers.pos().map(h => strong(h))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#let abrechnung(meta, days) = {
|
||||
set page(paper: "a4", margin: (x:1.5cm, y:2.25cm),
|
||||
footer:[#grid(
|
||||
columns: (3fr, .65fr),
|
||||
align: left + horizon,
|
||||
inset: .5em,
|
||||
[#meta.EmployeeName -- #meta.TimeRange], grid.cell(rowspan: 2)[#image("static/logo.png")],
|
||||
[Arbeitszeitrechnung maschinell erstellt am #meta.CurrentTimestamp],
|
||||
)
|
||||
])
|
||||
set text(font: "Noto Sans", size:10pt, fill: luma(10%))
|
||||
set table(
|
||||
stroke: 0.5pt + luma(10%),
|
||||
inset: .5em,
|
||||
align: center + horizon,
|
||||
)
|
||||
show text: it => {
|
||||
if it.text == "0min"{
|
||||
text(oklch(70.8%, 0, 0deg))[#it]
|
||||
}else if it.text.starts-with("-"){
|
||||
text(red)[#it]
|
||||
}else{
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[= Abrechnung Arbeitszeit -- #meta.EmployeeName]
|
||||
|
||||
[Zeitraum: #meta.TimeRange]
|
||||
|
||||
table(
|
||||
columns: (1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1.25fr),
|
||||
fill: (x, y) =>
|
||||
if y == 0 { oklch(87%, 0, 0deg) },
|
||||
table-header(
|
||||
[Datum], [Kommen], [Gehen], [Arbeitsart], [Stunden], [Pause], [Überstunden]
|
||||
),
|
||||
.. for day in days {
|
||||
(
|
||||
[#day.Date],
|
||||
if day.DayParts.len() == 0{
|
||||
table.cell(colspan: 3)[Keine Buchungen]
|
||||
}else if not day.DayParts.first().IsWorkDay{
|
||||
table.cell(colspan: 3)[#day.DayParts.first().WorkType]
|
||||
}
|
||||
else {
|
||||
|
||||
table.cell(colspan: 3, inset: 0em)[
|
||||
|
||||
#table(
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
.. for Zeit in day.DayParts {
|
||||
(
|
||||
[#Zeit.BookingFrom],
|
||||
[#Zeit.BookingTo],
|
||||
[#Zeit.WorkType],
|
||||
)
|
||||
},
|
||||
)
|
||||
]
|
||||
},
|
||||
[#day.Worktime],
|
||||
[#day.Pausetime],
|
||||
[#day.Overtime],
|
||||
)
|
||||
if day.IsFriday {
|
||||
( table.cell(colspan: 7, fill: oklch(87%, 0, 0deg))[Wochenende], ) // note the trailing comma
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
table(
|
||||
columns: (3fr, 1fr),
|
||||
align: right,
|
||||
inset: (x: .25em, y:.75em),
|
||||
stroke: none,
|
||||
table.hline(start: 0, end: 2, stroke: stroke(dash:"dashed", thickness:.5pt)),
|
||||
[Arbeitszeit :], table.cell(align: left)[#meta.WorkTime],
|
||||
[Überstunden :], table.cell(align: left)[#meta.Overtime],
|
||||
[Überstunden :],table.cell(align: left)[#meta.OvertimeTotal],
|
||||
table.hline(start: 0, end: 2),
|
||||
|
||||
)
|
||||
}
|
||||
@@ -4,8 +4,9 @@ templ headerComponent() {
|
||||
<div class="flex flex-row justify-between md:mx-[10%] py-2 items-center">
|
||||
<a href="/time">Zeitverwaltung</a>
|
||||
<a href="/team">Abrechnung</a>
|
||||
<a href="/pdf">PDF</a>
|
||||
if true {
|
||||
<a href="/team/presence">Anwesenheit</a>
|
||||
<a href="/presence">Anwesenheit</a>
|
||||
}
|
||||
<a href="/user/settings">Einstellungen</a>
|
||||
@LogoutButton()
|
||||
|
||||
@@ -29,12 +29,12 @@ func headerComponent() templ.Component {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-row justify-between md:mx-[10%] py-2 items-center\"><a href=\"/time\">Zeitverwaltung</a> <a href=\"/team\">Abrechnung</a> ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex flex-row justify-between md:mx-[10%] py-2 items-center\"><a href=\"/time\">Zeitverwaltung</a> <a href=\"/team\">Abrechnung</a> <a href=\"/pdf\">PDF</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if true {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<a href=\"/team/presence\">Anwesenheit</a> ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<a href=\"/presence\">Anwesenheit</a> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package templates
|
||||
|
||||
import "arbeitszeitmessung/models"
|
||||
import "arbeitszeitmessung/helper"
|
||||
|
||||
templ Base() {
|
||||
<!DOCTYPE html>
|
||||
@@ -29,7 +28,7 @@ templ LoginPage(success bool, errorMsg string) {
|
||||
</div>
|
||||
}
|
||||
|
||||
templ UserPage(status int) {
|
||||
templ SettingsPage(status int) {
|
||||
{{
|
||||
user := ctx.Value("user").(models.User)
|
||||
}}
|
||||
@@ -89,68 +88,13 @@ templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
|
||||
<div class="grid-main divide-y-1">
|
||||
<div class="grid-sub lg:divide-x-1 max-md:divide-y-1 responsive @container">
|
||||
<div class="grid-cell col-span-full bg-neutral-300 lg:border-0">
|
||||
<h2 class="text-2xl uppercase font-bold">Eigene Abrechnung</h2>
|
||||
<h2 class="text-xl uppercase font-bold">Eigene Abrechnung</h2>
|
||||
</div>
|
||||
</div>
|
||||
@workWeekComponent(userWeek, false)
|
||||
// <div class="grid-sub lg:divide-x-1 max-md:divide-y-1 responsive @container">
|
||||
// <div class="grid-cell col-span-full bg-neutral-300 lg:border-0">
|
||||
// <h2 class="text-2xl uppercase font-bold">Eigene Abrechnung</h2>
|
||||
// </div>
|
||||
// <div class="grid-cell flex flex-col max-md:border-b-1 max-md:bg-neutral-300 gap-2 ">
|
||||
// <div class="lg:hidden">
|
||||
// @weekPicker(userWeek.WeekStart)
|
||||
// </div>
|
||||
// <h2 class="uppercase font-bold">{ fmt.Sprintf("%s %s", userWeek.User.Vorname, userWeek.User.Name) }</h2>
|
||||
// <div class="grid grid-cols-5 gap-2 lg:grid-cols-1">
|
||||
// <div class="col-span-2">
|
||||
// <span class="flex flex-row gap-2 items-center">
|
||||
// @statusCheckMark(userWeek.CheckStatus(), models.WeekStatusSent)
|
||||
// Gesendet
|
||||
// </span>
|
||||
// <span class="flex flex-row gap-2 items-center">
|
||||
// @statusCheckMark(userWeek.CheckStatus(), models.WeekStatusAccepted)
|
||||
// Akzeptiert
|
||||
// </span>
|
||||
// </div>
|
||||
// <div class="flex flex-row gap-2 col-span-3">
|
||||
// @timeGaugeComponent(int8(progress), false)
|
||||
// <div>
|
||||
// <p>Arbeitszeit: { fmt.Sprintf("%s", helper.FormatDuration(userWeek.Worktime)) }</p>
|
||||
// <p>Überstunden: { fmt.Sprintf("%s", helper.FormatDurationFill(userWeek.Overtime, true)) }</p>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class="grid-cell col-span-3 flex flex-col @7xl:grid @7xl:grid-cols-5 gap-2 py-4 content-baseline">
|
||||
// for _, day := range userWeek.Days {
|
||||
// @defaultWeekDayComponent(userWeek.User, day)
|
||||
// }
|
||||
// </div>
|
||||
// <div class="grid-cell flex flex-col gap-2 justify-between">
|
||||
// <div class="max-md:hidden">
|
||||
// @weekPicker(userWeek.WeekStart)
|
||||
// </div>
|
||||
// <form method="post" class="flex flex-col gap-2">
|
||||
// <input type="hidden" name="method" value="send"/>
|
||||
// <input type="hidden" name="user" value={ strconv.Itoa(userWeek.User.PersonalNummer) }/>
|
||||
// <input type="hidden" name="week" value={ userWeek.WeekStart.Format(time.DateOnly) }/>
|
||||
// switch userWeek.CheckStatus() {
|
||||
// case models.WeekStatusNone:
|
||||
// <p class="text-sm">an Vorgesetzten senden</p>
|
||||
// case models.WeekStatusSent:
|
||||
// <p class="text-sm">an Vorgesetzten gesendet</p>
|
||||
// case models.WeekStatusAccepted:
|
||||
// <p class="text-sm">vom Vorgesetzten bestätigt</p>
|
||||
// }
|
||||
// <button disabled?={ userWeek.Status < models.WeekStatusSent } type="submit" class="btn">Korrigieren</button>
|
||||
// <button disabled?={ time.Since(userWeek.WeekStart) < 24*7*time.Hour || userWeek.Status >= models.WeekStatusSent || userWeek.RequiresAction() } type="submit" class="btn">Senden</button>
|
||||
// </form>
|
||||
// </div>
|
||||
// </div>
|
||||
if len(weeks) > 0 {
|
||||
<div class="grid-cell col-span-full bg-neutral-300">
|
||||
<h2 class="text-2xl uppercase font-bold">Abrechnung Mitarbeiter</h2>
|
||||
<h2 class="text-xl uppercase font-bold">Abrechnung Mitarbeiter</h2>
|
||||
</div>
|
||||
}
|
||||
for _, week := range weeks {
|
||||
@@ -159,39 +103,6 @@ templ TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) {
|
||||
</div>
|
||||
}
|
||||
|
||||
templ TeamPresencePage(teamPresence map[models.User]bool) {
|
||||
@Base()
|
||||
@headerComponent()
|
||||
<div class="grid-main divide-y-1">
|
||||
<div class="grid-sub divide-x-1">
|
||||
<h2 class="grid-cell font-bold uppercase">Mitarbeiter</h2>
|
||||
</div>
|
||||
for user, present := range teamPresence {
|
||||
<div class="grid-sub">
|
||||
<div class="grid-cell flex flex-row gap-2 col-span-2 md:col-span-1">
|
||||
@timeGaugeComponent(helper.BoolToInt8(present)*100-1, false)
|
||||
<p>{ user.Vorname } { user.Name }</p>
|
||||
</div>
|
||||
<div class="grid-cell col-span-2">
|
||||
if present {
|
||||
<span class="text-neutral-500">Anwesend</span>
|
||||
} else {
|
||||
<span class="text-neutral-500">Abwesend</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
// <div class="grid-sub divide-x-1">
|
||||
// <h2 class="grid-cell font-bold uppercase">Nicht Anwesend</h2>
|
||||
// <div class="flex flex-col col-span-2 md:col-span-4">
|
||||
// for _, user := range teamPresence[false] {
|
||||
// @userPresenceComponent(user, false)
|
||||
// }
|
||||
// </div>
|
||||
// </div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ LogoutButton() {
|
||||
<button onclick="logoutUser()" type="button" class="cursor-pointer">Abmelden</button>
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "arbeitszeitmessung/models"
|
||||
import "arbeitszeitmessung/helper"
|
||||
|
||||
func Base() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
@@ -77,7 +76,7 @@ func LoginPage(success bool, errorMsg string) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(errorMsg)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 25, Col: 46}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 24, Col: 46}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -96,7 +95,7 @@ func LoginPage(success bool, errorMsg string) templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func UserPage(status int) templ.Component {
|
||||
func SettingsPage(status int) 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 {
|
||||
@@ -155,7 +154,7 @@ func UserPage(status int) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 60, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -168,7 +167,7 @@ func UserPage(status int) templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 78}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 60, Col: 78}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -181,7 +180,7 @@ func UserPage(status int) templ.Component {
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(user.PersonalNummer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 62, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 61, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -260,7 +259,7 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub lg:divide-x-1 max-md:divide-y-1 responsive @container\"><div class=\"grid-cell col-span-full bg-neutral-300 lg:border-0\"><h2 class=\"text-2xl uppercase font-bold\">Eigene Abrechnung</h2></div></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub lg:divide-x-1 max-md:divide-y-1 responsive @container\"><div class=\"grid-cell col-span-full bg-neutral-300 lg:border-0\"><h2 class=\"text-xl uppercase font-bold\">Eigene Abrechnung</h2></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -269,7 +268,7 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(weeks) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<div class=\"grid-cell col-span-full bg-neutral-300\"><h2 class=\"text-2xl uppercase font-bold\">Abrechnung Mitarbeiter</h2></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<div class=\"grid-cell col-span-full bg-neutral-300\"><h2 class=\"text-xl uppercase font-bold\">Abrechnung Mitarbeiter</h2></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -288,102 +287,6 @@ func TeamPage(weeks []models.WorkWeek, userWeek models.WorkWeek) templ.Component
|
||||
})
|
||||
}
|
||||
|
||||
func TeamPresencePage(teamPresence map[models.User]bool) 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_Var10 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var10 == nil {
|
||||
templ_7745c5c3_Var10 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = headerComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub divide-x-1\"><h2 class=\"grid-cell font-bold uppercase\">Mitarbeiter</h2></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for user, present := range teamPresence {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div class=\"grid-sub\"><div class=\"grid-cell flex flex-row gap-2 col-span-2 md:col-span-1\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = timeGaugeComponent(helper.BoolToInt8(present)*100-1, false).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 173, Col: 22}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages.templ`, Line: 173, Col: 36}
|
||||
}
|
||||
_, 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, 23, "</p></div><div class=\"grid-cell col-span-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if present {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "<span class=\"text-neutral-500\">Anwesend</span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<span class=\"text-neutral-500\">Abwesend</span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func LogoutButton() 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
|
||||
@@ -400,12 +303,12 @@ func LogoutButton() templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var13 == nil {
|
||||
templ_7745c5c3_Var13 = templ.NopComponent
|
||||
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var10 == nil {
|
||||
templ_7745c5c3_Var10 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<button onclick=\"logoutUser()\" type=\"button\" class=\"cursor-pointer\">Abmelden</button>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<button onclick=\"logoutUser()\" type=\"button\" class=\"cursor-pointer\">Abmelden</button>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -3,9 +3,61 @@ package templates
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/models"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
templ PDFForm(teamMembers []models.User) {
|
||||
@Base()
|
||||
@headerComponent()
|
||||
<div class="grid-main divide-y-1">
|
||||
<div class="grid-cell col-span-full bg-neutral-300">
|
||||
<h1 class="text-xl uppercase font-bold">PDF Abrechnung erstellen</h1>
|
||||
</div>
|
||||
<div class="grid-sub divide-x-1 responsive">
|
||||
<div class="grid-cell">Zeitraum wählen</div>
|
||||
<div class="grid-cell col-span-3">
|
||||
<label class="block mb-1 text-sm text-neutral-700">Abrechnungsmonat</label>
|
||||
<input name="start_date" type="date" value="" class="btn bg-neutral-100"/>
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div class="grid-sub divide-x-1 responsive">
|
||||
<div class="grid-cell">Mitarbeiter wählen</div>
|
||||
<div class="grid-cell col-span-3 flex flex-col gap-2">
|
||||
<div class="flex flex-row gap-2">
|
||||
<button class="btn" type="button" onclick={ templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("true")) }>Alle</button>
|
||||
<button class="btn" type="button" onclick={ templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("false")) }>Keine</button>
|
||||
</div>
|
||||
for _, member := range teamMembers {
|
||||
@CheckboxComponent(fmt.Sprintf("pdf-%d", member.PersonalNummer), fmt.Sprintf("%s %s", member.Vorname, member.Name))
|
||||
}
|
||||
</div>
|
||||
<div></div>
|
||||
</div>
|
||||
<div class="grid-sub divide-x-1 responsive">
|
||||
<div class="grid-cell">PDFs Bündeln</div>
|
||||
<div class="grid-cell col-span-3 flex gap-2 flex-col md:flex-row">
|
||||
<button class="btn" type="button" name="action" value="download">Einzeln</button>
|
||||
<button class="btn" type="button" name="action" value="preview" onclick="">Bündel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ CheckboxComponent(id, label string) {
|
||||
<div class="inline-flex items-center">
|
||||
<label class="flex items-center cursor-pointer relative" for={ id }>
|
||||
<input type="checkbox" class="peer h-5 w-5 cursor-pointer transition-all appearance-none rounded border border-slate-800 checked:bg-slate-800 checked:border-slate-800" id={ id }/>
|
||||
<span class="absolute text-white opacity-0 peer-checked:opacity-100 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" viewBox="0 0 20 20" fill="currentColor" stroke="currentColor" stroke-width="1">
|
||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path>
|
||||
</svg>
|
||||
</span>
|
||||
</label> <label class="cursor-pointer ml-2 text-slate-600 select-none" for={ id }>{ label }</label>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays []models.IWorkDay, tsStart time.Time, tsEnd time.Time) {
|
||||
{{
|
||||
_, kw := tsStart.ISOWeek()
|
||||
@@ -45,7 +97,12 @@ templ PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
<p>{ workDay.Bookings[bookingI].BookingType.Name } </p>
|
||||
}
|
||||
if workDay.IsKurzArbeit() {
|
||||
<p class="col-span-full">Kurzarbeit</p>
|
||||
{{
|
||||
timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e)
|
||||
}}
|
||||
<p>{ timeFrom.Format("15:04") }</p>
|
||||
<p>{ timeTo.Format("15:04") }</p>
|
||||
<p>Kurzarbeit</p>
|
||||
}
|
||||
} else {
|
||||
{{
|
||||
|
||||
@@ -11,10 +11,11 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/models"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays []models.IWorkDay, tsStart time.Time, tsEnd time.Time) templ.Component {
|
||||
func PDFForm(teamMembers []models.User) 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 {
|
||||
@@ -35,6 +36,168 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = headerComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"grid-main divide-y-1\"><div class=\"grid-cell col-span-full bg-neutral-300\"><h1 class=\"text-xl uppercase font-bold\">PDF Abrechnung erstellen</h1></div><div class=\"grid-sub divide-x-1 responsive\"><div class=\"grid-cell\">Zeitraum wählen</div><div class=\"grid-cell col-span-3\"><label class=\"block mb-1 text-sm text-neutral-700\">Abrechnungsmonat</label> <input name=\"start_date\" type=\"date\" value=\"\" class=\"btn bg-neutral-100\"></div><div></div></div><div class=\"grid-sub divide-x-1 responsive\"><div class=\"grid-cell\">Mitarbeiter wählen</div><div class=\"grid-cell col-span-3 flex flex-col gap-2\"><div class=\"flex flex-row gap-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("true")))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<button class=\"btn\" type=\"button\" onclick=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 templ.ComponentScript = templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("true"))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2.Call)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\">Alle</button> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("false")))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<button class=\"btn\" type=\"button\" onclick=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 templ.ComponentScript = templ.JSFuncCall("checkAll", "pdf-", templ.JSExpression("false"))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3.Call)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\">Keine</button></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, member := range teamMembers {
|
||||
templ_7745c5c3_Err = CheckboxComponent(fmt.Sprintf("pdf-%d", member.PersonalNummer), fmt.Sprintf("%s %s", member.Vorname, member.Name)).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</div><div></div></div><div class=\"grid-sub divide-x-1 responsive\"><div class=\"grid-cell\">PDFs Bündeln</div><div class=\"grid-cell col-span-3 flex gap-2 flex-col md:flex-row\"><button class=\"btn\" type=\"button\" name=\"action\" value=\"download\">Einzeln</button> <button class=\"btn\" type=\"button\" name=\"action\" value=\"preview\" onclick=\"\">Bündel</button></div></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func CheckboxComponent(id, label 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_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<div class=\"inline-flex items-center\"><label class=\"flex items-center cursor-pointer relative\" for=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 50, Col: 67}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\"><input type=\"checkbox\" class=\"peer h-5 w-5 cursor-pointer transition-all appearance-none rounded border border-slate-800 checked:bg-slate-800 checked:border-slate-800\" id=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 51, Col: 178}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "\"> <span class=\"absolute text-white opacity-0 peer-checked:opacity-100 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2\"><svg xmlns=\"http://www.w3.org/2000/svg\" class=\"h-3.5 w-3.5\" viewBox=\"0 0 20 20\" fill=\"currentColor\" stroke=\"currentColor\" stroke-width=\"1\"><path fill-rule=\"evenodd\" d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\" clip-rule=\"evenodd\"></path></svg></span></label> <label class=\"cursor-pointer ml-2 text-slate-600 select-none\" for=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 57, Col: 81}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 57, Col: 91}
|
||||
}
|
||||
_, 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, 11, "</label></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays []models.IWorkDay, tsStart time.Time, tsEnd time.Time) 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_Var9 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var9 == nil {
|
||||
templ_7745c5c3_Var9 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
|
||||
_, kw := tsStart.ISOWeek()
|
||||
noBorder := ""
|
||||
@@ -42,98 +205,98 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<content class=\"p-8 relative flex flex-col gap-4 break-after-page\"><div><h1 class=\"text-2xl font-bold\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<content class=\"p-8 relative flex flex-col gap-4 break-after-page\"><div><h1 class=\"text-2xl font-bold\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(e.Vorname)
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(e.Vorname)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 17, Col: 45}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 69, Col: 45}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name)
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(e.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 17, Col: 56}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 69, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</h1><p>Zeitraum: <span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</h1><p>Zeitraum: <span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006"))
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(tsStart.Format("02.01.2006"))
|
||||
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: 70, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
_, 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, 4, "</span> - <span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</span> - <span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006"))
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(tsEnd.Format("02.01.2006"))
|
||||
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: 70, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
_, 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, 5, "</span></p><p>Arbeitszeit: <span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</span></p><p>Arbeitszeit: <span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(worktime))
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(worktime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 19, Col: 58}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 71, Col: 58}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</span></p><p>Überstunden: <span>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</span></p><p>Überstunden: <span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime))
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDuration(overtime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 20, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 72, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</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\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</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\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(kw)
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(kw)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 23, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 75, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
_, 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, 8, "</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>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</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>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -142,60 +305,60 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
if index == len(workDays)-1 {
|
||||
noBorder = "border-b-0"
|
||||
}
|
||||
var templ_7745c5c3_Var9 = []any{noBorder}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var9...)
|
||||
var templ_7745c5c3_Var17 = []any{noBorder}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var17...)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<p class=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<p class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var9).String())
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var17).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_Var10))
|
||||
_, 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, 10, "\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
var templ_7745c5c3_Var19 string
|
||||
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 36, Col: 59}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 88, Col: 59}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
_, 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, 11, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 = []any{"grid grid-cols-subgrid col-span-3 " + noBorder}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var12...)
|
||||
var templ_7745c5c3_Var20 = []any{"grid grid-cols-subgrid col-span-3 " + noBorder}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var20...)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<div class=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<div class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var12).String())
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var20).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_Var13))
|
||||
_, 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, 13, "\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -203,56 +366,84 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
for bookingI := 0; bookingI < len(workDay.Bookings); bookingI += 2 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var14 string
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].Timestamp.Format("15:04"))
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].Timestamp.Format("15:04"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 43, Col: 64}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 95, Col: 64}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</p><p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</p><p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var15 string
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI+1].Timestamp.Format("15:04"))
|
||||
var templ_7745c5c3_Var23 string
|
||||
templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI+1].Timestamp.Format("15:04"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 44, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 96, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</p><p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</p><p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].BookingType.Name)
|
||||
var templ_7745c5c3_Var24 string
|
||||
templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(workDay.Bookings[bookingI].BookingType.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 45, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 97, Col: 55}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if workDay.IsKurzArbeit() {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<p class=\"col-span-full\">Kurzarbeit</p>")
|
||||
|
||||
timeFrom, timeTo := workDay.GenerateKurzArbeitBookings(e)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "<p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(timeFrom.Format("15:04"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 103, Col: 36}
|
||||
}
|
||||
_, 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, 31, "</p><p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var26 string
|
||||
templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(timeTo.Format("15:04"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 104, Col: 34}
|
||||
}
|
||||
_, 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, 32, "</p><p>Kurzarbeit</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -260,25 +451,25 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
} else {
|
||||
|
||||
absentDay, _ := day.(*models.Absence)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<p class=\"col-span-full\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<p class=\"col-span-full\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(absentDay.AbwesenheitTyp.Name)
|
||||
var templ_7745c5c3_Var27 string
|
||||
templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(absentDay.AbwesenheitTyp.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 54, Col: 62}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 111, Col: 62}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
_, 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, 21, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -287,7 +478,7 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
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, 36, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -295,7 +486,7 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -303,18 +494,18 @@ func PDFReportEmploye(e models.User, overtime, worktime time.Duration, workDays
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if day.Date().Weekday() == time.Friday {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<p class=\"col-span-full bg-neutral-300\">Wochenende</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "<p class=\"col-span-full bg-neutral-300\">Wochenende</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</div></content>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "</div></content>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -338,9 +529,9 @@ func ColorDuration(d time.Duration, classes string) templ.Component {
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var18 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var18 == nil {
|
||||
templ_7745c5c3_Var18 = templ.NopComponent
|
||||
templ_7745c5c3_Var28 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var28 == nil {
|
||||
templ_7745c5c3_Var28 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
|
||||
@@ -348,38 +539,38 @@ func ColorDuration(d time.Duration, classes string) templ.Component {
|
||||
if d.Abs() < time.Minute {
|
||||
color = "text-neutral-300"
|
||||
}
|
||||
var templ_7745c5c3_Var19 = []any{color + " " + classes}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var19...)
|
||||
var templ_7745c5c3_Var29 = []any{color + " " + classes}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var29...)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<p class=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "<p class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var20 string
|
||||
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var19).String())
|
||||
var templ_7745c5c3_Var30 string
|
||||
templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var29).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_Var20))
|
||||
_, 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, 29, "\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatDurationFill(d, true))
|
||||
var templ_7745c5c3_Var31 string
|
||||
templ_7745c5c3_Var31, 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: 76, Col: 72}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pdf.templ`, Line: 133, Col: 72}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</p>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
29
Backend/templates/presencePage.templ
Normal file
29
Backend/templates/presencePage.templ
Normal file
@@ -0,0 +1,29 @@
|
||||
package templates
|
||||
|
||||
import "arbeitszeitmessung/models"
|
||||
import "arbeitszeitmessung/helper"
|
||||
|
||||
templ TeamPresencePage(teamPresence map[models.User]bool) {
|
||||
@Base()
|
||||
@headerComponent()
|
||||
<div class="grid-main divide-y-1">
|
||||
<div class="grid-sub divide-x-1 bg-neutral-300">
|
||||
<h2 class="grid-cell font-bold uppercase text-xl">Mitarbeiter</h2>
|
||||
</div>
|
||||
for user, present := range teamPresence {
|
||||
<div class="grid-sub">
|
||||
<div class="grid-cell flex flex-row gap-2 col-span-2 md:col-span-1">
|
||||
@timeGaugeComponent(helper.BoolToInt8(present)*100-1, false)
|
||||
<p>{ user.Vorname } { user.Name }</p>
|
||||
</div>
|
||||
<div class="grid-cell col-span-2">
|
||||
if present {
|
||||
<span class="text-neutral-500">Anwesend</span>
|
||||
} else {
|
||||
<span class="text-neutral-500">Abwesend</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
110
Backend/templates/presencePage_templ.go
Normal file
110
Backend/templates/presencePage_templ.go
Normal file
@@ -0,0 +1,110 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.924
|
||||
package templates
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "arbeitszeitmessung/models"
|
||||
import "arbeitszeitmessung/helper"
|
||||
|
||||
func TeamPresencePage(teamPresence map[models.User]bool) 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_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = Base().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = headerComponent().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"grid-main divide-y-1\"><div class=\"grid-sub divide-x-1 bg-neutral-300\"><h2 class=\"grid-cell font-bold uppercase text-xl\">Mitarbeiter</h2></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for user, present := range teamPresence {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"grid-sub\"><div class=\"grid-cell flex flex-row gap-2 col-span-2 md:col-span-1\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = timeGaugeComponent(helper.BoolToInt8(present)*100-1, false).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(user.Vorname)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/presencePage.templ`, Line: 17, Col: 22}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/presencePage.templ`, Line: 17, Col: 36}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</p></div><div class=\"grid-cell col-span-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if present {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<span class=\"text-neutral-500\">Anwesend</span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<span class=\"text-neutral-500\">Abwesend</span>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
@@ -32,7 +32,7 @@ templ defaultWeekDayComponent(u models.User, day models.IWorkDay) {
|
||||
<div class="flex flex-row gap-2">
|
||||
@timeGaugeComponent(day.GetDayProgress(u), false)
|
||||
<div class="flex flex-col">
|
||||
<p class=""><span class="font-bold uppercase hidden md:inline">{ day.Date().Format("Mon") }:</span> { day.Date().Format("02.01.2006") }</p>
|
||||
<p class=""><span class="font-bold uppercase hidden md:inline">{ helper.FormatGermanDayOfWeek(day.Date()) }:</span> { day.Date().Format("02.01.2006") }</p>
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
@@ -81,7 +81,7 @@ templ weekDayComponent(user models.User, day models.WorkDay) {
|
||||
templ workWeekComponent(week models.WorkWeek, onlyAccept bool) {
|
||||
{{
|
||||
year, kw := week.WeekStart.ISOWeek()
|
||||
progress := (float32(week.Worktime.Hours()) / week.User.ArbeitszeitPerWoche) * 100
|
||||
progress := (float32(week.WorkTimeVirtual.Hours()) / week.User.ArbeitszeitPerWoche) * 100
|
||||
}}
|
||||
<div class="employeComponent grid-sub responsive lg:divide-x-1 max-md:divide-y-1 @container">
|
||||
<div class="grid-cell flex flex-col max-md:bg-neutral-300 gap-2">
|
||||
|
||||
@@ -151,9 +151,9 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("Mon"))
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 92}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 108}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -166,7 +166,7 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 136}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 152}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -346,7 +346,7 @@ func workWeekComponent(week models.WorkWeek, onlyAccept bool) templ.Component {
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
|
||||
year, kw := week.WeekStart.ISOWeek()
|
||||
progress := (float32(week.Worktime.Hours()) / week.User.ArbeitszeitPerWoche) * 100
|
||||
progress := (float32(week.WorkTimeVirtual.Hours()) / week.User.ArbeitszeitPerWoche) * 100
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<div class=\"employeComponent grid-sub responsive lg:divide-x-1 max-md:divide-y-1 @container\"><div class=\"grid-cell flex flex-col max-md:bg-neutral-300 gap-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
@@ -20,7 +20,7 @@ templ lineComponent() {
|
||||
}
|
||||
|
||||
templ changeButtonComponent(id string, workDay bool) {
|
||||
<button class="btn w-auto group/button" type="submit" onclick={ templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), id, workDay) }>
|
||||
<button class="change-button-component btn w-auto group/button" type="button" onclick={ templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), id, workDay) }>
|
||||
<p class="hidden md:block group-[.edit]/button:hidden">Ändern</p>
|
||||
<p class="hidden group-[.edit]/button:md:block">Absenden</p>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="w-4 h-4 md:hidden">
|
||||
@@ -77,8 +77,8 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) {
|
||||
}
|
||||
}}
|
||||
<div class={ "flex flex-row items-center gap-2", editBox }>
|
||||
<input type="hidden" name="date_from" value={ a.DateFrom.Format("2006-01-02") }/>
|
||||
<input type="hidden" name="date_to" value={ a.DateTo.Format("2006-01-02") }/>
|
||||
<input type="hidden" name="date_from" value={ a.DateFrom.Format(time.DateOnly) }/>
|
||||
<input type="hidden" name="date_to" value={ a.DateTo.Format(time.DateOnly) }/>
|
||||
<input type="hidden" name="aw_type" value={ a.AbwesenheitTyp.Id }/>
|
||||
<input type="hidden" name="aw_id" value={ a.CounterId }/>
|
||||
<p class="whitespace-nowrap group-[.edit]:ml-2">
|
||||
@@ -89,7 +89,7 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) {
|
||||
</p>
|
||||
<div class="w-full"></div>
|
||||
if isKurzarbeit {
|
||||
<button onclick={ templ.JSFuncCall("editAbsence", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format("2006-01-02")) } class="hidden btn border-0 rounded-none grow-0 w-auto group-[.edit]:inline">Bearbeiten</button>
|
||||
<button type="button" onclick={ templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format(time.DateOnly), false) } class="hidden btn border-0 rounded-none grow-0 w-auto group-[.edit]:inline">Bearbeiten</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -97,7 +97,7 @@ templ absenceComponent(a *models.Absence, isKurzarbeit bool) {
|
||||
templ newBookingComponent(d *models.WorkDay) {
|
||||
<div class="new-booking-component hidden group-[.edit]:flex flex-row gap-2 items-center edit-box border-dashed">
|
||||
<input name="timestamp" type="time" value={ time.Now().Format("15:04") } class="text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm px-3 py-2 cursor-pointer"/>
|
||||
<input name="date" type="hidden" value={ d.Day.Format("2006-01-02") }/>
|
||||
<input name="date" type="hidden" value={ d.Day.Format(time.DateOnly) }/>
|
||||
<div class="relative">
|
||||
<select class="cursor-pointer appearance-none" name="check_in_out">
|
||||
<option value="0" disabled>Kommen/Gehen</option>
|
||||
@@ -120,6 +120,9 @@ templ bookingComponent(booking models.Booking) {
|
||||
<input disabled name={ "booking_" + strconv.Itoa(booking.CounterId) } type="time" value={ booking.Timestamp.Format("15:04") } class="text-neutral-700 group-[.edit]:inline hidden bg-neutral-100 text-sm px-3 py-2 cursor-pointer"/>
|
||||
{ booking.GetBookingType() }
|
||||
</p>
|
||||
if booking.IsSubmittedAndChecked() {
|
||||
<p>submitted</p>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func changeButtonComponent(id string, workDay bool) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<button class=\"btn w-auto group/button\" type=\"submit\" onclick=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<button class=\"change-button-component btn w-auto group/button\" type=\"button\" onclick=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -306,9 +306,9 @@ func absenceComponent(a *models.Absence, isKurzarbeit bool) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var16 string
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format("2006-01-02"))
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format(time.DateOnly))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 80, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 80, Col: 80}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -319,9 +319,9 @@ func absenceComponent(a *models.Absence, isKurzarbeit bool) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var17 string
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("2006-01-02"))
|
||||
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format(time.DateOnly))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 81, Col: 75}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 81, Col: 76}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -394,15 +394,15 @@ func absenceComponent(a *models.Absence, isKurzarbeit bool) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if isKurzarbeit {
|
||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editAbsence", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format("2006-01-02")))
|
||||
templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format(time.DateOnly), false))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<button onclick=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "<button type=\"button\" onclick=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var22 templ.ComponentScript = templ.JSFuncCall("editAbsence", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format("2006-01-02"))
|
||||
var templ_7745c5c3_Var22 templ.ComponentScript = templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), "time-"+a.Date().Format(time.DateOnly), false)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var22.Call)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@@ -459,9 +459,9 @@ func newBookingComponent(d *models.WorkDay) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var25 string
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(d.Day.Format("2006-01-02"))
|
||||
templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(d.Day.Format(time.DateOnly))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 100, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 100, Col: 70}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -568,7 +568,17 @@ func bookingComponent(booking models.Booking) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "</p></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if booking.IsSubmittedAndChecked() {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "<p>submitted</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -597,7 +607,7 @@ func LegendComponent() templ.Component {
|
||||
templ_7745c5c3_Var31 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "<div class=\"flex flex-row gap-4 md:mx-[10%] print:hidden\"><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-red-600\"></div><span>Fehler</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-orange-500\"></div><span>Arbeitszeit unter regulär</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-accent\"></div><span>Arbeitszeit vollständig</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-purple-600\"></div><span>Überstunden</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-neutral-400\"></div><span>Keine Buchungen</span></div></div>")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "<div class=\"flex flex-row gap-4 md:mx-[10%] print:hidden\"><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-red-600\"></div><span>Fehler</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-orange-500\"></div><span>Arbeitszeit unter regulär</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-accent\"></div><span>Arbeitszeit vollständig</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-purple-600\"></div><span>Überstunden</span></div><div class=\"flex flex-row items-center gap-2\"><div class=\"rounded-full size-4 bg-neutral-400\"></div><span>Keine Buchungen</span></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
@@ -98,12 +98,12 @@ templ defaultDayComponent(day models.IWorkDay) {
|
||||
@timeGaugeComponent(day.GetDayProgress(user), day.Date().Equal(time.Now().Truncate(24*time.Hour)))
|
||||
<div>
|
||||
<p>
|
||||
<span class="font-bold uppercase hidden md:inline">{ day.Date().Format("Mon") }:</span> { day.Date().Format("02.01.2006") }
|
||||
<span class="font-bold uppercase hidden md:inline">{ helper.FormatGermanDayOfWeek(day.Date()) }:</span> { day.Date().Format("02.01.2006") }
|
||||
</p>
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
work, pause, overtime := workDay.GetAllWorkTimesVirtual(user)
|
||||
work, pause, overtime := workDay.GetAllWorkTimesReal(user)
|
||||
}}
|
||||
if day.RequiresAction() {
|
||||
<p class="text-red-600">Bitte anpassen</p>
|
||||
@@ -127,7 +127,7 @@ templ defaultDayComponent(day models.IWorkDay) {
|
||||
</div>
|
||||
<div class="all-booking-component grid-cell flex flex-row md:col-span-3 col-span-2 gap-2 w-full">
|
||||
@lineComponent()
|
||||
<form id={ "time-" + day.Date().Format("2006-01-02") } class={ "flex flex-col gap-2 w-full", justify } method="post">
|
||||
<form id={ "time-" + day.Date().Format(time.DateOnly) } class={ "flex flex-col gap-2 w-full", justify } method="post">
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
@@ -153,14 +153,14 @@ templ defaultDayComponent(day models.IWorkDay) {
|
||||
</form>
|
||||
</div>
|
||||
<div class="grid-cell flex flex-row gap-2 items-end">
|
||||
@changeButtonComponent("time-"+day.Date().Format("2006-01-02"), day.IsWorkDay())
|
||||
@changeButtonComponent("time-"+day.Date().Format(time.DateOnly), day.IsWorkDay())
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ absentInput(a models.Absence) {
|
||||
<input type="hidden" name="date_from" value={ a.DateFrom.Format("2006-01-02") }/>
|
||||
<input type="hidden" name="date_to" value={ a.DateTo.Format("2006-01-02") }/>
|
||||
<input type="hidden" name="date_from" value={ a.DateFrom.Format(time.DateOnly) }/>
|
||||
<input type="hidden" name="date_to" value={ a.DateTo.Format(time.DateOnly) }/>
|
||||
<input type="hidden" name="aw_type" value={ a.AbwesenheitTyp.Id }/>
|
||||
<input type="hidden" name="aw_id" value={ a.CounterId }/>
|
||||
}
|
||||
|
||||
@@ -269,9 +269,9 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("Mon"))
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 82}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -284,7 +284,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 126}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 142}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -297,7 +297,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
if day.IsWorkDay() {
|
||||
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
work, pause, overtime := workDay.GetAllWorkTimesVirtual(user)
|
||||
work, pause, overtime := workDay.GetAllWorkTimesReal(user)
|
||||
if day.RequiresAction() {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<p class=\"text-red-600\">Bitte anpassen</p>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -389,9 +389,9 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var18 string
|
||||
templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs("time-" + day.Date().Format("2006-01-02"))
|
||||
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: 130, Col: 55}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 130, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -467,7 +467,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = changeButtonComponent("time-"+day.Date().Format("2006-01-02"), day.IsWorkDay()).Render(ctx, templ_7745c5c3_Buffer)
|
||||
templ_7745c5c3_Err = changeButtonComponent("time-"+day.Date().Format(time.DateOnly), day.IsWorkDay()).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -505,9 +505,9 @@ func absentInput(a models.Absence) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var21 string
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format("2006-01-02"))
|
||||
templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateFrom.Format(time.DateOnly))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 162, Col: 78}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 162, Col: 79}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -518,9 +518,9 @@ func absentInput(a models.Absence) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var22 string
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format("2006-01-02"))
|
||||
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(a.DateTo.Format(time.DateOnly))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 163, Col: 74}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 163, Col: 75}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
28
DB/initdb/01_schema.sql
Normal file → Executable file
28
DB/initdb/01_schema.sql
Normal file → Executable file
@@ -22,7 +22,7 @@ COMMENT ON COLUMN "anwesenheit"."geraet_id" IS 'ID des Lesegerätes';
|
||||
DROP TABLE IF EXISTS "s_anwesenheit_typen";
|
||||
CREATE TABLE "s_anwesenheit_typen" (
|
||||
"anwesenheit_id" int2 PRIMARY KEY,
|
||||
"anwesenheit_name" varchar(255)
|
||||
"anwesenheit_name" varchar(255) NOT NULL
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
@@ -78,30 +78,34 @@ EXECUTE FUNCTION update_zuletzt_geandert();
|
||||
DROP TABLE IF EXISTS "wochen_report";
|
||||
CREATE TABLE "wochen_report" (
|
||||
"id" serial PRIMARY KEY,
|
||||
"personal_nummer" int4,
|
||||
"woche_start" date,
|
||||
"personal_nummer" int4 NOT NULL,
|
||||
"woche_start" date NOT NULL,
|
||||
"bestaetigt" bool DEFAULT FALSE,
|
||||
"arbeitszeit" interval,
|
||||
"ueberstunden" interval,
|
||||
"arbeitszeit" interval NOT NULL,
|
||||
"ueberstunden" interval NOT NULL,
|
||||
"anwesenheiten" int ARRAY,
|
||||
"abwesenheiten" int ARRAY,
|
||||
UNIQUE ("personal_nummer", "woche_start")
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS "abwesenheit";
|
||||
CREATE TABLE "abwesenheit" (
|
||||
"counter_id" bigserial PRIMARY KEY,
|
||||
"card_uid" varchar(255),
|
||||
"abwesenheit_typ" int2,
|
||||
"datum_from" timestamptz DEFAULT NOW()::DATE,
|
||||
"datum_to" timestamptz
|
||||
"card_uid" varchar(255) NOT NULL,
|
||||
"abwesenheit_typ" int2 NOT NULL,
|
||||
"datum_from" timestamptz DEFAULT NOW()::DATE NOT NULL,
|
||||
"datum_to" timestamptz NOT NULL
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS "s_abwesenheit_typen";
|
||||
CREATE TABLE "s_abwesenheit_typen" (
|
||||
"abwesenheit_id" int2 PRIMARY KEY,
|
||||
"abwesenheit_name" varchar(255),
|
||||
"arbeitszeit_equivalent" float4
|
||||
"abwesenheit_id" int2 PRIMARY KEY NOT NULL,
|
||||
"abwesenheit_name" varchar(255) NOT NULL,
|
||||
"arbeitszeit_equivalent" float4 NOT NULL
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN "s_abwesenheit_typen"."arbeitszeit_equivalent" IS '0=keine Arbeitszeit; 1=Arbeitszeit auffüllen; 2=Arbeitszeit austauschen';
|
||||
|
||||
-- Adds crypto extension
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||
|
||||
0
DB/initdb/02_sample_data.sql
Normal file → Executable file
0
DB/initdb/02_sample_data.sql
Normal file → Executable file
0
DB/initdb/03_create_user.sh
Normal file → Executable file
0
DB/initdb/03_create_user.sh
Normal file → Executable file
@@ -1,11 +0,0 @@
|
||||
POSTGRES_USER=root
|
||||
POSTGRES_PASSWORD=very_secure
|
||||
POSTGRES_API_USER=api_nutzer
|
||||
POSTGRES_API_PASS=password
|
||||
POSTGRES_PATH=../DB
|
||||
POSTGRES_DB=arbeitszeitmessung
|
||||
EXPOSED_PORT=8000
|
||||
TZ=Europe/Berlin
|
||||
PGTZ=Europe/Berlin
|
||||
API_TOKEN=dont_access
|
||||
EMPTY_DAYS=false
|
||||
@@ -1,12 +1,6 @@
|
||||
name: arbeitszeitmessung-dev
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
PGDATA: /var/lib/postgresql/data/pg_data
|
||||
volumes:
|
||||
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
||||
# - ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
||||
@@ -19,21 +13,8 @@ services:
|
||||
ports:
|
||||
- 8001:8080
|
||||
backend:
|
||||
image: git.letsstein.de/tom/arbeitszeitmessung
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
EXPOSED_PORT: ${EXPOSED_PORT}
|
||||
NO_CORS: true
|
||||
ports:
|
||||
- ${EXPOSED_PORT}:8080
|
||||
volumes:
|
||||
- ../logs:/app/Backend/logs
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
swagger:
|
||||
image: swaggerapi/swagger-ui
|
||||
|
||||
@@ -6,28 +6,31 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
PGTZ: ${TZ}
|
||||
PGDATA: /var/lib/postgresql/data/pg_data
|
||||
volumes:
|
||||
- ${POSTGRES_PATH}:/var/lib/postgresql/data
|
||||
- ${POSTGRES_PATH}/initdb:/docker-entrypoint-initdb.d
|
||||
ports:
|
||||
- 5432:5432
|
||||
- ${POSTGRES_PORT}:5432
|
||||
|
||||
backend:
|
||||
image: git.letsstein.de/tom/arbeitszeitmessung
|
||||
image: git.letsstein.de/tom/arbeitszeitmessung-webserver
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
EXPOSED_PORT: ${EXPOSED_PORT}
|
||||
ports:
|
||||
- ${EXPOSED_PORT}:8080
|
||||
- ${WEB_PORT}:8080
|
||||
depends_on:
|
||||
- db
|
||||
- document-creator
|
||||
volumes:
|
||||
- ../logs:/app/Backend/logs
|
||||
restart: unless-stopped
|
||||
|
||||
document-creator:
|
||||
image: git.letsstein.de/tom/arbeitszeitmessung-doc-creator
|
||||
container_name: ${TYPST_CONTAINER}
|
||||
restart: unless-stopped
|
||||
|
||||
12
Docker/env.example
Normal file
12
Docker/env.example
Normal file
@@ -0,0 +1,12 @@
|
||||
POSTGRES_USER=root # Postgres ADMIN Nutzername
|
||||
POSTGRES_PASSWORD=very_secure # Postgres ADMIN Passwort
|
||||
POSTGRES_API_USER=api_nutzer # Postgres API Nutzername (für Arbeitszeitmessung)
|
||||
POSTGRES_API_PASS=password # Postgres API Passwort (für Arbeitszeitmessung)
|
||||
POSTGRES_PATH=../DB # Datebank Pfad (relativ zu Docker Ordner oder absoluter pfad mit /...)
|
||||
POSTGRES_DB=arbeitszeitmessung # Postgres Datenbank Name
|
||||
POSTGRES_PORT=127.0.0.1:5432 # Postgres Port will not be exposed by default.
|
||||
TZ=Europe/Berlin # Zeitzone
|
||||
PGTZ=Europe/Berlin # Zeitzone
|
||||
API_TOKEN=dont_access # API Token für ESP Endpoints
|
||||
WEB_PORT=8000 # Port from which Arbeitszeitmessung should be accessable regex:^[0-9]{1,5}$
|
||||
TYPST_CONTAINER=arbeitszeitmessung-doc-creator # Name of the pdf compiler container
|
||||
6
DocumentCreator/Dockerfile
Normal file
6
DocumentCreator/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM ghcr.io/typst/typst:0.14.0
|
||||
|
||||
COPY ./templates ./templates
|
||||
COPY ./static ./static
|
||||
|
||||
ENTRYPOINT ["sh", "-c", "while true; do sleep 3600; done"]
|
||||
BIN
DocumentCreator/static/logo.png
Normal file
BIN
DocumentCreator/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
92
DocumentCreator/templates/abrechnung.typ
Normal file
92
DocumentCreator/templates/abrechnung.typ
Normal file
@@ -0,0 +1,92 @@
|
||||
#let table-header(..headers) = {
|
||||
table.header(
|
||||
..headers.pos().map(h => strong(h))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#let abrechnung(meta, days) = {
|
||||
set page(paper: "a4", margin: (x:1.5cm, y:2.25cm),
|
||||
footer:[#grid(
|
||||
columns: (3fr, .65fr),
|
||||
align: left + horizon,
|
||||
inset: .5em,
|
||||
[#meta.EmployeeName -- #meta.TimeRange], grid.cell(rowspan: 2)[#image("static/logo.png")],
|
||||
[Arbeitszeitrechnung maschinell erstellt am #meta.CurrentTimestamp],
|
||||
)
|
||||
])
|
||||
set text(font: "Noto Sans", size:10pt, fill: luma(10%))
|
||||
set table(
|
||||
stroke: 0.5pt + luma(10%),
|
||||
inset: .5em,
|
||||
align: center + horizon,
|
||||
)
|
||||
show text: it => {
|
||||
if it.text == "0min"{
|
||||
text(oklch(70.8%, 0, 0deg))[#it]
|
||||
}else if it.text.starts-with("-"){
|
||||
text(red)[#it]
|
||||
}else{
|
||||
it
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[= Abrechnung Arbeitszeit -- #meta.EmployeeName]
|
||||
|
||||
[Zeitraum: #meta.TimeRange]
|
||||
|
||||
table(
|
||||
columns: (1fr, 1fr, 1fr, 1fr, 1fr, 1fr, 1.25fr),
|
||||
fill: (x, y) =>
|
||||
if y == 0 { oklch(87%, 0, 0deg) },
|
||||
table-header(
|
||||
[Datum], [Kommen], [Gehen], [Arbeitsart], [Stunden], [Pause], [Überstunden]
|
||||
),
|
||||
.. for day in days {
|
||||
(
|
||||
[#day.Date],
|
||||
if day.DayParts.len() == 0{
|
||||
table.cell(colspan: 3)[Keine Buchungen]
|
||||
}else if not day.DayParts.first().IsWorkDay{
|
||||
table.cell(colspan: 3)[#day.DayParts.first().WorkType]
|
||||
}
|
||||
else {
|
||||
|
||||
table.cell(colspan: 3, inset: 0em)[
|
||||
|
||||
#table(
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
.. for Zeit in day.DayParts {
|
||||
(
|
||||
[#Zeit.BookingFrom],
|
||||
[#Zeit.BookingTo],
|
||||
[#Zeit.WorkType],
|
||||
)
|
||||
},
|
||||
)
|
||||
]
|
||||
},
|
||||
[#day.Worktime],
|
||||
[#day.Pausetime],
|
||||
[#day.Overtime],
|
||||
)
|
||||
if day.IsFriday {
|
||||
( table.cell(colspan: 7, fill: oklch(87%, 0, 0deg))[Wochenende], ) // note the trailing comma
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
table(
|
||||
columns: (3fr, 1fr),
|
||||
align: right,
|
||||
inset: (x: .25em, y:.75em),
|
||||
stroke: none,
|
||||
table.hline(start: 0, end: 2, stroke: stroke(dash:"dashed", thickness:.5pt)),
|
||||
[Arbeitszeit :], table.cell(align: left)[#meta.WorkTime],
|
||||
[Überstunden :], table.cell(align: left)[#meta.Overtime],
|
||||
[Überstunden :],table.cell(align: left)[#meta.OvertimeTotal],
|
||||
table.hline(start: 0, end: 2),
|
||||
|
||||
)
|
||||
}
|
||||
10
Makefile
10
Makefile
@@ -44,7 +44,7 @@ generateFrontend:
|
||||
|
||||
|
||||
backend: generateFrontend login_registry
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t ${IMAGE_REGISTRY}/${PACKAGE_OWNER}/arbeitszeitmessung:latest Backend --load #--push
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t ${IMAGE_REGISTRY}/${PACKAGE_OWNER}/arbeitszeitmessung:latest Backend --push
|
||||
# docker buildx build --platform linux/amd64,linux/arm64 -t ${IMAGE_REGISTRY}/${PACKAGE_OWNER}/arbeitszeitmessung:${GIT_COMMIT} Backend //--push
|
||||
|
||||
test:
|
||||
@@ -52,3 +52,11 @@ test:
|
||||
|
||||
scan: test
|
||||
$(MAKE) -C Backend scan
|
||||
|
||||
Docker/.env:
|
||||
cp Docker/env.example Docker/.env
|
||||
echo "Konfigurations Datei erstellt (./Docker/.env), bitte zuerst ausfüllen und danach erneut 'make install' ausführen"
|
||||
exit 0
|
||||
|
||||
install: Docker/.env
|
||||
echo "Install"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Arbeitszeitmessung
|
||||
|
||||
[](https://sonar.letsstein.de/dashboard?id=arbeitszeitmessung)
|
||||
|
||||
bis jetzt ein einfaches Backend mit PostgreSQL Datenbank und GO Webserver um Arbeitszeitbuchungen per HTTP PUT einzufügen
|
||||
|
||||
## Installation
|
||||
|
||||
63
WIR-typst/main.typ
Normal file
63
WIR-typst/main.typ
Normal file
@@ -0,0 +1,63 @@
|
||||
#set page("a4")
|
||||
#set text(font: "Lato")
|
||||
|
||||
= Stunden
|
||||
|
||||
== Kim Mustermensch
|
||||
|
||||
Zeitraum: 01.10.2025 - 31.10.2025
|
||||
|
||||
Arbeitszeit: 136h 19min
|
||||
|
||||
Überstunden: -39h 41min
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// #show table.cell: it => {
|
||||
// if it.y == 0 {
|
||||
// set text(white)
|
||||
// strong(it)
|
||||
// } else if it.body == [] {
|
||||
// // Replace empty cells with 'N/A'
|
||||
// pad(..it.inset)[0min]
|
||||
|
||||
// } else {
|
||||
// it
|
||||
// }
|
||||
// }
|
||||
|
||||
#let subgrid(body) = {
|
||||
table.cell(colspan: 3, inset: 0em)[
|
||||
#table(
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
gutter: 0em,
|
||||
stroke: black,
|
||||
[..#body]
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
"01.09.2025",
|
||||
"08:07",
|
||||
"16:28",
|
||||
"Büro",
|
||||
"7h 51min",
|
||||
"30min",
|
||||
"-9min",
|
||||
"02.09.2025",
|
||||
// return work, pause, overtime
|
||||
table.cell(colspan: 3, inset: 0em)[#table(
|
||||
columns: (1fr, 1fr, 1fr),
|
||||
gutter: 0em,
|
||||
stroke: black,
|
||||
[08:12], [16:24], [Büro],
|
||||
[16:30], [17:24], [Homeoffice]
|
||||
)],
|
||||
"6h",
|
||||
"0min",
|
||||
"-1h 15min"
|
||||
|
||||
)
|
||||
BIN
WIR-typst/template.pdf
Normal file
BIN
WIR-typst/template.pdf
Normal file
Binary file not shown.
30
db.sql
30
db.sql
@@ -176,15 +176,15 @@ sample_bookings AS (
|
||||
(d.work_date + make_time(16, floor(random()*50)::int, 0))::timestamptz AS ts,
|
||||
1 AS anwesenheit_typ
|
||||
FROM days d
|
||||
),
|
||||
ins_anw AS (
|
||||
-- insert only bookings up to now (prevents future times on today)
|
||||
INSERT INTO anwesenheit ("timestamp", card_uid, check_in_out, geraet_id)
|
||||
SELECT ts, card_uid, check_in_out, geraet_id
|
||||
FROM sample_bookings
|
||||
WHERE ts <= NOW()
|
||||
RETURNING 1
|
||||
)
|
||||
|
||||
-- insert only bookings up to now (prevents future times on today)
|
||||
INSERT INTO anwesenheit ("timestamp", card_uid, check_in_out, geraet_id)
|
||||
SELECT ts, card_uid, check_in_out, geraet_id
|
||||
FROM sample_bookings
|
||||
WHERE ts <= NOW()
|
||||
RETURNING 1;
|
||||
|
||||
-- now insert absences (uses the same days CTE)
|
||||
INSERT INTO abwesenheit (card_uid, abwesenheit_typ, datum)
|
||||
SELECT
|
||||
@@ -247,15 +247,13 @@ all_bookings AS (
|
||||
SELECT * FROM base_bookings
|
||||
UNION ALL
|
||||
SELECT * FROM pause_bookings
|
||||
),
|
||||
ins_anw AS (
|
||||
INSERT INTO anwesenheit ("timestamp", "card_uid", "check_in_out", "geraet_id", "anwesenheit_typ")
|
||||
SELECT ts, card_uid, check_in_out, geraet_id, 1 as anwesenheit_typ
|
||||
FROM all_bookings
|
||||
WHERE ts <= NOW()
|
||||
ORDER BY work_date, ts
|
||||
RETURNING 1
|
||||
)
|
||||
INSERT INTO anwesenheit ("timestamp", "card_uid", "check_in_out", "geraet_id", "anwesenheit_typ")
|
||||
SELECT ts, card_uid, check_in_out, geraet_id, 1 as anwesenheit_typ
|
||||
FROM all_bookings
|
||||
WHERE ts <= NOW()
|
||||
ORDER BY work_date, ts;
|
||||
|
||||
INSERT INTO abwesenheit (card_uid, abwesenheit_typ, datum)
|
||||
SELECT
|
||||
d.card_uid,
|
||||
|
||||
108
install.sh
Executable file
108
install.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
envFile=Docker/.env
|
||||
envExample=Docker/env.example
|
||||
|
||||
echo "Checking Docker installation..."
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "Docker not found. Install Docker? [y/N]"
|
||||
read -r install_docker
|
||||
if [[ "$install_docker" =~ ^[Yy]$ ]]; then
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
else
|
||||
echo "Docker is required. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Docker is already installed."
|
||||
fi
|
||||
|
||||
echo "Checking Docker Compose..."
|
||||
if ! docker compose version >/dev/null 2>&1; then
|
||||
echo "Docker Compose plugin missing. You may need to update Docker."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Preparing .env file..."
|
||||
if [ ! -f $envFile ]; then
|
||||
if [ -f $envExample ]; then
|
||||
echo ".env not found. Creating interactively from .env.example."
|
||||
> $envFile
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
||||
#ignore empty lines and comments
|
||||
[[ "$line" =~ ^#.*$ || -z "$line" ]] && continue
|
||||
|
||||
|
||||
key=$(printf "%s" "$line" | cut -d '=' -f 1)
|
||||
rest=$(printf "%s" "$line" | cut -d '=' -f 2-)
|
||||
|
||||
# extract inline comment portion
|
||||
comment=$(printf "%s" "$rest" | sed -n 's/.*# \(.*\)$/\1/p')
|
||||
raw_val=$(printf "%s" "$rest" | sed 's/ *#.*//')
|
||||
default_value=$(printf "%s" "$raw_val" | sed 's/"//g')
|
||||
|
||||
regex=""
|
||||
if [[ "$comment" =~ regex:(.*)$ ]]; then
|
||||
regex="${BASH_REMATCH[1]}"
|
||||
fi
|
||||
|
||||
comment=$(printf "%s" "$comment" | sed 's/ regex:.*//')
|
||||
|
||||
while true; do
|
||||
if [ -z "$comment" ]; then
|
||||
printf "Value for $key - $comment (default: $default_value"
|
||||
else
|
||||
printf "Value for $key (default: $default_value"
|
||||
fi
|
||||
if [ -n "$regex" ]; then
|
||||
printf ", must match: %s" "$regex"
|
||||
fi
|
||||
printf "):\n"
|
||||
|
||||
read user_input < /dev/tty
|
||||
|
||||
# empty input -> take default
|
||||
[ -z "$user_input" ] && user_input="$default_value"
|
||||
|
||||
printf "\e[A$user_input\n"
|
||||
|
||||
# validate
|
||||
if [ -n "$regex" ]; then
|
||||
if [[ "$user_input" =~ $regex ]]; then
|
||||
echo "$key=$user_input" >> $envFile
|
||||
break
|
||||
else
|
||||
printf "Invalid value. Does not match regex: %s\n" "$regex"
|
||||
continue
|
||||
fi
|
||||
else
|
||||
echo "$key=$user_input" >> $envFile
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
done < $envExample
|
||||
|
||||
echo ".env created."
|
||||
else
|
||||
echo "No .env or .env.example found."
|
||||
echo "Creating an empty .env file for manual editing."
|
||||
touch $envFile
|
||||
fi
|
||||
else
|
||||
echo "Using existing .env. (found at $envFile)"
|
||||
fi
|
||||
|
||||
echo "Start containers with docker compose up -d? [y/N]"
|
||||
read -r start_containers
|
||||
if [[ "$start_containers" =~ ^[Yy]$ ]]; then
|
||||
cd Docker
|
||||
mkdir ../logs
|
||||
docker compose up -d
|
||||
echo "Containers started."
|
||||
else
|
||||
echo "You can start them manually with: docker compose up -d"
|
||||
fi
|
||||
4
migrations/20251013212224_buchungs_array.down.sql
Normal file
4
migrations/20251013212224_buchungs_array.down.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- reverse: modify "wochen_report" table
|
||||
ALTER TABLE "wochen_report" DROP COLUMN "abwesenheiten", DROP COLUMN "anwesenheiten", ALTER COLUMN "arbeitszeit" DROP NOT NULL, ALTER COLUMN "ueberstunden" DROP NOT NULL, ALTER COLUMN "woche_start" DROP NOT NULL;
|
||||
-- reverse: modify "abwesenheit" table
|
||||
ALTER TABLE "abwesenheit" ALTER COLUMN "datum_to" DROP NOT NULL;
|
||||
4
migrations/20251013212224_buchungs_array.up.sql
Normal file
4
migrations/20251013212224_buchungs_array.up.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- modify "abwesenheit" table
|
||||
ALTER TABLE "abwesenheit" ALTER COLUMN "datum_to" SET NOT NULL;
|
||||
-- modify "wochen_report" table
|
||||
ALTER TABLE "wochen_report" ALTER COLUMN "woche_start" SET NOT NULL, ALTER COLUMN "ueberstunden" SET NOT NULL, ALTER COLUMN "arbeitszeit" SET NOT NULL, ADD COLUMN "anwesenheiten" integer[] NULL, ADD COLUMN "abwesenheiten" integer[] NULL;
|
||||
@@ -1,15 +1,9 @@
|
||||
h1:3AxgD8mnu/F+JGtJu9FZvA9Ro0UUtGPgyjskKtfTYUQ=
|
||||
20250901201159_initial.down.sql h1:cmF5CvNGqEfcmbRgiqaqDWERdNNRaMzarbNLJ/Y35o4=
|
||||
20250901201159_initial.up.sql h1:Yrak/+wfQ4Tu/dVR/cUZ/75DlAcv4G/OJXDqpgSw47U=
|
||||
20250901201250_control_tables.down.sql h1:f/KmhO9pOI45J8ZRjFonvD3CypB+rOoGOPN2WMFHvOw=
|
||||
20250901201250_control_tables.up.sql h1:of5E07p0N1aen9CdQNEOrO7ffbKZC6kp4oK5KPzU9+g=
|
||||
20250901201710_triggers_extension.down.sql h1:a9va3FSfHBWzODJSJO+ywNa2hiZwjG/vmvYGb3L1lnM=
|
||||
20250901201710_triggers_extension.up.sql h1:nUBPd2eDssi/TwMVF/nOJkIM5rUM0iINdg1K9pZRZN0=
|
||||
20250903221313_overtime.down.sql h1:X+jJESqcZ6ZTd2H563z6kRaXb4dn4sA02D3ck2795v8=
|
||||
20250903221313_overtime.up.sql h1:C3DSiNVpe9v0Un1DEQ0lsy5yToR8iqcggv91GSr6tRE=
|
||||
20250903233030_non_null_contraints.down.sql h1:42TZzPsji2Ze50k6sLwgIuNo4Trk3m3ni/aIfQJ97dE=
|
||||
20250903233030_non_null_contraints.up.sql h1:k6zR5YNSAP4fo5QEc58KZ0LxvEz1nl0X/AAcZ+TG3I4=
|
||||
20250904114004_intervals.down.sql h1:SquJAPinzFIRN6fJjLLIRsz59Tyr4RwGiGuOFI/N1SQ=
|
||||
20250904114004_intervals.up.sql h1:AFqncTGOiEZVBbhWFqN2zlQ7DyhybB5wJr6a36Atk1E=
|
||||
20250916093608_kurzarbeit.down.sql h1:ljM1a1pQCxOQiXRaXU04GC4V9yy2y20x5eUNQ/zyx+o=
|
||||
20250916093608_kurzarbeit.up.sql h1:pTiw0VfGaf26mhJg4wf98Fqwn1kShJ+PiN2PiM4q1kk=
|
||||
h1:gE7ikkZS7bQbedAjVspQKftSo5ODij2eiQGWbfQEYmI=
|
||||
20250901201159_initial.up.sql h1:Mb1RlVdFvcxqU9HrSK6oNeURqFa3O4KzB3rDa+6+3gc=
|
||||
20250901201250_control_tables.up.sql h1:a5LATgR/CRiC4GsqxkJ94TyJOxeTcW74eCnodIy+c1E=
|
||||
20250901201710_triggers_extension.up.sql h1:z9b6Hk9btE2Ns4mU7B16HjvYBP6EEwHAXVlvPpkn978=
|
||||
20250903221313_overtime.up.sql h1:t/B435ShW5ZEnzC81jRABWVZ5gNm7tPZPnOO6/ZY6ow=
|
||||
20250903233030_non_null_contraints.up.sql h1:YKeYgazfh+jPyh7hFT/pV+By8eHnk1taXnlgSLyXSA0=
|
||||
20250904114004_intervals.up.sql h1:gDdN8cJ4xH1vQhAbbhqD5lwdyEO1N9EIqEYkmWGiWIU=
|
||||
20250916093608_kurzarbeit.up.sql h1:yDAAMLyUXz6b7+MI6XK/HZMPzutKoT2NNNOCjFaqSts=
|
||||
20251013212224_buchungs_array.up.sql h1:mbhvnwMUkEFFQQ41NC47auqxbtvNkztziWvpLDFm6tA=
|
||||
|
||||
Reference in New Issue
Block a user