|
|
|
@ -49,7 +49,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo});
|
|
|
|
AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo});
|
|
|
|
|
|
|
|
|
|
|
|
bool isUpcommingEnabled = true;
|
|
|
|
bool isUpcomingEnabled = true;
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
bool isFetchingLists = false;
|
|
|
|
int selectedBranch = 0;
|
|
|
|
int selectedBranch = 0;
|
|
|
|
int selectedAppointmentIndex = 0;
|
|
|
|
int selectedAppointmentIndex = 0;
|
|
|
|
@ -229,10 +229,9 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
void removeServiceInCurrentAppointment(int index) {
|
|
|
|
int serviceId = servicesInCurrentAppointment
|
|
|
|
int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1;
|
|
|
|
.elementAt(index)
|
|
|
|
|
|
|
|
.serviceProviderServiceId ?? -1;
|
|
|
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId);
|
|
|
|
|
|
|
|
servicesInCurrentAppointment[index].serviceItems!.clear();
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
servicesInCurrentAppointment.removeAt(index);
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -256,7 +255,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Future<void> populateAppointmentsFilterList() async {
|
|
|
|
Future<void> populateAppointmentsFilterList() async {
|
|
|
|
if (appointmentsFilterOptions.isNotEmpty) return;
|
|
|
|
if (appointmentsFilterOptions.isNotEmpty) return;
|
|
|
|
|
|
|
|
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: 13); // 13 is to get Appointments Filter Enums
|
|
|
|
myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.appointmentsFilterEnumId); // 13 is to get Appointments Filter Enums
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < myAppointmentsEnum.length; i++) {
|
|
|
|
for (int i = 0; i < myAppointmentsEnum.length; i++) {
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue));
|
|
|
|
appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue));
|
|
|
|
@ -352,8 +351,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters();
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
// myFilteredAppointments = myAppointments;
|
|
|
|
myUpComingAppointments =
|
|
|
|
myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
|
|
|
|
myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList();
|
|
|
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments);
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
@ -414,6 +412,11 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isShowMergeButton() {
|
|
|
|
|
|
|
|
return myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed) &&
|
|
|
|
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.length > 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<GenericRespModel> createMergeAppointment(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
Future<GenericRespModel> createMergeAppointment(Map<String, dynamic> map, {bool isNeedToRebuild = false}) async {
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
if (isNeedToRebuild) setState(ViewState.busy);
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.createMergeAppointment(map);
|
|
|
|
GenericRespModel genericRespModel = await appointmentRepo.createMergeAppointment(map);
|
|
|
|
@ -423,23 +426,20 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
|
|
|
|
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
bool inNeedToEnableMergeButton = false;
|
|
|
|
|
|
|
|
|
|
|
|
updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
void updateCheckBoxInMergeRequest(int currentIndex) {
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected =
|
|
|
|
myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
!(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
|
|
|
|
int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []);
|
|
|
|
if (count > 1)
|
|
|
|
if (count > 1) {
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
inNeedToEnableMergeButton = true;
|
|
|
|
else
|
|
|
|
} else {
|
|
|
|
inNeedToEnableMergeButton = false;
|
|
|
|
inNeedToEnableMergeButton = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int countSelected(List<AppointmentListModel> appointments) {
|
|
|
|
int countSelected(List<AppointmentListModel> appointments) {
|
|
|
|
return appointments
|
|
|
|
return appointments.where((appointment) => appointment.isSelected == true).toList().length;
|
|
|
|
.where((appointment) => appointment.isSelected == true)
|
|
|
|
|
|
|
|
.toList()
|
|
|
|
|
|
|
|
.length;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) {
|
|
|
|
@ -481,10 +481,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
int selectedSubServicesCounter = 0;
|
|
|
|
int selectedSubServicesCounter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
void onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
void onItemUpdateOrSelected(int index, bool selected, int itemId) {
|
|
|
|
int serviceIndex = 0;
|
|
|
|
int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
if (servicesInCurrentAppointment.isNotEmpty) {
|
|
|
|
|
|
|
|
serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log("index: $index");
|
|
|
|
log("index: $index");
|
|
|
|
log("selected: $selected");
|
|
|
|
log("selected: $selected");
|
|
|
|
@ -500,9 +497,10 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
|
|
|
|
allSelectedItemsInAppointments.add(serviceItemsFromApi[index]);
|
|
|
|
for (var element in allSelectedItemsInAppointments) {
|
|
|
|
for (var element in allSelectedItemsInAppointments) {
|
|
|
|
if (!ifItemAlreadySelected(element.id!)) {
|
|
|
|
if (!ifItemAlreadySelected(element.id!)) {
|
|
|
|
|
|
|
|
if (serviceIndex != -1) {
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]);
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -512,10 +510,12 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}");
|
|
|
|
log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}");
|
|
|
|
|
|
|
|
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
|
|
|
|
allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId);
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice =
|
|
|
|
if (serviceIndex != -1) {
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0");
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -613,8 +613,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
children: List.generate(
|
|
|
|
children: List.generate(
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
selectedService.serviceItems!.length,
|
|
|
|
(index) =>
|
|
|
|
(index) => Row(
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
"${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
|
|
@ -655,8 +654,7 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
(selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService
|
|
|
|
(selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService.currentTotalServicePrice}")
|
|
|
|
.currentTotalServicePrice}")
|
|
|
|
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
.toText(fontSize: 29, isBold: true),
|
|
|
|
2.width,
|
|
|
|
2.width,
|
|
|
|
LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
|
|
|
LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
|
|
|
@ -1498,11 +1496,4 @@ class AppointmentsVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(ViewState.idle);
|
|
|
|
setState(ViewState.idle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool isShowMergeButton() {
|
|
|
|
|
|
|
|
return myFilteredAppointments2[selectedAppointmentIndex]
|
|
|
|
|
|
|
|
.customerAppointmentList!
|
|
|
|
|
|
|
|
.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|