|
|
|
@ -75,8 +75,8 @@ class Pentry {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toMap(int visitId) {
|
|
|
|
Map<String, dynamic> toMap(int visitId) {
|
|
|
|
Map<String, dynamic> map = {};
|
|
|
|
Map<String, dynamic> map = {};
|
|
|
|
map["visitStatusId"] = ppmVisitStatus?.id.toString();
|
|
|
|
map["visitStatusId"] = ppmVisitStatus?.id?.toString();
|
|
|
|
if (status != null) map["deviceStatusId"] = status?.id.toString();
|
|
|
|
if (status != null) map["deviceStatusId"] = status?.id?.toString();
|
|
|
|
if (travelingHours != null) map["travelingHours"] = travelingHours;
|
|
|
|
if (travelingHours != null) map["travelingHours"] = travelingHours;
|
|
|
|
//if(imageFile != null) map["file_attachement"] = base64Encode(imageFile.readAsBytesSync());
|
|
|
|
//if(imageFile != null) map["file_attachement"] = base64Encode(imageFile.readAsBytesSync());
|
|
|
|
map["actualDate"] = actualVisitDate.toIso8601String();
|
|
|
|
map["actualDate"] = actualVisitDate.toIso8601String();
|
|
|
|
@ -87,7 +87,7 @@ class Pentry {
|
|
|
|
map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
|
|
|
|
map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (files?.isNotEmpty ?? false) {
|
|
|
|
if (files?.isNotEmpty ?? false) {
|
|
|
|
map["vAttachments"] = files.map((file) => {"attachmentName": (file.path.split("/").last + base64Encode(file.readAsBytesSync()))}).toList();
|
|
|
|
map["vAttachments"] = files.map((file) => {"attachmentName": _isLocalUrl(file.path) ? (file.path.split("/").last + "|" + base64Encode(file.readAsBytesSync())) : file.path}).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map["travelingHours"] = travelingHours;
|
|
|
|
map["travelingHours"] = travelingHours;
|
|
|
|
// if(contacts?.isNotEmpty == true) {
|
|
|
|
// if(contacts?.isNotEmpty == true) {
|
|
|
|
@ -105,6 +105,11 @@ class Pentry {
|
|
|
|
return map;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool _isLocalUrl(String url) {
|
|
|
|
|
|
|
|
if (url?.isEmpty != false) return false;
|
|
|
|
|
|
|
|
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
factory Pentry.fromMap(Map<String, dynamic> map) {
|
|
|
|
factory Pentry.fromMap(Map<String, dynamic> map) {
|
|
|
|
// List<Contact> contacts = [];
|
|
|
|
// List<Contact> contacts = [];
|
|
|
|
// if(map['contacts'] != null){
|
|
|
|
// if(map['contacts'] != null){
|
|
|
|
@ -120,6 +125,7 @@ class Pentry {
|
|
|
|
List<String> files = [];
|
|
|
|
List<String> files = [];
|
|
|
|
if (map["vAttachments"] != null) if (map["vAttachments"] is List) {
|
|
|
|
if (map["vAttachments"] != null) if (map["vAttachments"] is List) {
|
|
|
|
List list = map["vAttachments"];
|
|
|
|
List list = map["vAttachments"];
|
|
|
|
|
|
|
|
list.removeWhere((element) => (element["attachmentURL"]?.toString() ?? "").isEmpty);
|
|
|
|
files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList();
|
|
|
|
files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<PPMCheckList> ppmCheckLists = [];
|
|
|
|
List<PPMCheckList> ppmCheckLists = [];
|
|
|
|
@ -132,7 +138,7 @@ class Pentry {
|
|
|
|
calibrationTools = (map['vCalibrationTools'] as List<dynamic>).map((e) => CalibrationTool.fromMap(e as Map<String, dynamic>)).toList();
|
|
|
|
calibrationTools = (map['vCalibrationTools'] as List<dynamic>).map((e) => CalibrationTool.fromMap(e as Map<String, dynamic>)).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Pentry(
|
|
|
|
return Pentry(
|
|
|
|
status: Lookup(id: map["taskStatusId"], name: map["taskStatusName"]),
|
|
|
|
status: Lookup(id: map["deviceStatusId"], name: map["deviceStatusName"]),
|
|
|
|
ppmVisitStatus: Lookup(id: map["visitStatusId"], name: map["visitStatusName"]),
|
|
|
|
ppmVisitStatus: Lookup(id: map["visitStatusId"], name: map["visitStatusName"]),
|
|
|
|
actualVisitDate: DateTime.tryParse(map["actualDate"] ?? ""),
|
|
|
|
actualVisitDate: DateTime.tryParse(map["actualDate"] ?? ""),
|
|
|
|
expectedVisitDate: DateTime.tryParse(map["expectedDate"] ?? ""),
|
|
|
|
expectedVisitDate: DateTime.tryParse(map["expectedDate"] ?? ""),
|
|
|
|
@ -146,7 +152,11 @@ class Pentry {
|
|
|
|
ppmCheckLists: ppmCheckLists,
|
|
|
|
ppmCheckLists: ppmCheckLists,
|
|
|
|
calibrationTools: calibrationTools,
|
|
|
|
calibrationTools: calibrationTools,
|
|
|
|
pmKits: pmKits,
|
|
|
|
pmKits: pmKits,
|
|
|
|
files: files.map((e) => File(e)).toList(),
|
|
|
|
files: files?.map((e) {
|
|
|
|
|
|
|
|
print("${map["id"]}:${files?.length}:e:$e");
|
|
|
|
|
|
|
|
return File(e);
|
|
|
|
|
|
|
|
})?.toList() ??
|
|
|
|
|
|
|
|
[],
|
|
|
|
signatureNurse: URLs.getFileUrl(map["nurseSignature"]),
|
|
|
|
signatureNurse: URLs.getFileUrl(map["nurseSignature"]),
|
|
|
|
signatureEngineer: URLs.getFileUrl(map["engSignature"]),
|
|
|
|
signatureEngineer: URLs.getFileUrl(map["engSignature"]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|