small fixes in pdf generation + time calculation
All checks were successful
Tests / Run Go Tests (push) Successful in 27s
All checks were successful
Tests / Run Go Tests (push) Successful in 27s
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user