reservation calendar 2

This commit is contained in:
2024-07-26 13:40:56 +02:00
parent a7cf9fe4f0
commit b97c6cba5c
6 changed files with 110 additions and 2 deletions

View File

@ -624,6 +624,9 @@ func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Re
now = time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.UTC)
}
data := make(map[string]interface{})
data["now"] = now
next := now.AddDate(0, 1, 0)
last := now.AddDate(0, -1, 0)
@ -641,9 +644,28 @@ func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Re
stringMap["this_month"] = now.Format("01")
stringMap["this_month_year"] = now.Format("2006")
// get the first and last days from the month
currentYear, currentMonth, _ := now.Date()
currentLocation := now.Location()
firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
intMap := make(map[string]int)
intMap["days_in_month"] = lastOfMonth.Day()
rooms, err := m.DB.AllRooms()
if err != nil {
helpers.ServerError(w, err)
return
}
data["rooms"] = rooms
render.Template(w, r, "admin-reservations-calendar.page.tmpl",
&models.TemplateData{
StringMap: stringMap,
Data: data,
IntMap: intMap,
})
}