feat: extra properties dynamiques, filtrage meta_status et alertes retard
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m37s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m37s
This commit is contained in:
@@ -10,6 +10,31 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// resolveStatusLabel returns the display label for a manual status name
|
||||
func resolveStatusLabel(statusOptions interface{}, manualStatus string) string {
|
||||
switch opts := statusOptions.(type) {
|
||||
case []map[string]any:
|
||||
for _, opt := range opts {
|
||||
if name, _ := opt["name"].(string); name == manualStatus {
|
||||
if label, ok := opt["label"].(string); ok {
|
||||
return label
|
||||
}
|
||||
}
|
||||
}
|
||||
case []interface{}:
|
||||
for _, opt := range opts {
|
||||
if optMap, ok := opt.(map[string]interface{}); ok {
|
||||
if name, _ := optMap["name"].(string); name == manualStatus {
|
||||
if label, ok := optMap["label"].(string); ok {
|
||||
return label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return manualStatus
|
||||
}
|
||||
|
||||
func (r *XLSXRenderer) VehicleBookings(w http.ResponseWriter, bookings []fleetsstorage.Booking, vehiclesMap map[string]fleetsstorage.Vehicle, driversMap map[string]mobilityaccountsstorage.Account) {
|
||||
// Create Excel spreadsheet
|
||||
spreadsheet := r.NewSpreadsheet("Réservations véhicules")
|
||||
@@ -55,6 +80,10 @@ func (r *XLSXRenderer) VehicleBookings(w http.ResponseWriter, bookings []fleetss
|
||||
|
||||
spreadsheet.SetHeaders(headers)
|
||||
|
||||
// Read status management config
|
||||
isManualStatus := r.Config.GetString("modules.vehicles.status_management") == "manual"
|
||||
statusOptions := r.Config.Get("modules.vehicles.status_options")
|
||||
|
||||
// Add data rows
|
||||
for _, booking := range bookings {
|
||||
vehicle := vehiclesMap[booking.Vehicleid]
|
||||
@@ -69,6 +98,8 @@ func (r *XLSXRenderer) VehicleBookings(w http.ResponseWriter, bookings []fleetss
|
||||
status := ""
|
||||
if booking.Deleted {
|
||||
status = "Annulé"
|
||||
} else if isManualStatus {
|
||||
status = resolveStatusLabel(statusOptions, booking.ManualStatus)
|
||||
} else {
|
||||
switch booking.Status() {
|
||||
case 1:
|
||||
@@ -216,6 +247,10 @@ func (r *XLSXRenderer) VehicleBookingsAdmin(w http.ResponseWriter, bookings []fl
|
||||
|
||||
spreadsheet.SetHeaders(headers)
|
||||
|
||||
// Read status management config
|
||||
isManualStatusAdmin := r.Config.GetString("modules.vehicles.status_management") == "manual"
|
||||
statusOptionsAdmin := r.Config.Get("modules.vehicles.status_options")
|
||||
|
||||
// Add data rows
|
||||
for _, booking := range bookings {
|
||||
// Get vehicle from map
|
||||
@@ -243,6 +278,8 @@ func (r *XLSXRenderer) VehicleBookingsAdmin(w http.ResponseWriter, bookings []fl
|
||||
status := ""
|
||||
if booking.Deleted {
|
||||
status = "Annulé"
|
||||
} else if isManualStatusAdmin {
|
||||
status = resolveStatusLabel(statusOptionsAdmin, booking.ManualStatus)
|
||||
} else {
|
||||
switch booking.Status() {
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user