small fixes in pdf generation + time calculation
All checks were successful
Tests / Run Go Tests (push) Successful in 27s

This commit is contained in:
2025-09-15 12:33:46 +02:00
parent 2d0b117403
commit 656d4c2340
8 changed files with 865 additions and 214 deletions

View File

@@ -11,9 +11,14 @@ import (
func PDFHandler(w http.ResponseWriter, r *http.Request) {
helper.RequiresLogin(Session, w, r)
startDate, err := time.Parse("2006-01-02", "2025-09-01")
startDate, err := parseTimestamp(r, "start", time.Now().Format("2006-01-02"))
if err != nil {
log.Println("Error")
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)
@@ -22,8 +27,10 @@ func PDFHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Error getting user!")
}
//TODO: only accepted weeks
weeks := models.GetWorkDays(user, startDate, endDate)
log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
// log.Printf("Using Dates: %s - %s\n", startDate.String(), endDate.String())
templates.PDFReportEmploye(user, weeks, startDate, endDate).Render(r.Context(), w)
}