working on printable PDF Forms
All checks were successful
Tests / Run Go Tests (push) Successful in 30s
All checks were successful
Tests / Run Go Tests (push) Successful in 30s
This commit is contained in:
29
Backend/endpoints/pdf.go
Normal file
29
Backend/endpoints/pdf.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user