added control tables (s_*) + working on implementing absence and booking types
Some checks failed
arbeitszeitmessung/pipeline/head There was a failure building this commit

This commit is contained in:
2025-08-02 08:55:40 +02:00
parent 4201ed7b1c
commit 7670efa99b
10 changed files with 176 additions and 54 deletions

View File

@@ -13,6 +13,11 @@ import (
type SameBookingError struct{}
type BookingType struct {
Id int8
Name string
}
func (e SameBookingError) Error() string {
return "the same booking already exists!"
}
@@ -261,3 +266,34 @@ func (b *Booking) UpdateTime(newTime time.Time) {
func (b *Booking) ToString() string {
return fmt.Sprintf("Booking %d: at: %s, as type: %d", b.CounterId, b.Timestamp.Format("15:04"), b.CheckInOut)
}
func GetBokkingTypes() ([]BookingType, error) {
var types []BookingType
qStr, err := DB.Prepare("SELECT anwesenheit_id, anwesenheit_name FROM s_anwesenheit_typen;")
if err != nil {
return types, err
}
defer qStr.Close()
rows, err := qStr.Query()
if err != nil {
log.Println("Error getting anwesenheit rows!", err)
return types, err
}
defer rows.Close()
for rows.Next() {
var bookingType BookingType
if err := rows.Scan(&bookingType.Id, &bookingType.Name); err != nil {
log.Println("Error scanning row!", err)
}
types = append(types, bookingType)
}
return types, nil
}
func GetBookingTypesCached() []BookingType {
types, err := definedTypes.Get("s_anwesenheit_typen")
if err != nil {
return []BookingType{}
}
return types.([]BookingType)
}