3 Commits

Author SHA1 Message Date
c8f8f82535 resolve commit and fix 2023-11-27 08:45:48 +01:00
0f5a0ed5ab improve 2023-11-27 07:26:21 +01:00
275c8b1999 comments replace in go.mod 2023-08-07 10:52:29 +02:00
6 changed files with 73 additions and 30 deletions

2
go.mod
View File

@@ -6,7 +6,7 @@ replace git.coopgo.io/coopgo-platform/mobility-accounts => ../../coopgo-platform
// replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/ // replace git.coopgo.io/coopgo-platform/groups-management => ../../coopgo-platform/groups-management/
replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/ // replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
// replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/ // replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/

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

@@ -467,6 +467,25 @@ 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) { func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
bookingid := vars["bookingid"] bookingid := vars["bookingid"]
@@ -481,9 +500,12 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
now := time.Now() // now := time.Now()
date := now.Format("2006-01-02") // date := now.Format("2006-01-02")
date := "1970-01-01"
unavailableto, _ := time.Parse("2006-01-02", date) unavailableto, _ := time.Parse("2006-01-02", date)
unavailablefrom := unavailableto
current_group, err := h.currentGroup(r) current_group, err := h.currentGroup(r)
if err != nil { if err != nil {
@@ -548,7 +570,7 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
Driver: resp.Booking.Driver, Driver: resp.Booking.Driver,
Startdate: resp.Booking.Startdate, Startdate: resp.Booking.Startdate,
Enddate: resp.Booking.Enddate, Enddate: resp.Booking.Enddate,
Unavailablefrom: resp.Booking.Unavailablefrom, Unavailablefrom: timestamppb.New(unavailablefrom),
Unavailableto: timestamppb.New(unavailableto), Unavailableto: timestamppb.New(unavailableto),
Data: datapb, Data: datapb,
}, },

View File

@@ -3,6 +3,9 @@ package exports
import ( import (
"context" "context"
"fmt" "fmt"
"net/http"
"sort"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting" "git.coopgo.io/coopgo-apps/parcoursmob/utils/sorting"
agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi" agenda "git.coopgo.io/coopgo-platform/agenda/grpcapi"
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage" agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
@@ -12,8 +15,6 @@ import (
accountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage" accountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/xuri/excelize/v2" "github.com/xuri/excelize/v2"
"net/http"
"sort"
) )
func (h *ExportsHandler) Agenda(filter string) func(w http.ResponseWriter, r *http.Request) { func (h *ExportsHandler) Agenda(filter string) func(w http.ResponseWriter, r *http.Request) {
@@ -141,7 +142,10 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
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")
i := 2 i := 2
for _, e := range events { for _, e := range events {
if len(e.Owners) == 0 { if len(e.Owners) == 0 {
@@ -149,24 +153,27 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
} }
admin := groups[e.Owners[0]] admin := groups[e.Owners[0]]
subscribedbygroup := ""
subscribedbyuser := ""
if v, ok := e.Data["subscribed_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok {
if v3, ok := v2["id"].(string); ok {
subscribedbygroup = v3
}
}
if v4, ok := v["user"].(map[string]any); ok {
if v5, ok := v4["display_name"].(string); ok {
subscribedbyuser = v5
}
}
}
for _, s := range e.Subscriptions { for _, s := range e.Subscriptions {
subscribedbygroup := ""
subscribedbyuser := ""
subscribedbyemail := ""
if v, ok := s.Data["subscribed_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok {
if v3, ok := v2["name"].(string); ok {
subscribedbygroup = v3
}
}
if v4, ok := v["user"].(map[string]any); ok {
if v5, ok := v4["display_name"].(string); ok {
subscribedbyuser = v5
}
if v6, ok := v4["email"].(string); ok {
subscribedbyemail = v6
}
}
}
beneficiary := beneficiaries_map[s.Subscriber] beneficiary := beneficiaries_map[s.Subscriber]
@@ -176,9 +183,10 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
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
} }

View File

@@ -45,7 +45,6 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
} }
groups := map[string]groupsstorage.Group{} groups := map[string]groupsstorage.Group{}
admingroups, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), &groupsmanagement.GetGroupsRequest{ admingroups, err := h.services.GRPC.GroupsManagement.GetGroups(context.TODO(), &groupsmanagement.GetGroupsRequest{
@@ -94,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 {
@@ -127,7 +128,7 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
// filter by group // filter by group
g := r.Context().Value(identification.GroupKey) g := r.Context().Value(identification.GroupKey)
group := g.(groupsstorage.Group) group := g.(groupsstorage.Group)
if bookedbygroup != group.ID { if bookedbygroup != group.ID {
continue continue
} }
@@ -139,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"])
@@ -151,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

@@ -110,6 +110,7 @@ func main() {
application.HandleFunc("/vehicles-management/bookings/{bookingid}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle) application.HandleFunc("/vehicles-management/bookings/{bookingid}/change-vehicle", applicationHandler.VehicleManagementBookingChangeVehicle)
/////////////////////////////////////Remove booking vehicle///////////////////////////////////////// /////////////////////////////////////Remove booking vehicle/////////////////////////////////////////
application.HandleFunc("/vehicles-management/bookings/{bookingid}/delete", applicationHandler.UnbookingVehicle) 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)