You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.6 KiB
Dart
106 lines
3.6 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:test_sa/models/department.dart';
|
|
import 'package:test_sa/models/hospital.dart';
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
import '../timer_model.dart';
|
|
|
|
@Deprecated("Use asset_transfer.dart instead of this one")
|
|
class DeviceTransferInfo {
|
|
String userId;
|
|
String comment;
|
|
Hospital client;
|
|
Department department;
|
|
String workingHours;
|
|
|
|
// DateTime startDate;
|
|
// DateTime endDate;
|
|
String travelingHours;
|
|
String userName;
|
|
String engSignature;
|
|
List<File> attachments;
|
|
String assignedEmployeeName;
|
|
Lookup status;
|
|
TimerModel timer;
|
|
|
|
DeviceTransferInfo({
|
|
this.userId,
|
|
this.comment,
|
|
this.department,
|
|
this.client,
|
|
this.userName,
|
|
this.travelingHours,
|
|
// this.startDate,
|
|
// this.endDate,
|
|
this.workingHours,
|
|
this.engSignature,
|
|
this.status,
|
|
this.assignedEmployeeName,
|
|
this.timer,
|
|
this.attachments,
|
|
});
|
|
|
|
Map<String, String> toJson(bool isSender) {
|
|
Map<String, String> body = {};
|
|
final baseKey = isSender ? "sender_" : "receiver_";
|
|
|
|
if (comment != null && comment.isNotEmpty) body["${baseKey}comment"] = comment;
|
|
if (workingHours != null && workingHours.isNotEmpty) body["${baseKey}working_hours"] = workingHours;
|
|
// if (startDate != null) body["${baseKey}start_date"] = startDate?.toIso8601String();
|
|
// if (endDate != null) body["${baseKey}end_date"] = endDate?.toIso8601String();
|
|
if (timer?.startAt != null) body["${baseKey}start_date"] = timer?.startAt?.toIso8601String();
|
|
if (timer?.endAt != null) body["${baseKey}end_date"] = timer?.endAt?.toIso8601String();
|
|
if (travelingHours != null && travelingHours.isNotEmpty) body["${baseKey}travel_hours"] = travelingHours;
|
|
if (status != null) body["${baseKey}status"] = status.id.toString();
|
|
if (engSignature != null && engSignature.isNotEmpty) body["${baseKey}image"] = engSignature;
|
|
return body;
|
|
}
|
|
|
|
bool validate() {
|
|
if (client == null) return false;
|
|
if (department == null) return false;
|
|
return true;
|
|
}
|
|
|
|
fromDetails(DeviceTransferInfo old, {bool withSignature = true}) {
|
|
userId = old.userId;
|
|
userName = old.userName;
|
|
client = Hospital.fromHospital(old.client);
|
|
department = Department.fromDepartment(old.department);
|
|
workingHours = old.workingHours;
|
|
attachments = old.attachments ?? [];
|
|
// startDate = old.startDate;
|
|
// endDate = old.endDate;
|
|
timer = old.timer;
|
|
travelingHours = old.travelingHours;
|
|
comment = old.comment;
|
|
if (withSignature) engSignature = old.engSignature;
|
|
status = old.status;
|
|
}
|
|
|
|
// factory DeviceTransferInfo.fromJson(Map<String, dynamic> parsedJson, String key) {
|
|
// return DeviceTransferInfo(
|
|
// workingHours: parsedJson["${key}working_hours"],
|
|
// // startDate: parsedJson["${key}start_date"],
|
|
// // endDate: parsedJson["${key}end_date"],
|
|
// timer: TimerModel(
|
|
// startAt: DateTime.tryParse(parsedJson["${key}start_date"] ?? ""),
|
|
// endAt: DateTime.tryParse(parsedJson["${key}end_date"] ?? ""),
|
|
// durationInSecond: ((parsedJson["${key}working_hours"] ?? 0) * 60 * 60).toInt(),
|
|
// ),
|
|
// travelingHours: parsedJson["${key}travel_hours"],
|
|
// userName: parsedJson["${key}name"],
|
|
// signature: parsedJson["${key}image"],
|
|
// userId: parsedJson["${key}id"],
|
|
// comment: parsedJson["${key}comment"],
|
|
// assignedEmployeeName: parsedJson["${key}AssignedEmployeeName"],
|
|
// client: Hospital(id: parsedJson["${key}SiteId"], name: parsedJson["${key}SiteName"]),
|
|
// department: Department(
|
|
// id: parsedJson["${key}DepartmentId"],
|
|
// name: parsedJson["${key}DepartmentName"],
|
|
// ),
|
|
// );
|
|
// }
|
|
}
|