added new booking Button + ui for abwesenheit

This commit is contained in:
2025-04-25 17:03:05 +02:00
parent 65ea9c63e9
commit 35ec575a05
6 changed files with 1328 additions and 143 deletions

View File

@@ -69,6 +69,21 @@ func (b *Booking) Insert() error {
return nil
}
func (b *Booking) InsertTimestamp() error {
if b.Timestamp.IsZero() {
b.Timestamp = time.Now()
}
stmt, err := DB.Prepare((`INSERT INTO anwesenheit (card_uid, geraet_id, check_in_out, timestamp) VALUES ($1, $2, $3, $4) RETURNING counter_id`))
if err != nil {
return err
}
err = stmt.QueryRow(b.CardUID, b.GeraetID, b.CheckInOut, b.Timestamp).Scan(&b.CounterId)
if err != nil {
return err
}
return nil
}
func (b *Booking) GetBookingById(booking_id int) (Booking, error) {
var booking Booking
qStr, err := DB.Prepare((`SELECT counter_id, timestamp, card_uid, geraet_id, check_in_out FROM anwesenheit WHERE counter_id = $1`))
@@ -79,10 +94,10 @@ func (b *Booking) GetBookingById(booking_id int) (Booking, error) {
if err != nil {
return booking, err
}
if !booking.Verify() {
fmt.Printf("Booking verification failed")
return booking, nil
}
// if !booking.Verify() {
// fmt.Printf("Booking verification failed! %d", )
// return booking, nil
// }
return booking, nil
}
@@ -167,17 +182,17 @@ func (b *Booking) GetBookingType() string {
case 1: //manuelle Änderung
return "kommen"
case 3:
if(debug){
return "kommen manuell"
}
return "kommen"
if debug {
return "kommen manuell"
}
return "kommen"
case 2: //manuelle Änderung
return "gehen"
case 4:
if(debug){
return "gehen manuell"
}
return "gehen"
if debug {
return "gehen manuell"
}
return "gehen"
case 254:
return "abgemeldet"
default: