Compare commits

...

18 Commits

Author SHA1 Message Date
Arnaud Delcasse c8f8f82535 resolve commit and fix 2023-11-27 08:45:48 +01:00
Arnaud Delcasse 0f5a0ed5ab improve 2023-11-27 07:26:21 +01:00
Nicolas CARON 275c8b1999 comments replace in go.mod 2023-08-07 10:52:29 +02:00
Nicolas CARON 18e890ceed add filter in export fleets 2023-06-02 14:43:56 +02:00
Nicolas CARON b717be9b99 add filter in export fleets 2023-06-02 14:42:55 +02:00
Nicolas CARON ddb08cf671 add export agenda by Salim 2023-06-01 14:11:03 +02:00
Nicolas CARON 4fe479c1fb edit exports/fleets 2023-06-01 10:59:21 +02:00
Nicolas CARON b0dd81bf67 Merge branch 'main' into dev 2023-05-31 11:19:04 +02:00
soukainna 3bfd2e1bfe fix err merge 2023-05-19 10:50:15 +02:00
soukainna b5154bf9be Merge branch 'modifyVehicle' into dev 2023-05-19 10:45:34 +02:00
soukainna 96823f3289 update vehicle 2023-05-19 10:19:30 +02:00
soukainna 93cab33fb9 update vehicle 2023-05-19 10:19:06 +02:00
soukainna d5bc764ef3 fix err 2023-05-12 13:00:19 +02:00
soukainna 1aeb6d50ef add logic fuction to update vehicles 2023-05-12 12:59:16 +02:00
Nicolas CARON f26d792b8b edit vehicles-management handler 2023-05-12 11:05:42 +02:00
Nicolas CARON bfd14d7f4c edit handlers vehicle-management for unbooking a vehicle 2023-05-10 09:52:57 +02:00
Nicolas CARON 31e5eadc73 edit handlers and renderer for delete a booking vehicle 2023-05-05 15:14:56 +02:00
Nicolas CARON 8f20a12bc5 edit config.yaml to add delete_booking route 2023-05-03 14:29:43 +02:00
7 changed files with 425 additions and 129 deletions

2
go.mod
View File

@ -2,7 +2,7 @@ module git.coopgo.io/coopgo-apps/parcoursmob
go 1.18 go 1.18
// replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/ replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform/mobility-accounts/
// replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/ // replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/

View File

@ -47,6 +47,7 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
for _, account := range resp.Accounts[min:] { for _, account := range resp.Accounts[min:] {
if filterAccount(r, account) { if filterAccount(r, account) {
fmt.Println(account)
a := account.ToStorageType() a := account.ToStorageType()
accounts = append([]any{a}, accounts...) accounts = append([]any{a}, accounts...)
} }

View File

@ -45,8 +45,10 @@ func (h *ApplicationHandler) VehiclesManagementOverview(w http.ResponseWriter, r
vehicleBookings := []fleetsstorage.Booking{} vehicleBookings := []fleetsstorage.Booking{}
for _, b := range v.Bookings { for _, b := range v.Bookings {
if b.Status() != fleetsstorage.StatusOld { if b.Status() != fleetsstorage.StatusOld {
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
bookings = append(bookings, b) bookings = append(bookings, b)
} }
}
if b.Unavailableto.After(time.Now()) { if b.Unavailableto.After(time.Now()) {
vehicleBookings = append(vehicleBookings, b) vehicleBookings = append(vehicleBookings, b)
} }
@ -188,36 +190,10 @@ func (h *ApplicationHandler) VehiclesFleetDisplay(w http.ResponseWriter, r *http
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
// if len(resp.Vehicle.ToStorageType().Bookings) == 0 {
// fmt.Println("lol")
// }
// fmt.Println(resp.Vehicle.ToStorageType().Bookings)
h.Renderer.VehiclesFleetDisplay(w, r, resp.Vehicle.ToStorageType()) h.Renderer.VehiclesFleetDisplay(w, r, resp.Vehicle.ToStorageType())
} }
func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
vehicleid := vars["vehicleid"]
if r.Method == "POST" {
w.WriteHeader(http.StatusNotFound)
return
}
request := &fleets.GetVehicleRequest{
Vehicleid: vehicleid,
}
resp, err := h.services.GRPC.Fleets.GetVehicle(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
h.Renderer.VehiclesFleetUpdate(w, r, resp.Vehicle.ToStorageType())
}
func filterVehicle(r *http.Request, v *fleets.Vehicle) bool { func filterVehicle(r *http.Request, v *fleets.Vehicle) bool {
g := r.Context().Value(identification.GroupKey) g := r.Context().Value(identification.GroupKey)
if g == nil { if g == nil {
@ -491,3 +467,208 @@ func (h ApplicationHandler) VehiclesFleetMakeUnavailable(w http.ResponseWriter,
// fmt.Println(vehicles) // fmt.Println(vehicles)
// h.Renderer.UnbookingVehicles(w, r, vehicles) // h.Renderer.UnbookingVehicles(w, r, vehicles)
// } // }
func (h *ApplicationHandler) DeleteBooking(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
bookingid := vars["bookingid"]
request := &fleets.DeleteBookingRequest{
Id: bookingid,
}
_, err := h.services.GRPC.Fleets.DeleteBooking(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/app/vehicles-management/bookings/", http.StatusSeeOther)
}
func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
bookingid := vars["bookingid"]
request := &fleets.GetBookingRequest{
Bookingid: bookingid,
}
resp, err := h.services.GRPC.Fleets.GetBooking(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
// now := time.Now()
// date := now.Format("2006-01-02")
date := "1970-01-01"
unavailableto, _ := time.Parse("2006-01-02", date)
unavailablefrom := unavailableto
current_group, err := h.currentGroup(r)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
current_user_token, current_user_claims, err := h.currentUser(r)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
booked_by_id := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["id"].GetStringValue()
booked_by_name := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["display_name"].GetStringValue()
booked_by_email := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["user"].GetStructValue().Fields["email"].GetStringValue()
booked_by_group_id := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["group"].GetStructValue().Fields["id"].GetStringValue()
booked_by_group_name := resp.Booking.Data.Fields["booked_by"].GetStructValue().Fields["group"].GetStructValue().Fields["name"].GetStringValue()
data := map[string]any{
"booked_by": map[string]any{
"user": map[string]any{
"id": booked_by_id,
"display_name": booked_by_name,
"email": booked_by_email,
},
"group": map[string]any{
"id": booked_by_group_id,
"name": booked_by_group_name,
},
},
"unbooked_by": map[string]any{
"user": map[string]any{
"id": current_user_token.Subject,
"display_name": current_user_claims["first_name"].(string) + " " + current_user_claims["last_name"].(string),
"email": current_user_claims["email"],
},
"group": map[string]any{
"id": current_group.ID,
"name": current_group.Data["name"],
},
},
"Deleted": true,
"motif": r.FormValue("motif"),
}
datapb, err := structpb.NewStruct(data)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
if r.Method == "POST" {
request := &fleets.UpdateBookingRequest{
Booking: &fleets.Booking{
Id: resp.Booking.Id,
Vehicleid: resp.Booking.Vehicleid,
Driver: resp.Booking.Driver,
Startdate: resp.Booking.Startdate,
Enddate: resp.Booking.Enddate,
Unavailablefrom: timestamppb.New(unavailablefrom),
Unavailableto: timestamppb.New(unavailableto),
Data: datapb,
},
}
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/app/vehicles-management/", http.StatusFound)
return
}
h.Renderer.UnbookingVehicle(w, r, resp.Booking.ToStorageType())
}
////////////////////////UpdateVehicle///////////////////////
func (h *ApplicationHandler) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
vehicleID := vars["vehicleid"]
request := &fleets.GetVehicleRequest{
Vehicleid: vehicleID,
}
resp, err := h.services.GRPC.Fleets.GetVehicle(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
namespaceV := resp.Vehicle.Namespace
//typeV := resp.Vehicle.Type
administratorsV := resp.Vehicle.Administrators
if r.Method == "POST" {
fmt.Print(r.FormValue("vehicle_type"))
if err := r.ParseForm(); err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
return
}
dataMap := map[string]any{}
if v := r.FormValue("name"); v != "" {
dataMap["name"] = v
}
if v := r.FormValue("address"); v != "" {
var address map[string]any
err := json.Unmarshal([]byte(v), &address)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
dataMap["address"] = address
}
if v := r.FormValue("informations"); v != "" {
dataMap["informations"] = v
}
if v := r.FormValue("licence_plate"); v != "" {
dataMap["licence_plate"] = v
}
if v := r.FormValue("automatic"); v != "" {
fmt.Println(v)
dataMap["automatic"] = (v == "on")
}
data, err := structpb.NewValue(dataMap)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
request := &fleets.UpdateVehicleRequest{
Vehicle: &fleets.Vehicle{
Id: vehicleID,
Namespace: namespaceV,
Type: r.FormValue("type"),
Administrators: administratorsV,
Data: data.GetStructValue(),
},
}
resp, err := h.services.GRPC.Fleets.UpdateVehicle(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, fmt.Sprintf("/app/vehicles-management/fleet/%s", resp.Vehicle.Id), http.StatusFound)
return
}
vehicles_types := h.config.GetStringSlice("modules.fleets.vehicle_types")
h.Renderer.VehiclesFleetUpdate(w, r, resp.Vehicle.ToStorageType(), vehicles_types)
}

View File

@ -13,14 +13,17 @@ import (
groupsstorage "git.coopgo.io/coopgo-platform/groups-management/storage" groupsstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
accounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi" accounts "git.coopgo.io/coopgo-platform/mobility-accounts/grpcapi"
accountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage" accountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
"github.com/gorilla/mux"
"github.com/xuri/excelize/v2" "github.com/xuri/excelize/v2"
) )
func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) { func (h *ExportsHandler) Agenda(filter string) func(w http.ResponseWriter, r *http.Request) {
switch filter {
case "allEvents":
return func(w http.ResponseWriter, r *http.Request) {
resp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{ resp, err := h.services.GRPC.Agenda.GetEvents(context.TODO(), &agenda.GetEventsRequest{
Namespaces: []string{"parcoursmob_dispositifs"}, Namespaces: []string{"parcoursmob_dispositifs"},
}) })
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
@ -67,15 +70,70 @@ func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) {
beneficiaries_map[ben.Id] = ben.ToStorageType() beneficiaries_map[ben.Id] = ben.ToStorageType()
} }
/////////////// Generate file f := h.generateExcel(events, groups, beneficiaries_map)
h.writeFileResponse(f, w)
}
case "oneEvent":
return func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
eventId := vars["eventid"]
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), &agenda.GetEventRequest{
Id: eventId,
})
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
groupids := []string{}
beneficiaries_ids := []string{}
groupids = append(groupids, resp.Event.Owners...)
for _, subscriptions := range resp.Event.Subscriptions {
beneficiaries_ids = append(beneficiaries_ids, subscriptions.Subscriber)
}
groupsresp, err := h.services.GRPC.GroupsManagement.GetGroupsBatch(context.TODO(), &groupsmanagement.GetGroupsBatchRequest{
Groupids: groupids,
})
groups := map[string]groupsstorage.Group{}
if err == nil {
for _, g := range groupsresp.Groups {
groups[g.Id] = g.ToStorageType()
}
}
beneficiaries, err := h.services.GRPC.MobilityAccounts.GetAccountsBatch(context.TODO(), &accounts.GetAccountsBatchRequest{
Accountids: beneficiaries_ids,
})
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
beneficiaries_map := map[string]accountsstorage.Account{}
for _, ben := range beneficiaries.Accounts {
beneficiaries_map[ben.Id] = ben.ToStorageType()
}
f := h.generateExcel([]agendastorage.Event{resp.Event.ToStorageType()}, groups, beneficiaries_map)
h.writeFileResponse(f, w)
}
}
return nil
}
func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[string]groupsstorage.Group,
beneficiaries_map map[string]accountsstorage.Account) *excelize.File {
f := excelize.NewFile() f := excelize.NewFile()
defer func() { defer func() {
if err := f.Close(); err != nil { if err := f.Close(); err != nil {
fmt.Println(err) fmt.Println(err)
} }
}() }()
f.SetCellValue("Sheet1", "A1", "Evénement") f.SetCellValue("Sheet1", "A1", "Evénement")
f.SetCellValue("Sheet1", "B1", "Date de début") f.SetCellValue("Sheet1", "B1", "Date de début")
f.SetCellValue("Sheet1", "C1", "Date de fin") f.SetCellValue("Sheet1", "C1", "Date de fin")
@ -84,7 +142,8 @@ func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", "F1", "Numéro allocataire / Pole emploi") f.SetCellValue("Sheet1", "F1", "Numéro allocataire / Pole emploi")
f.SetCellValue("Sheet1", "G1", "Prescipteur") f.SetCellValue("Sheet1", "G1", "Prescipteur")
f.SetCellValue("Sheet1", "H1", "Prescipteur Nom") f.SetCellValue("Sheet1", "H1", "Prescipteur Nom")
f.SetCellValue("Sheet1", "I1", "Gestionnaire événement") f.SetCellValue("Sheet1", "I1", "Prescipteur Email")
f.SetCellValue("Sheet1", "J1", "Gestionnaire événement")
// f.SetCellValue("Sheet1", "I1", "Prescripteur téléphone") // f.SetCellValue("Sheet1", "I1", "Prescripteur téléphone")
i := 2 i := 2
@ -94,11 +153,13 @@ func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) {
} }
admin := groups[e.Owners[0]] admin := groups[e.Owners[0]]
for _, s := range e.Subscriptions {
subscribedbygroup := "" subscribedbygroup := ""
subscribedbyuser := "" subscribedbyuser := ""
if v, ok := e.Data["subscribed_by"].(map[string]any); ok { subscribedbyemail := ""
if v, ok := s.Data["subscribed_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok { if v2, ok := v["group"].(map[string]any); ok {
if v3, ok := v2["id"].(string); ok { if v3, ok := v2["name"].(string); ok {
subscribedbygroup = v3 subscribedbygroup = v3
} }
@ -107,12 +168,13 @@ func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) {
if v5, ok := v4["display_name"].(string); ok { if v5, ok := v4["display_name"].(string); ok {
subscribedbyuser = v5 subscribedbyuser = v5
} }
if v6, ok := v4["email"].(string); ok {
subscribedbyemail = v6
}
} }
} }
for _, s := range e.Subscriptions {
beneficiary := beneficiaries_map[s.Subscriber] beneficiary := beneficiaries_map[s.Subscriber]
f.SetCellValue("Sheet1", fmt.Sprintf("A%d", i), e.Name) f.SetCellValue("Sheet1", fmt.Sprintf("A%d", i), e.Name)
@ -121,17 +183,22 @@ func (h *ExportsHandler) Agenda(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", fmt.Sprintf("D%d", i), beneficiary.Data["last_name"]) f.SetCellValue("Sheet1", fmt.Sprintf("D%d", i), beneficiary.Data["last_name"])
f.SetCellValue("Sheet1", fmt.Sprintf("E%d", i), beneficiary.Data["first_name"]) f.SetCellValue("Sheet1", fmt.Sprintf("E%d", i), beneficiary.Data["first_name"])
f.SetCellValue("Sheet1", fmt.Sprintf("F%d", i), beneficiary.Data["file_number"]) f.SetCellValue("Sheet1", fmt.Sprintf("F%d", i), beneficiary.Data["file_number"])
f.SetCellValue("Sheet1", fmt.Sprintf("G%d", i), groups[subscribedbygroup].Data["name"]) f.SetCellValue("Sheet1", fmt.Sprintf("G%d", i), subscribedbygroup)
f.SetCellValue("Sheet1", fmt.Sprintf("H%d", i), subscribedbyuser) f.SetCellValue("Sheet1", fmt.Sprintf("H%d", i), subscribedbyuser)
f.SetCellValue("Sheet1", fmt.Sprintf("I%d", i), admin.Data["name"]) f.SetCellValue("Sheet1", fmt.Sprintf("I%d", i), subscribedbyemail)
f.SetCellValue("Sheet1", fmt.Sprintf("J%d", i), admin.Data["name"])
i = i + 1 i = i + 1
} }
} }
return f
}
func (h *ExportsHandler) writeFileResponse(file *excelize.File, w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", "attachment; filename="+"Workbook.xlsx") w.Header().Set("Content-Disposition", "attachment; filename="+"Workbook.xlsx")
w.Header().Set("Content-Transfer-Encoding", "binary") w.Header().Set("Content-Transfer-Encoding", "binary")
w.Header().Set("Expires", "0") w.Header().Set("Expires", "0")
f.Write(w) file.Write(w)
} }

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi" fleets "git.coopgo.io/coopgo-platform/fleets/grpcapi"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage" fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi" groupsmanagement "git.coopgo.io/coopgo-platform/groups-management/grpcapi"
@ -18,7 +19,6 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
vehicles := map[string]fleetsstorage.Vehicle{} vehicles := map[string]fleetsstorage.Vehicle{}
bookings := []fleetsstorage.Booking{} bookings := []fleetsstorage.Booking{}
reequest := &fleets.GetVehiclesRequest{ reequest := &fleets.GetVehiclesRequest{
Namespaces: []string{"parcoursmob"}, Namespaces: []string{"parcoursmob"},
} }
@ -93,8 +93,10 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", "H1", "Fin de mise Ă  disposition") f.SetCellValue("Sheet1", "H1", "Fin de mise Ă  disposition")
f.SetCellValue("Sheet1", "I1", "Début indisponibilité") f.SetCellValue("Sheet1", "I1", "Début indisponibilité")
f.SetCellValue("Sheet1", "J1", "Fin indisponibilité") f.SetCellValue("Sheet1", "J1", "Fin indisponibilité")
f.SetCellValue("Sheet1", "K1", "Retrait par le gestionnaire") f.SetCellValue("Sheet1", "K1", "Véhicule retiré")
f.SetCellValue("Sheet1", "L1", "Commentaire") f.SetCellValue("Sheet1", "L1", "Commentaire - Retrait véhicule")
f.SetCellValue("Sheet1", "M1", "Réservation supprimée")
f.SetCellValue("Sheet1", "N1", "Motif de la suppression")
i := 2 i := 2
for _, b := range bookings { for _, b := range bookings {
@ -106,14 +108,31 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
bookedby := "" bookedby := ""
if v, ok := b.Data["booked_by"].(map[string]any); ok { if v, ok := b.Data["booked_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok { if v2, ok := v["user"].(map[string]any); ok {
if v3, ok := v2["name"].(string); ok { if v3, ok := v2["display_name"].(string); ok {
bookedby = v3 bookedby = v3
} }
} }
} }
bookedbygroup := ""
if v4, ok := b.Data["booked_by"].(map[string]any); ok {
if v5, ok := v4["group"].(map[string]any); ok {
if v6, ok := v5["id"].(string); ok {
bookedbygroup = v6
}
}
}
// filter by group
g := r.Context().Value(identification.GroupKey)
group := g.(groupsstorage.Group)
if bookedbygroup != group.ID {
continue
}
beneficiary := beneficiaries_map[b.Driver] beneficiary := beneficiaries_map[b.Driver]
adminunavailability := false adminunavailability := false
@ -121,6 +140,14 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
adminunavailability = true adminunavailability = true
} }
deleted := ""
v, ok := b.Data["Deleted"]
fmt.Println(v)
fmt.Println(ok)
if b.Deleted || (ok && v.(bool)) {
deleted = "DELETED"
}
f.SetCellValue("Sheet1", fmt.Sprintf("A%d", i), vehicle.Data["licence_plate"]) f.SetCellValue("Sheet1", fmt.Sprintf("A%d", i), vehicle.Data["licence_plate"])
f.SetCellValue("Sheet1", fmt.Sprintf("B%d", i), vehicle.Type) f.SetCellValue("Sheet1", fmt.Sprintf("B%d", i), vehicle.Type)
f.SetCellValue("Sheet1", fmt.Sprintf("C%d", i), admin.Data["name"]) f.SetCellValue("Sheet1", fmt.Sprintf("C%d", i), admin.Data["name"])
@ -133,6 +160,8 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", fmt.Sprintf("J%d", i), b.Unavailableto.Format("2006-01-02")) f.SetCellValue("Sheet1", fmt.Sprintf("J%d", i), b.Unavailableto.Format("2006-01-02"))
f.SetCellValue("Sheet1", fmt.Sprintf("K%d", i), adminunavailability) f.SetCellValue("Sheet1", fmt.Sprintf("K%d", i), adminunavailability)
f.SetCellValue("Sheet1", fmt.Sprintf("L%d", i), b.Data["comment"]) f.SetCellValue("Sheet1", fmt.Sprintf("L%d", i), b.Data["comment"])
f.SetCellValue("Sheet1", fmt.Sprintf("M%d", i), deleted)
f.SetCellValue("Sheet1", fmt.Sprintf("N%d", i), b.Data["motif"])
i = i + 1 i = i + 1
} }

View File

@ -108,6 +108,10 @@ func main() {
application.HandleFunc("/vehicles-management/bookings/", applicationHandler.VehiclesManagementBookingsList) application.HandleFunc("/vehicles-management/bookings/", applicationHandler.VehiclesManagementBookingsList)
application.HandleFunc("/vehicles-management/bookings/{bookingid}", applicationHandler.VehicleManagementBookingDisplay) application.HandleFunc("/vehicles-management/bookings/{bookingid}", applicationHandler.VehicleManagementBookingDisplay)
application.HandleFunc("/vehicles-management/bookings/{bookingid}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle) application.HandleFunc("/vehicles-management/bookings/{bookingid}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle)
/////////////////////////////////////Remove booking vehicle/////////////////////////////////////////
application.HandleFunc("/vehicles-management/bookings/{bookingid}/delete", applicationHandler.UnbookingVehicle)
// application.HandleFunc("/vehicles-management/bookings/{bookingid}/delete", applicationHandler.DeleteBooking)
////////////////////////////////////////////////////////////////////////////////////////////////////
application.HandleFunc("/vehicles-management/bookings/{bookingid}/documents/{document}", applicationHandler.BookingDocumentDownload) application.HandleFunc("/vehicles-management/bookings/{bookingid}/documents/{document}", applicationHandler.BookingDocumentDownload)
application.HandleFunc("/agenda/", applicationHandler.AgendaHome) application.HandleFunc("/agenda/", applicationHandler.AgendaHome)
application.HandleFunc("/agenda/history", applicationHandler.AgendaHistory) application.HandleFunc("/agenda/history", applicationHandler.AgendaHistory)
@ -163,7 +167,9 @@ func main() {
export := r.PathPrefix("/exports").Subrouter() export := r.PathPrefix("/exports").Subrouter()
export.HandleFunc("/fleets/bookings", exportsHandler.Bookings) export.HandleFunc("/fleets/bookings", exportsHandler.Bookings)
export.HandleFunc("/agenda/subscriptions", exportsHandler.Agenda) export.HandleFunc("/fleets/bookings/{groupid}", exportsHandler.Bookings)
export.HandleFunc("/agenda/subscriptions", exportsHandler.Agenda("allEvents"))
export.HandleFunc("/agenda/{eventid}", exportsHandler.Agenda("oneEvent"))
export.Use(idp.Middleware) export.Use(idp.Middleware)
export.Use(idp.GroupsMiddleware) export.Use(idp.GroupsMiddleware)

View File

@ -53,11 +53,12 @@ func (renderer *Renderer) VehiclesFleetDisplay(w http.ResponseWriter, r *http.Re
renderer.Render("fleet display vehicle", w, r, files, state) renderer.Render("fleet display vehicle", w, r, files, state)
} }
func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any) { func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any, vehicle_types []string) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_update.files") files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_update.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu) state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{ state.ViewState = map[string]any{
"vehicle": vehicle, "vehicle": vehicle,
"vehicle_types": vehicle_types,
} }
renderer.Render("fleet display vehicle", w, r, files, state) renderer.Render("fleet display vehicle", w, r, files, state)
@ -78,3 +79,14 @@ func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter,
renderer.Render("vehicles search", w, r, files, state) renderer.Render("vehicles search", w, r, files, state)
} }
func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Request, booking any) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"booking": booking,
}
renderer.Render("vehicule unbooking", w, r, files, state)
}