mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
store booking request in D
This commit is contained in:
parent
fef6ba4954
commit
07f91e8f85
4 changed files with 24 additions and 7 deletions
|
|
@ -28,17 +28,17 @@ func (b Booking) InvoiceNumber(hc *config.Host) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type BookingRequest struct {
|
type BookingRequest struct {
|
||||||
From time.Time
|
|
||||||
To time.Time
|
|
||||||
gorm.Model
|
gorm.Model
|
||||||
CustomerName string
|
From time.Time
|
||||||
PhoneNumber *string // ensure at least one out of these is not null
|
To time.Time
|
||||||
|
PhoneNumber *string
|
||||||
Email *string
|
Email *string
|
||||||
|
BookingId *int
|
||||||
|
CustomerName string
|
||||||
ItemType string
|
ItemType string
|
||||||
Message string
|
Message string
|
||||||
Status string
|
Status string
|
||||||
CustomerNumber int
|
CustomerNumber int
|
||||||
BookingId int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
|
|
|
||||||
|
|
@ -154,3 +154,17 @@ func (bs Service) BuildReport(period string, month, year int) *Report {
|
||||||
}, 0.0),
|
}, 0.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bs Service) CreateRequest(From time.Time, To time.Time, Name string, PhoneNumber string, Email string, Item string, CustomerNumber int) *BookingRequest {
|
||||||
|
b := &BookingRequest{
|
||||||
|
CustomerName: Name,
|
||||||
|
PhoneNumber: &PhoneNumber,
|
||||||
|
CustomerNumber: CustomerNumber,
|
||||||
|
Email: &Email,
|
||||||
|
From: From,
|
||||||
|
To: To,
|
||||||
|
ItemType: Item,
|
||||||
|
}
|
||||||
|
_ = bs.db.Create(b)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
|
||||||
|
"github.com/rjNemo/rentease/internal/booking"
|
||||||
"github.com/rjNemo/rentease/internal/view"
|
"github.com/rjNemo/rentease/internal/view"
|
||||||
myTime "github.com/rjNemo/rentease/pkg/time"
|
myTime "github.com/rjNemo/rentease/pkg/time"
|
||||||
)
|
)
|
||||||
|
|
@ -17,7 +18,7 @@ func handleHomePage() echo.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleRequestBooking() echo.HandlerFunc {
|
func handleRequestBooking(bs *booking.Service) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
itemStr := c.FormValue("item")
|
itemStr := c.FormValue("item")
|
||||||
fromStr := c.FormValue("from")
|
fromStr := c.FormValue("from")
|
||||||
|
|
@ -53,6 +54,8 @@ func handleRequestBooking() echo.HandlerFunc {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bs.CreateRequest(from, to, name, phoneNumber, email, itemStr, 1)
|
||||||
|
|
||||||
return renderTempl(c, http.StatusSeeOther, view.BaseLayout())
|
return renderTempl(c, http.StatusSeeOther, view.BaseLayout())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package server
|
||||||
func (s Server) MountHandlers() {
|
func (s Server) MountHandlers() {
|
||||||
// public
|
// public
|
||||||
s.Router.GET("/", handleHomePage())
|
s.Router.GET("/", handleHomePage())
|
||||||
s.Router.POST("/request-booking", handleRequestBooking())
|
s.Router.POST("/request-booking", handleRequestBooking(s.bs))
|
||||||
// admin
|
// admin
|
||||||
s.Router.GET("/bookings", handleListBookingPage(s.bs, s.hc))
|
s.Router.GET("/bookings", handleListBookingPage(s.bs, s.hc))
|
||||||
s.Router.GET("/bookings/new", handleNewBookingPage())
|
s.Router.GET("/bookings/new", handleNewBookingPage())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue