Showing the reservation calendar

This commit is contained in:
vinchent 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 // AdminReservationsCalendar displays the reservation calendar
func (m *Repository) AdminReservationsCalendar(w http.ResponseWriter, r *http.Request) { 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 // AdminProcessReservation marks a reservation as processed

View File

@ -6,6 +6,20 @@ Reservations Calendar
{{define "content"}} {{define "content"}}
<div class="col-md-12"> <div class="col-md-12">
Reservations calendar content <div class="text-center">
<h3>{{index .StringMap "this_month"}} {{index .StringMap "this_month_year"}}</h3>
</div>
<div class="float-start">
<a class="btn btn-sm btn-outline-secondary"
href="/admin/reservations-calendar?y={{index .StringMap "last_month_year"}}&m={{index .StringMap "last_month"}}">&lt;&lt;</a>
</div>
<div class="float-end">
<a class="btn btn-sm btn-outline-secondary"
href="/admin/reservations-calendar?y={{index .StringMap "next_month_year"}}&m={{index .StringMap "next_month"}}">&gt;&gt;</a>
</div>
<div class="clearfix"></div>
</div> </div>
{{end}} {{end}}

View File

@ -62,7 +62,8 @@
<!-- partial --> <!-- partial -->
<div class="container-fluid page-body-wrapper"> <div class="container-fluid page-body-wrapper">
<!-- partial:partials/_sidebar.html --> <!-- partial:partials/_sidebar.html -->
<nav class="sidebar sidebar-offcanvas" id="sidebar"> <!-- TODO sidebar-offcanvas need to be repaired -->
<nav class="sidebar" id="sidebar">
<ul class="nav"> <ul class="nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/admin/dashboard"> <a class="nav-link" href="/admin/dashboard">