Showing the reservation calendar

This commit is contained in:
2024-07-26 10:18:27 +02:00
parent 5987fadb03
commit a7cf9fe4f0
3 changed files with 46 additions and 3 deletions

View File

@ -616,7 +616,35 @@ func (m *Repository) AdminPostShowReservation(w http.ResponseWriter, r *http.Req
// AdminReservationsCalendar displays the reservation calendar
func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Request) {
render.Template(w, r, "admin-reservations-calendar.page.tmpl", &models.TemplateData{})
now := time.Now()
if r.URL.Query().Get("y") != "" {
year, _ := strconv.Atoi(r.URL.Query().Get("y"))
month, _ := strconv.Atoi(r.URL.Query().Get("m"))
now = time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.UTC)
}
next := now.AddDate(0, 1, 0)
last := now.AddDate(0, -1, 0)
nextMonth := next.Format("01")
nextMonthYear := next.Format("2006")
lastMonth := last.Format("01")
lastMonthYear := last.Format("2006")
stringMap := make(map[string]string)
stringMap["next_month"] = nextMonth
stringMap["next_month_year"] = nextMonthYear
stringMap["last_month"] = lastMonth
stringMap["last_month_year"] = lastMonthYear
stringMap["this_month"] = now.Format("01")
stringMap["this_month_year"] = now.Format("2006")
render.Template(w, r, "admin-reservations-calendar.page.tmpl",
&models.TemplateData{
StringMap: stringMap,
})
}
// AdminProcessReservation marks a reservation as processed