MMS43 changes

This commit is contained in:
Arnaud Delcasse
2025-12-29 10:50:58 +01:00
parent 52de8d363e
commit 6cda7509c1
6 changed files with 126 additions and 79 deletions

View File

@@ -9,10 +9,10 @@ import (
"strings"
"time"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/identification"
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
gen "git.coopgo.io/coopgo-platform/solidarity-transport/servers/grpc/proto/gen"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/identification"
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
)
@@ -25,7 +25,7 @@ func (h *Handler) SolidarityTransportOverviewHTTPHandler() http.HandlerFunc {
// Extract filter parameters using the same field names as the old handler
tab := r.FormValue("tab")
if tab == "" {
tab = "solidarityService" // Default to showing current bookings
tab = "solidarityService" // Default to showing current bookings
}
// Extract archived filter
@@ -55,7 +55,7 @@ func (h *Handler) SolidarityTransportOverviewHTTPHandler() http.HandlerFunc {
// History filters (apply when on solidarityHistory tab)
if tab == "solidarityHistory" {
histStatus = r.FormValue("status") // Note: history uses same field names as current
histStatus = r.FormValue("status") // Note: history uses same field names as current
histDriverID = r.FormValue("driver_id")
histStartDate = r.FormValue("date_start")
histEndDate = r.FormValue("date_end")
@@ -135,25 +135,25 @@ func (h *Handler) SolidarityTransportOverviewHTTPHandler() http.HandlerFunc {
// Build filters map for template (matching old handler format)
filters := map[string]any{
"tab": tab,
"date_start": startDate,
"date_end": endDate,
"status": status,
"driver_id": driverID,
"departure_geo": departureGeo,
"destination_geo": destinationGeo,
"tab": tab,
"date_start": startDate,
"date_end": endDate,
"status": status,
"driver_id": driverID,
"departure_geo": departureGeo,
"destination_geo": destinationGeo,
"passenger_address_geo": passengerAddressGeo,
"driver_address_geo": driverAddressGeo,
"driver_address_geo": driverAddressGeo,
}
histFilters := map[string]any{
"tab": tab,
"date_start": histStartDate,
"date_end": histEndDate,
"status": histStatus,
"driver_id": histDriverID,
"departure_geo": histDepartureGeo,
"destination_geo": histDestinationGeo,
"tab": tab,
"date_start": histStartDate,
"date_end": histEndDate,
"status": histStatus,
"driver_id": histDriverID,
"departure_geo": histDepartureGeo,
"destination_geo": histDestinationGeo,
"passenger_address_geo": histPassengerAddressGeo,
}
@@ -521,7 +521,11 @@ func (h *Handler) SolidarityTransportDriverJourneyHTTPHandler() http.HandlerFunc
vars := mux.Vars(r)
driverID := vars["driverid"]
journeyID := vars["journeyid"]
// Preserve passengerid from either query parameter or form data
passengerID := r.URL.Query().Get("passengerid")
if passengerID == "" {
passengerID = r.FormValue("passengerid")
}
replacesBookingID := r.URL.Query().Get("replaces_booking_id")
if r.Method == "POST" {
@@ -580,7 +584,16 @@ func (h *Handler) SolidarityTransportDriverJourneyToggleNoreturnHTTPHandler() ht
return
}
http.Redirect(w, r, fmt.Sprintf("/app/solidarity-transport/drivers/%s/journeys/%s", driverID, journeyID), http.StatusFound)
// Preserve passengerid query parameter if present
passengerID := r.URL.Query().Get("passengerid")
if passengerID == "" {
passengerID = r.FormValue("passengerid")
}
redirectURL := fmt.Sprintf("/app/solidarity-transport/drivers/%s/journeys/%s", driverID, journeyID)
if passengerID != "" {
redirectURL += "?passengerid=" + passengerID
}
http.Redirect(w, r, redirectURL, http.StatusFound)
}
}
@@ -641,11 +654,11 @@ func (h *Handler) SolidarityTransportBookingDisplayHTTPHandler() http.HandlerFun
if err == nil {
pricing := map[string]interface{}{
"passenger": map[string]interface{}{
"amount": pricingResult["passenger"].Amount,
"amount": pricingResult["passenger"].Amount,
"currency": pricingResult["passenger"].Currency,
},
"driver": map[string]interface{}{
"amount": pricingResult["driver"].Amount,
"amount": pricingResult["driver"].Amount,
"currency": pricingResult["driver"].Currency,
},
}
@@ -716,7 +729,7 @@ func (h *Handler) SolidarityTransportCreateReplacementBookingHTTPHandler() http.
journeyID,
passengerID,
motivation,
message, // message from form
message, // message from form
doNotSend, // doNotSend from form checkbox
returnWaitingTimeMinutes,
oldBookingID,
@@ -771,4 +784,5 @@ func (h *Handler) SolidarityTransportBookingStatusHTTPHandler(action string) htt
http.Redirect(w, r, fmt.Sprintf("/app/solidarity-transport/bookings/%s", bookingID), http.StatusSeeOther)
}
}
}

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"net/http"
"time"
"git.coopgo.io/coopgo-apps/parcoursmob/core/utils/identification"
"git.coopgo.io/coopgo-platform/groups-management/storage"
@@ -18,11 +19,31 @@ func (h *Handler) VehiclesSearchHTTPHandler() http.HandlerFunc {
// Extract parameters
beneficiaryID := r.FormValue("beneficiaryid")
startDate := r.FormValue("startdate")
endDate := r.FormValue("enddate")
startDateStr := r.FormValue("startdate")
endDateStr := r.FormValue("enddate")
startTimeStr := r.FormValue("starttime")
endTimeStr := r.FormValue("endtime")
vehicleType := r.FormValue("type")
automatic := r.FormValue("automatic") == "on"
// Default times if not provided
if startTimeStr == "" {
startTimeStr = "00:00"
}
if endTimeStr == "" {
endTimeStr = "23:59"
}
// Parse dates and times in Europe/Paris timezone
paris, _ := time.LoadLocation("Europe/Paris")
var startDate, endDate time.Time
if startDateStr != "" {
startDate, _ = time.ParseInLocation("2006-01-02 15:04", startDateStr+" "+startTimeStr, paris)
}
if endDateStr != "" {
endDate, _ = time.ParseInLocation("2006-01-02 15:04", endDateStr+" "+endTimeStr, paris)
}
// Call business logic
result, err := h.applicationHandler.SearchVehicles(r.Context(), beneficiaryID, startDate, endDate, vehicleType, automatic)
if err != nil {
@@ -58,8 +79,23 @@ func (h *Handler) BookVehicleHTTPHandler() http.HandlerFunc {
}
// Extract form data
startDate := r.FormValue("startdate")
endDate := r.FormValue("enddate")
startDateStr := r.FormValue("startdate")
endDateStr := r.FormValue("enddate")
startTimeStr := r.FormValue("starttime")
endTimeStr := r.FormValue("endtime")
// Default times if not provided
if startTimeStr == "" {
startTimeStr = "00:00"
}
if endTimeStr == "" {
endTimeStr = "23:59"
}
// Parse dates and times in Europe/Paris timezone
paris, _ := time.LoadLocation("Europe/Paris")
startDate, _ := time.ParseInLocation("2006-01-02 15:04", startDateStr+" "+startTimeStr, paris)
endDate, _ := time.ParseInLocation("2006-01-02 15:04", endDateStr+" "+endTimeStr, paris)
// Extract documents
documents := make(map[string]io.Reader)

View File

@@ -178,9 +178,34 @@ func (h *Handler) VehicleManagementBookingDisplayHTTPHandler() http.HandlerFunc
// Parse form data
r.ParseForm()
// Extract date and time values
startDateStr := r.FormValue("startdate")
startTimeStr := r.FormValue("starttime")
endDateStr := r.FormValue("enddate")
endTimeStr := r.FormValue("endtime")
// Parse dates with times in Europe/Paris timezone
paris, _ := time.LoadLocation("Europe/Paris")
var startDate, endDate *time.Time
if startDateStr != "" {
if startTimeStr == "" {
startTimeStr = "00:00"
}
t, _ := time.ParseInLocation("2006-01-02 15:04", startDateStr+" "+startTimeStr, paris)
startDate = &t
}
if endDateStr != "" {
if endTimeStr == "" {
endTimeStr = "23:59"
}
t, _ := time.ParseInLocation("2006-01-02 15:04", endDateStr+" "+endTimeStr, paris)
endDate = &t
}
err := h.applicationHandler.UpdateBooking(r.Context(), bookingID,
r.FormValue("startdate"),
r.FormValue("enddate"),
startDate,
endDate,
r.FormValue("unavailablefrom"),
r.FormValue("unavailableto"),
)