Skip to content

Commit

Permalink
reservations celendar 75% complete
Browse files Browse the repository at this point in the history
  • Loading branch information
ErfiDev committed Dec 8, 2021
1 parent ef37249 commit 57f0258
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 26 deletions.
36 changes: 28 additions & 8 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,12 @@ func (r Repository) CompleteReservation(res http.ResponseWriter, req *http.Reque
}
}

func (r Repository) AdminReservationCelender(res http.ResponseWriter, req *http.Request) {
func (r Repository) AdminReservationCelendar(res http.ResponseWriter, req *http.Request) {
now := time.Now()

stringMap := make(map[string]string)
data := make(map[string]interface{})

if req.URL.Query().Get("y") != "" && req.URL.Query().Get("m") != "" {
year, _ := strconv.Atoi(req.URL.Query().Get("y"))
month, _ := strconv.Atoi(req.URL.Query().Get("m"))
Expand All @@ -696,24 +699,41 @@ func (r Repository) AdminReservationCelender(res http.ResponseWriter, req *http.
lastMonth := last.Format("01")
lastYear := last.Format("2006")

stringMap := make(map[string]string)

stringMap["next_month"] = nextMonth
stringMap["next_year"] = nextYear
stringMap["last_month"] = lastMonth
stringMap["last_year"] = lastYear
stringMap["now_month"] = now.Format("01")
stringMap["now_year"] = now.Format("2006")

data := make(map[string]interface{})
data["title"] = "Reservations Celender"
data["path"] = "/reservation"
data["title"] = "Reservations Celendar"
data["path"] = "/reservation-celendar"

utils.RenderTemplate(res, req, "admin-res-celender.page.gohtml", &models.TmpData{
utils.RenderTemplate(res, req, "admin-res-celendar.page.gohtml", &models.TmpData{
StringMap: stringMap,
Data: data,
})
} else {
http.Redirect(res, req, "/admin/dashboard", http.StatusSeeOther)
next := now.AddDate(0, 1, 0)
last := now.AddDate(0, -1, 0)

nextMonth := next.Format("01")
nextYear := next.Format("2006")
lastMonth := last.Format("01")
lastYear := last.Format("2006")

stringMap["next_month"] = nextMonth
stringMap["next_year"] = nextYear
stringMap["last_month"] = lastMonth
stringMap["last_year"] = lastYear
stringMap["now_year"] = now.Format("2006")
stringMap["now_month"] = now.Format("01")
data["title"] = "Reservations Celendar"
data["path"] = "/reservations-celendar"

utils.RenderTemplate(res, req, "admin-res-celendar.page.gohtml", &models.TmpData{
StringMap: stringMap,
Data: data,
})
}
}
2 changes: 1 addition & 1 deletion routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Routes() http.Handler {
mux.Get("/reservations", controllers.Repo.AdminReservations)
mux.Get("/newReservations", controllers.Repo.NewReservations)
mux.Get("/reservation/{id}", controllers.Repo.SingleReservation)
mux.Get("/reservations-celender", controllers.Repo.AdminReservationCelender)
mux.Get("/reservations-celendar", controllers.Repo.AdminReservationCelendar)
mux.Post("/api/updateReservation", controllers.Repo.ApiUpdateReservation)
mux.Post("/api/deleteReservation", controllers.Repo.DeleteReservation)
mux.Post("/api/completeReservation", controllers.Repo.CompleteReservation)
Expand Down
17 changes: 17 additions & 0 deletions static/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,21 @@ body {
display: flex;
justify-content: center;
align-items: center;
}

.admin-reservation-celendar {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}

.reservation-celendar-top {
display: flex;
justify-items: center;
align-items: center;
gap: 10vw;
}
.reservation-celendar-top a {
cursor: pointer;
}
17 changes: 17 additions & 0 deletions views/admin-res-celendar.page.gohtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{template "admin" .}}

{{define "adminsubpage"}}
<div class="admin-reservation-celendar">
{{$sm := .StringMap}}
<div class="reservation-celendar-top">
<a href="/admin/reservations-celendar?y={{index $sm "last_year"}}&m={{index $sm "last_month"}}">{{"< "}}Last Month</a>
<h1>
{{$sm.now_year}} - {{$sm.now_month}}
</h1>
<a href="/admin/reservations-celendar?y={{index $sm "next_year"}}&m={{index $sm "next_month"}}">Next Month{{" >"}}</a>
</div>
<div class="reservation-celendar-main">

</div>
</div>
{{end}}
14 changes: 0 additions & 14 deletions views/admin-res-celender.page.gohtml

This file was deleted.

6 changes: 3 additions & 3 deletions views/admin.layout.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<a href="/admin/newReservations">New Reservations</a>
</li>
{{end}}
{{if eq $path "/reservations-celender"}}
{{if eq $path "/reservations-celendar"}}
<li class="admin-sidebar-item used">
<a href="/admin/reservations-celender">Reservations Celender</a>
<a href="/admin/reservations-celendar">Reservations Celendar</a>
</li>
{{else}}
<li class="admin-sidebar-item">
<a href="/admin/reservations-celender">Reservations Celender</a>
<a href="/admin/reservations-celendar">Reservations Celendar</a>
</li>
{{end}}
{{if eq $path "/admins"}}
Expand Down

0 comments on commit 57f0258

Please sign in to comment.