|
|
|
|
@ -64,6 +64,7 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
List<ImageModel> commercialCertificates = [];
|
|
|
|
|
List<ImageModel> vatCertificates = [];
|
|
|
|
|
List<BranchDetailModel> homePageBranches = [];
|
|
|
|
|
List<CategoryData> categories = [];
|
|
|
|
|
|
|
|
|
|
void updateSelectionOpenTime(String date) {
|
|
|
|
|
openTime = date;
|
|
|
|
|
@ -118,68 +119,111 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Future<String?> selectFile(BuildContext context, int index) async {
|
|
|
|
|
// final status = await AppPermissions.checkStoragePermissions(context);
|
|
|
|
|
// if (status) {
|
|
|
|
|
// final File? file = await commonServices.pickFile(
|
|
|
|
|
// context,
|
|
|
|
|
// fileType: FileType.custom,
|
|
|
|
|
// allowedExtensions: ['png', 'pdf', 'jpeg'],
|
|
|
|
|
// );
|
|
|
|
|
// if (file != null) {
|
|
|
|
|
// int sizeInBytes = file.lengthSync();
|
|
|
|
|
// // double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
|
|
|
// if (sizeInBytes > 1000000) {
|
|
|
|
|
// Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
|
|
|
// } else {
|
|
|
|
|
// document!.data![index].document = Utils.convertFileToBase64(file);
|
|
|
|
|
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
|
|
|
|
|
// document!.data![index].documentUrl = file.path;
|
|
|
|
|
// setState(ViewState.idle);
|
|
|
|
|
// // return document!.data![index].document;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // User canceled the picker
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Future<String?> selectFile(BuildContext context, int index) async {
|
|
|
|
|
// File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']);
|
|
|
|
|
//
|
|
|
|
|
// if (file != null) {
|
|
|
|
|
// int sizeInBytes = file.lengthSync();
|
|
|
|
|
// // double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
|
|
|
// if (sizeInBytes > 1000000) {
|
|
|
|
|
// Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
|
|
|
// } else {
|
|
|
|
|
// document!.data![index].document = Utils.convertFileToBase64(file);
|
|
|
|
|
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
|
|
|
|
|
// document!.data![index].documentUrl = file.path;
|
|
|
|
|
// document!.data![index].isFileAttached = true;
|
|
|
|
|
// return Utils.convertFileToBase64(file);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // User canceled the picker
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
filterUserBranchCategories() {
|
|
|
|
|
categories = [];
|
|
|
|
|
print("Filter Branch Executed");
|
|
|
|
|
List<BranchDetailModel>? localbranches;
|
|
|
|
|
if (branches!.data != null) {
|
|
|
|
|
if (selectedBranchStatus == 3) {
|
|
|
|
|
localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId == 3).toList();
|
|
|
|
|
} else {
|
|
|
|
|
localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId != 3).toList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var branch in localbranches!) {
|
|
|
|
|
for (var element in branch.branchServices!) {
|
|
|
|
|
categories.add(
|
|
|
|
|
CategoryData(
|
|
|
|
|
id: element.categoryId,
|
|
|
|
|
categoryName: element.categoryName,
|
|
|
|
|
categoryNameN: element.categoryName,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
categories = categories.toSet().toList();
|
|
|
|
|
for (var payment in categories) {
|
|
|
|
|
for (var element in branch.branchServices!) {
|
|
|
|
|
if (payment.id == element.categoryId) {
|
|
|
|
|
payment.services ??= [];
|
|
|
|
|
payment.services!.add(element);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
categories = categories;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Future<String?> selectFile(BuildContext context, int index) async {
|
|
|
|
|
// final status = await AppPermissions.checkStoragePermissions(context);
|
|
|
|
|
// if (status) {
|
|
|
|
|
// final File? file = await commonServices.pickFile(
|
|
|
|
|
// context,
|
|
|
|
|
// fileType: FileType.custom,
|
|
|
|
|
// allowedExtensions: ['png', 'pdf', 'jpeg'],
|
|
|
|
|
// );
|
|
|
|
|
// if (file != null) {
|
|
|
|
|
// int sizeInBytes = file.lengthSync();
|
|
|
|
|
// // double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
|
|
|
// if (sizeInBytes > 1000000) {
|
|
|
|
|
// Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
|
|
|
// } else {
|
|
|
|
|
// document!.data![index].document = Utils.convertFileToBase64(file);
|
|
|
|
|
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
|
|
|
|
|
// document!.data![index].documentUrl = file.path;
|
|
|
|
|
// setState(ViewState.idle);
|
|
|
|
|
// // return document!.data![index].document;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // User canceled the picker
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Future<String?> selectFile(BuildContext context, int index) async {
|
|
|
|
|
// File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']);
|
|
|
|
|
//
|
|
|
|
|
// if (file != null) {
|
|
|
|
|
// int sizeInBytes = file.lengthSync();
|
|
|
|
|
// // double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
|
|
|
// if (sizeInBytes > 1000000) {
|
|
|
|
|
// Utils.showToast(LocaleKeys.fileLarger.tr());
|
|
|
|
|
// } else {
|
|
|
|
|
// document!.data![index].document = Utils.convertFileToBase64(file);
|
|
|
|
|
// document!.data![index].fileExt = Utils.checkFileExt(file.path);
|
|
|
|
|
// document!.data![index].documentUrl = file.path;
|
|
|
|
|
// document!.data![index].isFileAttached = true;
|
|
|
|
|
// return Utils.convertFileToBase64(file);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // User canceled the picker
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Future<void> pickPdfReceiptFile(BuildContext context, int documentID, int index) async {
|
|
|
|
|
List<ImageModel> imageModels = [];
|
|
|
|
|
List<File>? files = await commonServices.pickMultipleFiles(context, allowMultiple: false);
|
|
|
|
|
List<File>? files = await commonServices.pickMultipleFiles(
|
|
|
|
|
context,
|
|
|
|
|
allowMultiple: false,
|
|
|
|
|
);
|
|
|
|
|
if (files == null) return null;
|
|
|
|
|
for (var element in files) {
|
|
|
|
|
imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false));
|
|
|
|
|
imageModels.add(ImageModel(
|
|
|
|
|
filePath: element.path,
|
|
|
|
|
isFromNetwork: false,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
documentID == 1
|
|
|
|
|
? commerceCertificates.addAll(imageModels)
|
|
|
|
|
: documentID == 2
|
|
|
|
|
? commercialCertificates.addAll(imageModels)
|
|
|
|
|
: vatCertificates.addAll(imageModels);
|
|
|
|
|
? commercialCertificates.addAll(imageModels)
|
|
|
|
|
: vatCertificates.addAll(imageModels);
|
|
|
|
|
document!.data![index].document = Utils.convertFileToBase64(files.first);
|
|
|
|
|
document!.data![index].fileExt = Utils.checkFileExt(files.first.path);
|
|
|
|
|
document!.data![index].documentUrl = files.first.path;
|
|
|
|
|
document!.data![index].isLocalFile = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -192,6 +236,16 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> removeNetworkImag(String filePath) async {
|
|
|
|
|
int index = document!.data!.indexWhere((element) => element.documentUrl == filePath);
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
document!.data![index].documentUrl = null;
|
|
|
|
|
document!.data![index].isLocalFile = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> commercialRemove(String filePath) async {
|
|
|
|
|
int index = commercialCertificates.indexWhere((element) => element.filePath == filePath);
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
@ -214,7 +268,7 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
return await branchRepo.serviceProviderDocumentsUpdate(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create new branch
|
|
|
|
|
// Create new branch
|
|
|
|
|
Future<void> getBranchAndServices() async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
branches = await branchRepo.getBranchAndServices();
|
|
|
|
|
@ -319,7 +373,7 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
pickedBranchImages.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create Services
|
|
|
|
|
// Create Services
|
|
|
|
|
Services? services;
|
|
|
|
|
List<DropValue> categoryDropList = [];
|
|
|
|
|
List<DropValue> servicesDropList = [];
|
|
|
|
|
@ -335,10 +389,10 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
DropValue(
|
|
|
|
|
element.id ?? 0,
|
|
|
|
|
((element.categoryName!.isEmpty
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
? "N/A"
|
|
|
|
|
: countryCode == "SA"
|
|
|
|
|
? element.categoryNameN
|
|
|
|
|
: element.categoryName) ??
|
|
|
|
|
"N/A"),
|
|
|
|
|
"",
|
|
|
|
|
),
|
|
|
|
|
@ -382,7 +436,9 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<GenericRespModel> createService(List<Map<String, dynamic>> map) async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
return await branchRepo.createService(map);
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<GenericRespModel> updateServices(List<Map<String, dynamic>> map) async {
|
|
|
|
|
@ -435,7 +491,7 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
return await branchRepo.duplicateItems(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Branch Users
|
|
|
|
|
// Branch Users
|
|
|
|
|
List<BranchUser> allProviderDealersList = [];
|
|
|
|
|
List<BranchUser> branchUserList = [];
|
|
|
|
|
|
|
|
|
|
@ -449,6 +505,28 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
setState(ViewState.idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// filterUserBranchCategories() {
|
|
|
|
|
// for (var element in branchData.branchServices!) {
|
|
|
|
|
// categories.add(
|
|
|
|
|
// CategoryData(
|
|
|
|
|
// id: element.categoryId,
|
|
|
|
|
// categoryName: element.categoryName,
|
|
|
|
|
// categoryNameN: element.categoryName,
|
|
|
|
|
// ),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// categories = categories.toSet().toList();
|
|
|
|
|
// for (var payment in categories) {
|
|
|
|
|
// for (var element in branchData.branchServices!) {
|
|
|
|
|
// if (payment.id == element.categoryId) {
|
|
|
|
|
// payment.services ??= [];
|
|
|
|
|
// payment.services!.add(element);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// branchData.categories = categories;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Future<void> getBranchUsers(Map<String, dynamic> map) async {
|
|
|
|
|
setState(ViewState.busy);
|
|
|
|
|
GenericRespModel response = await branchRepo.getBranchUsers(map);
|
|
|
|
|
@ -482,7 +560,9 @@ class ServiceVM extends BaseVM {
|
|
|
|
|
File file = File(imageModel.filePath!);
|
|
|
|
|
List<int> imageBytes = await file.readAsBytes();
|
|
|
|
|
String image = base64Encode(imageBytes);
|
|
|
|
|
String fileName = file.path.split('/').last;
|
|
|
|
|
String fileName = file.path
|
|
|
|
|
.split('/')
|
|
|
|
|
.last;
|
|
|
|
|
branchPostingImages = BranchPostingImages(
|
|
|
|
|
imageName: fileName,
|
|
|
|
|
imageStr: image,
|
|
|
|
|
|