reservation calendar 2
This commit is contained in:
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user