Marking a resercation as processed
This commit is contained in:
parent
ca1e72c676
commit
fcd29cc082
@ -44,6 +44,7 @@ func routes(app *config.AppConfig) http.Handler {
|
|||||||
mux.Get("/reservations-new", handlers.Repo.AdminNewReservations)
|
mux.Get("/reservations-new", handlers.Repo.AdminNewReservations)
|
||||||
mux.Get("/reservations-all", handlers.Repo.AdminAllReservations)
|
mux.Get("/reservations-all", handlers.Repo.AdminAllReservations)
|
||||||
mux.Get("/reservations-calendar", handlers.Repo.AdminReservationsCalendar)
|
mux.Get("/reservations-calendar", handlers.Repo.AdminReservationsCalendar)
|
||||||
|
mux.Get("/process-reservation/{src}/{id}", handlers.Repo.AdminProcessReservation)
|
||||||
|
|
||||||
mux.Get("/reservations/{src}/{id}", handlers.Repo.AdminShowReservation)
|
mux.Get("/reservations/{src}/{id}", handlers.Repo.AdminShowReservation)
|
||||||
mux.Post("/reservations/{src}/{id}", handlers.Repo.AdminPostShowReservation)
|
mux.Post("/reservations/{src}/{id}", handlers.Repo.AdminPostShowReservation)
|
||||||
|
@ -16,6 +16,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-chi/chi/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Repo the repository used by the handlers
|
// Repo the repository used by the handlers
|
||||||
@ -616,3 +618,15 @@ func (m *Repository) AdminPostShowReservation(w http.ResponseWriter, r *http.Req
|
|||||||
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{})
|
render.Template(w, r, "admin-reservations-calendar.page.tmpl", &models.TemplateData{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AdminProcessReservation marks a reservation as processed
|
||||||
|
func (m *Repository) AdminProcessReservation(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id, _ := strconv.Atoi(chi.URLParam(r, "id"))
|
||||||
|
src := chi.URLParam(r, "src")
|
||||||
|
|
||||||
|
_ = m.DB.UpdateProcessedForReservation(id, 1)
|
||||||
|
|
||||||
|
m.App.Session.Put(r.Context(), "flash", "Reservation marked as processed")
|
||||||
|
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("/admin/reservations-%s", src), http.StatusSeeOther)
|
||||||
|
}
|
||||||
|
@ -97,12 +97,6 @@ function Prompt() {
|
|||||||
c.didOpen();
|
c.didOpen();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
preConfirm: () => {
|
|
||||||
return [
|
|
||||||
document.getElementById('start').value,
|
|
||||||
document.getElementById('end').value,
|
|
||||||
]
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (c.callback !== undefined) {
|
if (c.callback !== undefined) {
|
||||||
|
@ -50,7 +50,25 @@ Reservation
|
|||||||
|
|
||||||
<input type="submit" class="btn btn-primary" value="Save">
|
<input type="submit" class="btn btn-primary" value="Save">
|
||||||
<a href="/admin/reservations-{{$src}}" class="btn btn-warning">Cancel</a>
|
<a href="/admin/reservations-{{$src}}" class="btn btn-warning">Cancel</a>
|
||||||
|
<a href="#" class="btn btn-info" onclick="processRes({{$res.ID}})">Mark as Processed</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{define "js"}}
|
||||||
|
{{$src := index .StringMap "src"}}
|
||||||
|
<script>
|
||||||
|
function processRes(id) {
|
||||||
|
attention.custom({
|
||||||
|
icon: 'warning',
|
||||||
|
msg: 'Are you sure?',
|
||||||
|
callback: function(result) {
|
||||||
|
if (result != false) {
|
||||||
|
window.location.href = "/admin/process-reservation/{{$src}}/" + id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<!-- plugin css for this page -->
|
<!-- plugin css for this page -->
|
||||||
<!-- End plugin css for this page -->
|
<!-- End plugin css for this page -->
|
||||||
<!-- inject:css -->
|
<!-- inject:css -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://unpkg.com/notie/dist/notie.min.css">
|
||||||
<link rel="stylesheet" href="/static/admin/css/style.css">
|
<link rel="stylesheet" href="/static/admin/css/style.css">
|
||||||
<!-- endinject -->
|
<!-- endinject -->
|
||||||
<link rel="shortcut icon" href="/static/admin/images/favicon.png" />
|
<link rel="shortcut icon" href="/static/admin/images/favicon.png" />
|
||||||
@ -25,6 +26,9 @@
|
|||||||
label {
|
label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.notie-container {
|
||||||
|
z-index: 50000;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
{{block "css" .}}
|
{{block "css" .}}
|
||||||
|
|
||||||
@ -132,8 +136,25 @@
|
|||||||
<script src="/static/admin/js/todolist.js"></script>
|
<script src="/static/admin/js/todolist.js"></script>
|
||||||
<!-- endinject -->
|
<!-- endinject -->
|
||||||
<!-- Custom js for this page-->
|
<!-- Custom js for this page-->
|
||||||
|
<script src="https://unpkg.com/notie"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<script src="/static/admin/js/dashboard.js"></script>
|
<script src="/static/admin/js/dashboard.js"></script>
|
||||||
<!-- End custom js for this page-->
|
<!-- End custom js for this page-->
|
||||||
|
<script>
|
||||||
|
let attention = Prompt()
|
||||||
|
|
||||||
|
{{with .Error}}
|
||||||
|
notify("{{.}}", "error")
|
||||||
|
{{end}}
|
||||||
|
{{with .Warning}}
|
||||||
|
notify("{{.}}", "warning")
|
||||||
|
{{end}}
|
||||||
|
{{with .Flash}}
|
||||||
|
notify("{{.}}", "success")
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
</script>
|
||||||
{{block "js" .}}
|
{{block "js" .}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
Reference in New Issue
Block a user