delete reservation and history benef
This commit is contained in:
@@ -255,7 +255,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http
|
||||
}
|
||||
vars := mux.Vars(r)
|
||||
eventid := vars["eventid"]
|
||||
|
||||
fmt.Println(eventid)
|
||||
if err := r.ParseForm(); err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
||||
@@ -205,6 +205,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||
|
||||
subcriptionresp, err := h.services.GRPC.Agenda.GetSubscriptionByUser(context.TODO(), subscriptionrequest)
|
||||
if err != nil {
|
||||
fmt.Println("icii")
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -212,13 +213,15 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||
|
||||
events := []agendastorage.Event{}
|
||||
currentTime := time.Now().Truncate(24 * time.Hour)
|
||||
|
||||
fmt.Println(subcriptionresp)
|
||||
for _, e := range subcriptionresp.Subscription {
|
||||
eventresquest := &agenda.GetEventRequest{
|
||||
Id: e.Eventid,
|
||||
}
|
||||
fmt.Println(eventresquest)
|
||||
eventresp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), eventresquest)
|
||||
if err != nil {
|
||||
fmt.Println("iciiiiii")
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
@@ -269,6 +272,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
|
||||
events_list = append(events_list, event)
|
||||
|
||||
}
|
||||
|
||||
var status_booking int
|
||||
@@ -306,6 +310,7 @@ func (h *ApplicationHandler) BeneficiaryDisplay(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
|
||||
events_list = append(events_list, event)
|
||||
|
||||
}
|
||||
}
|
||||
sortByDate(events_list)
|
||||
|
||||
@@ -302,12 +302,15 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
||||
}
|
||||
|
||||
alternativerequest := &fleets.GetVehiclesRequest{
|
||||
Namespaces: []string{"parcoursmob"},
|
||||
Types: []string{booking.Vehicle.Type},
|
||||
Administrators: booking.Vehicle.Administrators,
|
||||
AvailabilityFrom: timestamppb.New(booking.Startdate),
|
||||
AvailabilityTo: timestamppb.New(booking.Enddate.Add(24 * time.Hour)),
|
||||
Namespaces: []string{"parcoursmob"},
|
||||
Types: []string{booking.Vehicle.Type},
|
||||
Administrators: booking.Vehicle.Administrators,
|
||||
//AvailabilityFrom: timestamppb.New(booking.Startdate),
|
||||
//AvailabilityTo: timestamppb.New(booking.Startdate.Add(After(time.Now()))),
|
||||
}
|
||||
// if alternativerequest.AvailabilityFrom.After(time.Now()) {
|
||||
// fmt.Println("loooool")
|
||||
// }
|
||||
|
||||
alternativeresp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), alternativerequest)
|
||||
if err != nil {
|
||||
@@ -319,11 +322,48 @@ func (h ApplicationHandler) VehicleManagementBookingDisplay(w http.ResponseWrite
|
||||
for _, a := range alternativeresp.Vehicles {
|
||||
alternatives = append(alternatives, a.ToStorageType())
|
||||
}
|
||||
/***************************************add list of vehicules ******************************************/
|
||||
requesst := &fleets.GetVehiclesRequest{
|
||||
Namespaces: []string{"parcoursmob"},
|
||||
}
|
||||
ressp, err := h.services.GRPC.Fleets.GetVehicles(context.TODO(), requesst)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
vehicles := []fleetsstorage.Vehicle{}
|
||||
bookings := []fleetsstorage.Booking{}
|
||||
vehicles_map := map[string]fleetsstorage.Vehicle{}
|
||||
|
||||
for _, vehicle := range ressp.Vehicles {
|
||||
if filterVehicle(r, vehicle) {
|
||||
v := vehicle.ToStorageType()
|
||||
vehicleBookings := []fleetsstorage.Booking{}
|
||||
for _, b := range v.Bookings {
|
||||
if b.Status() != fleetsstorage.StatusOld {
|
||||
if deleted, ok := b.Data["Deleted"].(bool); !ok && !deleted {
|
||||
bookings = append(bookings, b)
|
||||
}
|
||||
}
|
||||
if b.Unavailableto.After(time.Now()) {
|
||||
vehicleBookings = append(vehicleBookings, b)
|
||||
}
|
||||
}
|
||||
v.Bookings = vehicleBookings
|
||||
vehicles = append(vehicles, v)
|
||||
vehicles_map[v.ID] = v
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//sort.Sort(sorting.VehiclesByLicencePlate(vehicles))
|
||||
//sort.Sort(sorting.BookingsByStartdate(bookings))
|
||||
/*********************************************************************************/
|
||||
documents := h.filestorage.List(filestorage.PREFIX_BOOKINGS + "/" + bookingid)
|
||||
file_types_map := h.config.GetStringMapString("storage.files.file_types")
|
||||
|
||||
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives)
|
||||
h.Renderer.VehicleManagementBookingDisplay(w, r, booking, booking.Vehicle, beneficiary, groupresp.Group.ToStorageType(), documents, file_types_map, alternatives, vehicles, vehicles_map, bookings)
|
||||
}
|
||||
|
||||
func (h ApplicationHandler) VehicleManagementBookingChangeVehicle(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -553,8 +593,17 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
|
||||
Data: datapb,
|
||||
},
|
||||
}
|
||||
requestt := &fleets.DeleteBookingRequest{
|
||||
Id: bookingid,
|
||||
}
|
||||
_, errr := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
||||
|
||||
_, err := h.services.GRPC.Fleets.UpdateBooking(context.TODO(), request)
|
||||
if errr != nil {
|
||||
fmt.Println(errr)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
_, err := h.services.GRPC.Fleets.DeleteBooking(context.TODO(), requestt)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user