|
|
|
|
@ -87,7 +87,7 @@ class Pentry {
|
|
|
|
|
map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
// if(contacts?.isNotEmpty == true) {
|
|
|
|
|
@ -104,7 +104,10 @@ class Pentry {
|
|
|
|
|
map["engSignature"] = signatureEngineer; //"${DateTime.now().toIso8601String()}.png|$signatureEngineer";
|
|
|
|
|
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) {
|
|
|
|
|
// List<Contact> contacts = [];
|
|
|
|
|
// if(map['contacts'] != null){
|
|
|
|
|
@ -120,6 +123,7 @@ class Pentry {
|
|
|
|
|
List<String> files = [];
|
|
|
|
|
if (map["vAttachments"] != null) if (map["vAttachments"] is List) {
|
|
|
|
|
List list = map["vAttachments"];
|
|
|
|
|
list.removeWhere((element) => (element["attachmentURL"]?.toString() ?? "").isEmpty);
|
|
|
|
|
files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList();
|
|
|
|
|
}
|
|
|
|
|
List<PPMCheckList> ppmCheckLists = [];
|
|
|
|
|
@ -146,7 +150,11 @@ class Pentry {
|
|
|
|
|
ppmCheckLists: ppmCheckLists,
|
|
|
|
|
calibrationTools: calibrationTools,
|
|
|
|
|
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"]),
|
|
|
|
|
signatureEngineer: URLs.getFileUrl(map["engSignature"]),
|
|
|
|
|
);
|
|
|
|
|
|