|
|
|
|
@ -9,6 +9,8 @@ import 'package:test_sa/models/lookup.dart';
|
|
|
|
|
class ServiceRequest {
|
|
|
|
|
String id;
|
|
|
|
|
String requestCode;
|
|
|
|
|
|
|
|
|
|
CallCreatedBy callCreatedBy;
|
|
|
|
|
String deviceSerialNumber;
|
|
|
|
|
int deviceId;
|
|
|
|
|
String deviceArName;
|
|
|
|
|
@ -51,6 +53,7 @@ class ServiceRequest {
|
|
|
|
|
this.id,
|
|
|
|
|
this.date,
|
|
|
|
|
this.requestCode,
|
|
|
|
|
this.callCreatedBy,
|
|
|
|
|
this.hospitalName,
|
|
|
|
|
this.deviceArName,
|
|
|
|
|
this.deviceEnName,
|
|
|
|
|
@ -98,6 +101,10 @@ class ServiceRequest {
|
|
|
|
|
return ServiceRequest(
|
|
|
|
|
id: parsedJson["id"].toString(),
|
|
|
|
|
requestCode: parsedJson["callNo"].toString(),
|
|
|
|
|
callCreatedBy: parsedJson['callCreatedBy'] != null
|
|
|
|
|
? CallCreatedBy.fromJson(parsedJson['callCreatedBy'])
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
|
|
hospitalName: parsedJson["asset"]["site"]["custName"],
|
|
|
|
|
deviceNumber: parsedJson["asset"]["assetNumber"].toString(),
|
|
|
|
|
deviceId: parsedJson["asset"]["id"],
|
|
|
|
|
@ -123,12 +130,16 @@ class ServiceRequest {
|
|
|
|
|
engineerMobile: parsedJson["assignedEmployee"] == null ? null : parsedJson["assignedEmployee"]["phone"],
|
|
|
|
|
faultDescription: parsedJson["workOrder"] != null
|
|
|
|
|
? parsedJson["workOrder"]["faultDescription"] != null
|
|
|
|
|
? FaultDescription.fromJson(parsedJson["workOrder"]["faultDescription"])
|
|
|
|
|
: null
|
|
|
|
|
? FaultDescription.fromJson(parsedJson["workOrder"]["faultDescription"])
|
|
|
|
|
: null
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
|
|
jobSheetNumber: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["jobSheetNumber"] : null,
|
|
|
|
|
visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first,
|
|
|
|
|
visitDate: DateTime
|
|
|
|
|
.tryParse(parsedJson["visitDate"] ?? "")
|
|
|
|
|
.toString()
|
|
|
|
|
.split(" ")
|
|
|
|
|
.first,
|
|
|
|
|
nextVisitDate: DateTime.tryParse(parsedJson["nextVisitDate"] ?? ""),
|
|
|
|
|
//workPerformed: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["workPerformed"] : null,
|
|
|
|
|
device: Asset.fromJson(parsedJson["asset"]),
|
|
|
|
|
@ -142,6 +153,7 @@ class ServiceRequest {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<bool> validateNewRequest(BuildContext context) async {
|
|
|
|
|
if (device == null) {
|
|
|
|
|
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.device}");
|
|
|
|
|
@ -162,3 +174,22 @@ class ServiceRequest {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CallCreatedBy {
|
|
|
|
|
String id;
|
|
|
|
|
String name;
|
|
|
|
|
|
|
|
|
|
CallCreatedBy({this.id, this.name});
|
|
|
|
|
|
|
|
|
|
CallCreatedBy.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
id = json['id'];
|
|
|
|
|
name = json['name'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
|
|
|
|
data['id'] = this.id;
|
|
|
|
|
data['name'] = this.name;
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
}
|