CHANGE: finalized user auth + added booking edit view
This commit is contained in:
@@ -132,6 +132,9 @@ func (b *Booking) GetBookingsGrouped(card_uid string, tsFrom time.Time, tsTo tim
|
||||
var result []WorkDay
|
||||
for key, bookings := range grouped {
|
||||
day, _ := time.Parse("2006-01-02", key)
|
||||
sort.Slice(bookings, func(i, j int) bool {
|
||||
return bookings[i].Timestamp.Before(bookings[j].Timestamp)
|
||||
})
|
||||
result = append(result, WorkDay{Day: day, Bookings: bookings})
|
||||
}
|
||||
|
||||
@@ -157,11 +160,11 @@ func (b Booking) Save() {
|
||||
|
||||
func (b *Booking) GetBookingType() string {
|
||||
switch b.CheckInOut{
|
||||
case (1):
|
||||
case 1,3: //manuelle Änderung
|
||||
return "kommen"
|
||||
case (2):
|
||||
case 2, 4: //manuelle Änderung
|
||||
return "gehen"
|
||||
case(255):
|
||||
case 255:
|
||||
return "abgemeldet"
|
||||
default:
|
||||
return "Buchungs Typ unbekannt"
|
||||
@@ -203,3 +206,22 @@ func checkLastBooking(b Booking) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Booking) UpdateTime(newTime time.Time){
|
||||
hour, minute, _ := newTime.Clock()
|
||||
if(hour == b.Timestamp.Local().Hour() && minute == b.Timestamp.Local().Minute()){
|
||||
return
|
||||
}
|
||||
// TODO: add check for time overlap
|
||||
|
||||
var newBooking Booking
|
||||
newBooking.Timestamp = time.Date(b.Timestamp.Year(), b.Timestamp.Month(), b.Timestamp.Day(), hour, minute, 0, 0, time.Local).UTC()
|
||||
if(b.CheckInOut < 3){
|
||||
newBooking.CheckInOut = b.CheckInOut + 2
|
||||
}
|
||||
if(b.CheckInOut == 255){
|
||||
newBooking.CheckInOut = 4
|
||||
}
|
||||
b.Update(newBooking)
|
||||
b.Save()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user