diff --git a/lib/models/service_request/service_request.dart b/lib/models/service_request/service_request.dart index 370acc93..352adc29 100644 --- a/lib/models/service_request/service_request.dart +++ b/lib/models/service_request/service_request.dart @@ -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 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 json) { + id = json['id']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + return data; + } +} \ No newline at end of file diff --git a/lib/views/pages/user/ppm/ppm_details_page.dart b/lib/views/pages/user/ppm/ppm_details_page.dart index aeeb2aef..a76b34cb 100644 --- a/lib/views/pages/user/ppm/ppm_details_page.dart +++ b/lib/views/pages/user/ppm/ppm_details_page.dart @@ -97,7 +97,8 @@ class _PpmDetailsPageState extends State { const Divider().defaultStyle(context), '${context.translation.assignedTo}: ${ppm.assignedToName ?? ""}'.bodyText(context), '${context.translation.engineerName}: ${ppm.assignedEmployeeName ?? ""}'.bodyText(context), - '${context.translation.site}: ${ppm.siteName}'.bodyText(context), + '${context.translation.site}: ${ppm.siteName?.cleanupWhitespace?.capitalizeFirstOfEach}'.bodyText(context), + '${context.translation.department}: ${ppm.departmentName?.cleanupWhitespace?.capitalizeFirstOfEach}'.bodyText(context), ], ).toShadowContainer(context).paddingAll(16), ).expanded, diff --git a/lib/views/pages/user/requests/service_request_details.dart b/lib/views/pages/user/requests/service_request_details.dart index 7a08e0cd..c55239b6 100644 --- a/lib/views/pages/user/requests/service_request_details.dart +++ b/lib/views/pages/user/requests/service_request_details.dart @@ -109,10 +109,10 @@ class _ServiceRequestDetailsPageState extends State { '${context.translation.requestNo}: ${serviceRequest.requestCode}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), - // Text( - // '${context.translation.visitDate}: ${serviceRequest.visitDate}', - // style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), - // ), + Text( + '${context.translation.requesterName}: ${serviceRequest.callCreatedBy?.name ?? "-"}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + ), ], ).expanded, Column( @@ -143,6 +143,14 @@ class _ServiceRequestDetailsPageState extends State { '${context.translation.model}: ${serviceRequest.device.modelDefinition.modelName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), + Text( + '${context.translation.site}: ${serviceRequest.device.site.custName?.cleanupWhitespace?.capitalizeFirstOfEach}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + ), + Text( + '${context.translation.department}: ${serviceRequest.device.department.departmentName?.cleanupWhitespace?.capitalizeFirstOfEach}', + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + ), 8.height, if ((serviceRequest.callComments ?? "").isNotEmpty) ...[ const Divider().defaultStyle(context),