working on printable PDF Forms
All checks were successful
Tests / Run Go Tests (push) Successful in 30s

This commit is contained in:
2025-09-08 00:32:29 +02:00
parent 12ed9959cb
commit 2eab598348
12 changed files with 305 additions and 22 deletions

29
Backend/endpoints/pdf.go Normal file
View File

@@ -0,0 +1,29 @@
package endpoints
import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
"arbeitszeitmessung/templates"
"log"
"net/http"
"time"
)
func PDFHandler(w http.ResponseWriter, r *http.Request) {
helper.RequiresLogin(Session, w, r)
startDate, err := time.Parse("2006-01-02", "2025-08-01")
if err != nil {
log.Println("Error")
}
endDate := startDate.AddDate(0, 1, -1)
user, err := models.GetUserFromSession(Session, r.Context())
if err != nil {
log.Println("Error getting user!")
}
weeks := models.GetWorkDays(user.CardUID, startDate, endDate)
log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
templates.PDFReportEmploye(user, weeks, startDate, endDate).Render(r.Context(), w)
}