This commit is contained in:
@@ -2,6 +2,7 @@ package models
|
||||
|
||||
import (
|
||||
"arbeitszeitmessung/helper"
|
||||
"arbeitszeitmessung/helper/logs"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -199,6 +200,7 @@ func (b Booking) Save() {
|
||||
log.Fatalf("Error preparing query: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = qStr.Query(b.CounterId, b.CardUID, b.GeraetID, b.CheckInOut, b.Timestamp)
|
||||
if err != nil {
|
||||
log.Fatalf("Error executing query: %v", err)
|
||||
@@ -231,6 +233,8 @@ func (b *Booking) GetBookingType() string {
|
||||
}
|
||||
|
||||
func (b *Booking) Update(nb Booking) {
|
||||
auditLog, closeLog := logs.NewAudit()
|
||||
defer closeLog()
|
||||
if b.CheckInOut != nb.CheckInOut && nb.CheckInOut != 0 {
|
||||
b.CheckInOut = nb.CheckInOut
|
||||
}
|
||||
@@ -241,6 +245,7 @@ func (b *Booking) Update(nb Booking) {
|
||||
b.GeraetID = nb.GeraetID
|
||||
}
|
||||
if b.Timestamp != nb.Timestamp {
|
||||
auditLog.Printf("Änderung in Buchung %d von '%s': Buchungszeit (%s -> %s).", b.CounterId, b.CardUID, b.Timestamp.Format("15:04"), nb.Timestamp.Format("15:04)"))
|
||||
b.Timestamp = nb.Timestamp
|
||||
}
|
||||
}
|
||||
@@ -281,11 +286,15 @@ func (b *Booking) UpdateTime(newTime time.Time) {
|
||||
if b.CheckInOut == 254 {
|
||||
newBooking.CheckInOut = 4
|
||||
}
|
||||
log.Println("Updating")
|
||||
b.Update(newBooking)
|
||||
// TODO Check verify
|
||||
b.Verify()
|
||||
b.Save()
|
||||
if b.Verify() {
|
||||
b.Save()
|
||||
} else {
|
||||
log.Println("Cannot save updated booking!", b.ToString())
|
||||
}
|
||||
// b.Verify()
|
||||
// b.Save()
|
||||
}
|
||||
|
||||
func (b *Booking) ToString() string {
|
||||
|
||||
Reference in New Issue
Block a user