diff --git a/assets/subtitles/ar_subtitle.json b/assets/subtitles/ar_subtitle.json index ada5f900..7a2aa1ca 100644 --- a/assets/subtitles/ar_subtitle.json +++ b/assets/subtitles/ar_subtitle.json @@ -188,5 +188,12 @@ "alert": "تنبيه", "duplicateAlert": "تنبيه التكرار", "duplicateAlertMessage": "هل أنت متأكد أنك تريد تكرار الطلب؟", - "duplicateRequest": "تكرار الطلب" + "duplicateRequest": "تكرار الطلب", + "orderWorkNumber": "رقم طلب العمل", + "assignedEmployee": "الموظف المعين", + "assetSN": "رقم تسلسلي للاصل ", + "assetName": "اسم الاصل", + "site": "الموقع", + "maintenanceSituation": "موقع الصيانه", + "currentSituation": "الموقع الحالي" } \ No newline at end of file diff --git a/assets/subtitles/en_subtitle.json b/assets/subtitles/en_subtitle.json index 2ce29fb9..df591025 100644 --- a/assets/subtitles/en_subtitle.json +++ b/assets/subtitles/en_subtitle.json @@ -184,9 +184,17 @@ "requiredWord": "required", "serviceType": "Service Type", "workPreformed": "Work Preformed", + "orderWorkNumber": "Order Work Number", + "assignedEmployee": "Assigned Employee", + "assetSN": "Asset S.N", + "assetName": "Asset Name", + "site": "Site", + "maintenanceSituation": "Maintenance Situation", + "currentSituation": "Current Situation", "alert": "Alert", "duplicateAlert": "Duplicate Alert", "duplicateAlertMessage": "Are you sure you want to duplicate request?", "duplicateRequest": "Duplicate Request" + } \ No newline at end of file diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index 65c8935d..5edeb3ae 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -45,6 +45,7 @@ class URLs { static get updateServiceReport => "$_baseUrl/WorkOrder/UpdateWorkOrder"; // get static get getServiceReport => "$_baseUrl/WorkOrder/GetWorkOrderById"; // get static get createDuplicatedReport => "$_baseUrl/handle/duplicate/request"; // get + static get searchWorkOrders => "$_baseUrl/WorkOrder/SearchWorkOrders"; static get getServiceReportReasons => "$_baseUrl/Lookups/GetLookup?lookupEnum=522"; // get static get getServiceReportTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=501"; // get diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index 59062251..167087b9 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -14,6 +14,8 @@ import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/models/timer_model.dart'; import 'package:test_sa/models/user.dart'; +import '../../../models/service_request/search_work_order.dart'; + class ServiceRequestsProvider extends ChangeNotifier { // number of items call in each request final pageItemNumber = 10; @@ -35,6 +37,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // list of user requests List serviceRequests; + List workOrders =[]; // when requests in-process _loading = true // done _loading = true @@ -245,6 +248,36 @@ class ServiceRequestsProvider extends ChangeNotifier { } } + Future> searchWorkOrders({@required String callId}) async { + + Response response; + + try{ + var body = { + "pageSize": pageItemNumber, + "pageNumber":( (workOrders?.length ?? 0) ~/ pageItemNumber) + 1, + "callId": callId, + }; + response = await ApiManager.instance.post(URLs.searchWorkOrders, body: body); + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + // client's request was successfully received + List workOrdersJson = json.decode(response.body)["data"]; + print(workOrdersJson); + workOrders = workOrdersJson.map((request) => SearchWorkOrders.fromJson(request)).toList(); + if (workOrders.length == pageItemNumber) { + nextPage = true; + } else { + nextPage = false; + } + } + return workOrders; + + }catch(e){ + return []; + } + } + Future createDuplicatedReport({ @required String host, @required User user, diff --git a/lib/models/service_request/search_work_order.dart b/lib/models/service_request/search_work_order.dart new file mode 100644 index 00000000..ac58714f --- /dev/null +++ b/lib/models/service_request/search_work_order.dart @@ -0,0 +1,584 @@ +import 'package:test_sa/models/lookup.dart'; + +class SearchWorkOrders { + int id; + String parentWOId; + String workOrderNo; + int workOrderYear; + int workOrderSequennce; + CallRequest callRequest; + String assetType; + AssignedEmployee assignedEmployee; + String visitDate; + List assistantEmployees; + String supplier; + String vendorTicketNumber; + List contactPersonWorkOrders; + Lookup calllastSituation; + Lookup currentSituation; + String repairLocation; + String reason; + String startofWorkTime; + String endofWorkTime; + double workingHours; + String travelingHours; + String travelingExpenses; + ModelDefRelatedDefects faultDescription; + List sparePartsWorkOrders; + String reviewComment; + String comment; + String attachmentsWorkOrder; + String equipmentStatus; + List suppEngineerWorkOrders; + String engSignature; + String nurseSignature; + String woParentDto; + + SearchWorkOrders( + {this.id, + this.parentWOId, + this.workOrderNo, + this.workOrderYear, + this.workOrderSequennce, + this.callRequest, + this.assetType, + this.assignedEmployee, + this.visitDate, + this.assistantEmployees, + this.supplier, + this.vendorTicketNumber, + this.contactPersonWorkOrders, + this.calllastSituation, + this.currentSituation, + this.repairLocation, + this.reason, + this.startofWorkTime, + this.endofWorkTime, + this.workingHours, + this.travelingHours, + this.travelingExpenses, + this.faultDescription, + this.sparePartsWorkOrders, + this.reviewComment, + this.comment, + this.attachmentsWorkOrder, + this.equipmentStatus, + this.suppEngineerWorkOrders, + this.engSignature, + this.nurseSignature, + this.woParentDto}); + + SearchWorkOrders.fromJson(Map json) { + print(json['callRequest']); + id = json['id']; + parentWOId = json['parentWOId']; + workOrderNo = json['workOrderNo']; + workOrderYear = json['workOrderYear']; + workOrderSequennce = json['workOrderSequennce']; + callRequest = json['callRequest'] != null + ? new CallRequest.fromJson(json['callRequest']) + : CallRequest(); + assetType = json['assetType']; + assignedEmployee = json['assignedEmployee'] != null + ? new AssignedEmployee.fromJson(json['assignedEmployee']) + : AssignedEmployee(); + visitDate = json['visitDate']; + if (json['assistantEmployees'] != null) { + assistantEmployees = json['assistantEmployees']; + } + supplier = json['supplier']; + vendorTicketNumber = json['vendorTicketNumber']; + if (json['contactPersonWorkOrders'] != null) { + contactPersonWorkOrders = json['contactPersonWorkOrders']; + } + calllastSituation = json['calllastSituation'] != null + ? new Lookup.fromJson(json['calllastSituation']) + : Lookup(); + currentSituation = json['currentSituation'] != null + ? new Lookup.fromJson(json['currentSituation']) + : Lookup(); + repairLocation = json['repairLocation']; + reason = json['reason']; + startofWorkTime = json['startofWorkTime']; + endofWorkTime = json['endofWorkTime']; + workingHours = json['workingHours']; + travelingHours = json['travelingHours']; + travelingExpenses = json['travelingExpenses']; + faultDescription = json['faultDescription'] != null + ? new ModelDefRelatedDefects.fromJson(json['faultDescription']) + : ModelDefRelatedDefects(); + if (json['sparePartsWorkOrders'] != null) { + sparePartsWorkOrders = json['sparePartsWorkOrders']; + } + reviewComment = json['reviewComment']; + comment = json['comment']; + attachmentsWorkOrder = json['attachmentsWorkOrder']; + equipmentStatus = json['equipmentStatus']; + if (json['suppEngineerWorkOrders'] != null) { + suppEngineerWorkOrders = json['suppEngineerWorkOrders']; + } + engSignature = json['engSignature']; + nurseSignature = json['nurseSignature']; + woParentDto = json['woParentDto']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['parentWOId'] = this.parentWOId; + data['workOrderNo'] = this.workOrderNo; + data['workOrderYear'] = this.workOrderYear; + data['workOrderSequennce'] = this.workOrderSequennce; + if (this.callRequest != null) { + data['callRequest'] = this.callRequest.toJson(); + } + data['assetType'] = this.assetType; + if (this.assignedEmployee != null) { + data['assignedEmployee'] = this.assignedEmployee.toJson(); + } + data['visitDate'] = this.visitDate; + if (this.assistantEmployees != null) { + data['assistantEmployees'] = + this.assistantEmployees.map((v) => v.toJson()).toList(); + } + data['supplier'] = this.supplier; + data['vendorTicketNumber'] = this.vendorTicketNumber; + if (this.contactPersonWorkOrders != null) { + data['contactPersonWorkOrders'] = + this.contactPersonWorkOrders.map((v) => v.toJson()).toList(); + } + if (this.calllastSituation != null) { + data['calllastSituation'] = this.calllastSituation.toMap(); + } + if (this.currentSituation != null) { + data['currentSituation'] = this.currentSituation.toMap(); + } + data['repairLocation'] = this.repairLocation; + data['reason'] = this.reason; + data['startofWorkTime'] = this.startofWorkTime; + data['endofWorkTime'] = this.endofWorkTime; + data['workingHours'] = this.workingHours; + data['travelingHours'] = this.travelingHours; + data['travelingExpenses'] = this.travelingExpenses; + if (this.faultDescription != null) { + data['faultDescription'] = this.faultDescription.toJson(); + } + if (this.sparePartsWorkOrders != null) { + data['sparePartsWorkOrders'] = + this.sparePartsWorkOrders.map((v) => v.toJson()).toList(); + } + data['reviewComment'] = this.reviewComment; + data['comment'] = this.comment; + data['attachmentsWorkOrder'] = this.attachmentsWorkOrder; + data['equipmentStatus'] = this.equipmentStatus; + if (this.suppEngineerWorkOrders != null) { + data['suppEngineerWorkOrders'] = + this.suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + } + data['engSignature'] = this.engSignature; + data['nurseSignature'] = this.nurseSignature; + data['woParentDto'] = this.woParentDto; + return data; + } +} + +class CallRequest { + int id; + String callNo; + Asset asset; + AssignedEmployee assignedEmployee; + List callSiteContactPerson; + Lookup status; + Lookup callLastSituation; + String defectType; + String firstAction; + String assetType; + + CallRequest( + {this.id, + this.callNo, + this.asset, + this.assignedEmployee, + this.callSiteContactPerson, + this.status, + this.callLastSituation, + this.defectType, + this.firstAction, + this.assetType}); + + CallRequest.fromJson(Map json) { + id = json['id']; + callNo = json['callNo']; + asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : Asset(); + assignedEmployee = json['assignedEmployee'] != null + ? new AssignedEmployee.fromJson(json['assignedEmployee']) + : AssignedEmployee(); + if (json['callSiteContactPerson'] != null) { + callSiteContactPerson = json['callSiteContactPerson']; + } + status = + json['status'] != null ? new Lookup.fromJson(json['status']) : Lookup(); + callLastSituation = json['callLastSituation'] != null + ? new Lookup.fromJson(json['callLastSituation']) + : Lookup(); + defectType = json['defectType']; + firstAction = json['firstAction']; + assetType = json['assetType']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['callNo'] = this.callNo; + if (this.asset != null) { + data['asset'] = this.asset.toJson(); + } + if (this.assignedEmployee != null) { + data['assignedEmployee'] = this.assignedEmployee.toJson(); + } + if (this.callSiteContactPerson != null) { + data['callSiteContactPerson'] = + this.callSiteContactPerson.map((v) => v.toJson()).toList(); + } + if (this.status != null) { + data['status'] = this.status.toMap(); + } + if (this.callLastSituation != null) { + data['callLastSituation'] = this.callLastSituation.toMap(); + } + data['defectType'] = this.defectType; + data['firstAction'] = this.firstAction; + data['assetType'] = this.assetType; + return data; + } +} + +class Asset { + int id; + String assetSerialNo; + String systemID; + String assetNumber; + ModelDefinition modelDefinition; + String supplier; + String ipAddress; + String macAddress; + String portNumber; + String assetReplace; + String oldAsset; + String isParent; + String parentAsset; + String assetType; + Site site; + String building; + String floor; + String department; + String room; + String testsDay; + String purchasingPrice; + String nbv; + String currency; + String poNo; + String invoiceNumber; + String invoiceDate; + String replacementDate; + String originDepartment; + Site originSite; + String budgetYear; + String lastPOPrice; + String commissioningStatus; + String productionDate; + String edd; + String technicalInspectionDate; + String deliveryInspectionDate; + String endUserAcceptanceDate; + String receivingCommittee; + String siteWarrantyMonths; + String extendedWarrantyMonths; + String remainderWarrantyMonths; + String eomWarrantyMonthsNo; + String warrantyValue; + String warrantyEndDate; + String warrantyContractConditions; + List technicalGuidanceBooks; + String comment; + String tagCode; + + Asset( + {this.id, + this.assetSerialNo, + this.systemID, + this.assetNumber, + this.modelDefinition, + this.supplier, + this.ipAddress, + this.macAddress, + this.portNumber, + this.assetReplace, + this.oldAsset, + this.isParent, + this.parentAsset, + this.assetType, + this.site, + this.building, + this.floor, + this.department, + this.room, + this.testsDay, + this.purchasingPrice, + this.nbv, + this.currency, + this.poNo, + this.invoiceNumber, + this.invoiceDate, + this.replacementDate, + this.originDepartment, + this.originSite, + this.budgetYear, + this.lastPOPrice, + this.commissioningStatus, + this.productionDate, + this.edd, + this.technicalInspectionDate, + this.deliveryInspectionDate, + this.endUserAcceptanceDate, + this.receivingCommittee, + this.siteWarrantyMonths, + this.extendedWarrantyMonths, + this.remainderWarrantyMonths, + this.eomWarrantyMonthsNo, + this.warrantyValue, + this.warrantyEndDate, + this.warrantyContractConditions, + this.technicalGuidanceBooks, + this.comment, + this.tagCode}); + + Asset.fromJson(Map json) { + id = json['id']; + assetSerialNo = json['assetSerialNo']; + systemID = json['systemID']; + assetNumber = json['assetNumber']; + modelDefinition = json['modelDefinition'] != null + ? new ModelDefinition.fromJson(json['modelDefinition']) + : ModelDefinition(); + supplier = json['supplier']; + ipAddress = json['ipAddress']; + macAddress = json['macAddress']; + portNumber = json['portNumber']; + assetReplace = json['assetReplace']; + oldAsset = json['oldAsset']; + isParent = json['isParent']; + parentAsset = json['parentAsset']; + assetType = json['assetType']; + site = json['site'] != null ? new Site.fromJson(json['site']) : Site(); + building = json['building']; + floor = json['floor']; + department = json['department']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['assetSerialNo'] = this.assetSerialNo; + data['systemID'] = this.systemID; + data['assetNumber'] = this.assetNumber; + if (this.modelDefinition != null) { + data['modelDefinition'] = this.modelDefinition.toJson(); + } + data['supplier'] = this.supplier; + data['ipAddress'] = this.ipAddress; + data['macAddress'] = this.macAddress; + data['portNumber'] = this.portNumber; + data['assetReplace'] = this.assetReplace; + data['oldAsset'] = this.oldAsset; + data['isParent'] = this.isParent; + data['parentAsset'] = this.parentAsset; + data['assetType'] = this.assetType; + if (this.site != null) { + data['site'] = this.site.toJson(); + } + data['building'] = this.building; + data['floor'] = this.floor; + data['department'] = this.department; + data['room'] = this.room; + data['testsDay'] = this.testsDay; + data['purchasingPrice'] = this.purchasingPrice; + data['nbv'] = this.nbv; + data['currency'] = this.currency; + data['poNo'] = this.poNo; + data['invoiceNumber'] = this.invoiceNumber; + data['invoiceDate'] = this.invoiceDate; + data['replacementDate'] = this.replacementDate; + data['originDepartment'] = this.originDepartment; + if (this.originSite != null) { + data['originSite'] = this.originSite.toJson(); + } + data['budgetYear'] = this.budgetYear; + data['lastPOPrice'] = this.lastPOPrice; + data['commissioningStatus'] = this.commissioningStatus; + data['productionDate'] = this.productionDate; + data['edd'] = this.edd; + data['technicalInspectionDate'] = this.technicalInspectionDate; + data['deliveryInspectionDate'] = this.deliveryInspectionDate; + data['endUserAcceptanceDate'] = this.endUserAcceptanceDate; + data['receivingCommittee'] = this.receivingCommittee; + data['siteWarrantyMonths'] = this.siteWarrantyMonths; + data['extendedWarrantyMonths'] = this.extendedWarrantyMonths; + data['remainderWarrantyMonths'] = this.remainderWarrantyMonths; + data['eomWarrantyMonthsNo'] = this.eomWarrantyMonthsNo; + data['warrantyValue'] = this.warrantyValue; + data['warrantyEndDate'] = this.warrantyEndDate; + data['warrantyContractConditions'] = this.warrantyContractConditions; + if (this.technicalGuidanceBooks != null) { + data['technicalGuidanceBooks'] = + this.technicalGuidanceBooks.map((v) => v.toJson()).toList(); + } + data['comment'] = this.comment; + data['tagCode'] = this.tagCode; + return data; + } +} + +class ModelDefinition { + int id; + String assetName; + String modelDefCode; + String modelName; + int manufacturerId; + String manufacturerName; + String supplierName; + String replacementDate; + int lifeSpan; + List modelDefRelatedDefects; + List suppliers; + + ModelDefinition( + {this.id, + this.assetName, + this.modelDefCode, + this.modelName, + this.manufacturerId, + this.manufacturerName, + this.supplierName, + this.replacementDate, + this.lifeSpan, + this.modelDefRelatedDefects, + this.suppliers}); + + ModelDefinition.fromJson(Map json) { + id = json['id']; + assetName = json['assetName']; + modelDefCode = json['modelDefCode']; + modelName = json['modelName']; + manufacturerId = json['manufacturerId']; + manufacturerName = json['manufacturerName']; + supplierName = json['supplierName']; + replacementDate = json['replacementDate']; + lifeSpan = json['lifeSpan']; + if (json['modelDefRelatedDefects'] != null) { + modelDefRelatedDefects = []; + json['modelDefRelatedDefects'].forEach((v) { + modelDefRelatedDefects.add(new ModelDefRelatedDefects.fromJson(v)); + }); + } + if (json['suppliers'] != null) { + suppliers = json['suppliers']; + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['assetName'] = this.assetName; + data['modelDefCode'] = this.modelDefCode; + data['modelName'] = this.modelName; + data['manufacturerId'] = this.manufacturerId; + data['manufacturerName'] = this.manufacturerName; + data['supplierName'] = this.supplierName; + data['replacementDate'] = this.replacementDate; + data['lifeSpan'] = this.lifeSpan; + if (this.modelDefRelatedDefects != null) { + data['modelDefRelatedDefects'] = + this.modelDefRelatedDefects.map((v) => v.toJson()).toList(); + } + if (this.suppliers != null) { + data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ModelDefRelatedDefects { + String id; + String defectName; + String workPerformed; + String estimatedTime; + + ModelDefRelatedDefects( + {this.id, this.defectName, this.workPerformed, this.estimatedTime}); + + ModelDefRelatedDefects.fromJson(Map json) { + id = json['id']; + defectName = json['defectName']; + workPerformed = json['workPerformed']; + estimatedTime = json['estimatedTime']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['defectName'] = this.defectName; + data['workPerformed'] = this.workPerformed; + data['estimatedTime'] = this.estimatedTime; + return data; + } +} + +class Site { + int id; + int customerCode; + String custName; + List buildings; + + Site({this.id, this.customerCode, this.custName, this.buildings}); + + Site.fromJson(Map json) { + id = json['id']; + customerCode = json['customerCode']; + custName = json['custName']; + if (json['buildings'] != null) { + buildings = json['buildings']; + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['customerCode'] = this.customerCode; + data['custName'] = this.custName; + if (this.buildings != null) { + data['buildings'] = this.buildings.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class AssignedEmployee { + String id; + String name; + + AssignedEmployee({this.id, this.name}); + + AssignedEmployee.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; + } +} + diff --git a/lib/models/subtitle.dart b/lib/models/subtitle.dart index a2f212c2..49722511 100644 --- a/lib/models/subtitle.dart +++ b/lib/models/subtitle.dart @@ -209,6 +209,13 @@ class Subtitle{ String partNumber; String number; String quantity; + String orderWorkNumber; + String assignedEmployee; + String assetSN; + String assetName; + String site; + String maintenanceSituation; + String currentSituation; // all String duplicateRequest; @@ -407,6 +414,13 @@ class Subtitle{ @required this.duplicateAlert, @required this.duplicateAlertMessage, @required this.duplicateRequest, + @required this.orderWorkNumber, + @required this.assignedEmployee, + @required this.assetSN, + @required this.assetName, + @required this.site, + @required this.maintenanceSituation, + @required this.currentSituation, }); factory Subtitle.fromJson(Map parsedJson){ @@ -597,6 +611,13 @@ class Subtitle{ duplicateAlert: parsedJson["duplicateAlert"], duplicateAlertMessage: parsedJson["duplicateAlertMessage"], duplicateRequest: parsedJson["duplicateRequest"], + orderWorkNumber:parsedJson["orderWorkNumber"], + assignedEmployee:parsedJson["assignedEmployee"], + assetSN:parsedJson["assetSN"], + assetName:parsedJson["assetName"], + site:parsedJson["site"], + maintenanceSituation:parsedJson["maintenanceSituation"], + currentSituation:parsedJson["currentSituation"], ); } diff --git a/lib/views/pages/user/requests/request_details.dart b/lib/views/pages/user/requests/request_details.dart index d45692d8..f33ab0c9 100644 --- a/lib/views/pages/user/requests/request_details.dart +++ b/lib/views/pages/user/requests/request_details.dart @@ -23,6 +23,7 @@ import 'package:test_sa/views/widgets/requests/service_request_update_dialog.dar import 'package:test_sa/views/widgets/sound/sound_player.dart'; import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; +import '../../../../models/service_request/search_work_order.dart'; import 'report/future_service_report.dart'; class RequestDetailsPage extends StatelessWidget { static final String id = "/call-details"; @@ -34,6 +35,7 @@ class RequestDetailsPage extends StatelessWidget { Subtitle _subtitle = AppLocalization.of(context).subtitle; UserProvider _userProvider = Provider.of(context); SettingProvider _settingProvider = Provider.of(context); + List workOrders=[]; ServiceRequestsProvider _serviceRequestsProvider = Provider.of(context); return DefaultTabController( length: 2, @@ -286,65 +288,102 @@ class RequestDetailsPage extends StatelessWidget { // ) ], ), - serviceRequest.viewReport ? - ListView( - padding: EdgeInsets.symmetric(horizontal: 16), - children: [ - RequestInfoRow( - title: _subtitle.faultDescription, - content: serviceRequest.faultDescription, - ), - RequestInfoRow( - title: _subtitle.workPerformed, - content: serviceRequest.workPerformed, - ), - RequestInfoRow( - title: _subtitle.visitDate, - info: serviceRequest.visitDate, - ), - RequestInfoRow( - title: _subtitle.jobSheetNumber, - info: serviceRequest.jobSheetNumber, - ), - _userProvider.user.type == UsersTypes.engineer - && serviceRequest.reportID != null? - Padding( - padding: EdgeInsets.all(32), - child: AButton( - text: _subtitle.editServiceReport, - onPressed: (){ - Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => FutureServiceReport( - request: serviceRequest, - ) - ), + // workOrders.isEmpty ? + FutureBuilder( + future: _serviceRequestsProvider.searchWorkOrders(callId:serviceRequest.requestCode), + builder: (context, snap){ + print("${workOrders?.length}"); + workOrders= snap.data as List; + print("${workOrders?.length}"); + if(snap.connectionState==ConnectionState.done && snap.data.length != 0) + return ListView.builder( + padding: EdgeInsets.symmetric(horizontal: 16), + itemCount: workOrders.length, + itemBuilder: (context , index){ + return Column( + children: [ + RequestInfoRow( + title: _subtitle.callId, + content:workOrders[index].id.toString(), + ), + RequestInfoRow( + title: _subtitle.orderWorkNumber, + info: "123", + ), + RequestInfoRow( + title: _subtitle.visitDate, + info: workOrders[index].visitDate, + ), + RequestInfoRow( + title: _subtitle.assignedEmployee, + info: workOrders[index].callRequest.assignedEmployee.name, + ), + RequestInfoRow( + title: _subtitle.assetSN, + info:workOrders[index].callRequest.asset.assetSerialNo, + ), + RequestInfoRow( + title: _subtitle.assetName, + info:"123", + ), + RequestInfoRow( + title: _subtitle.model, + info:"123", + ), + RequestInfoRow( + title: _subtitle.site, + info:workOrders[index].callRequest.asset.site.custName, + ), + RequestInfoRow( + title: _subtitle.maintenanceSituation, + info:"123", + ), + RequestInfoRow( + title: _subtitle.currentSituation, + info:workOrders[index].currentSituation.name??'', + ), + _userProvider.user.type == UsersTypes.engineer + && serviceRequest.reportID != null? + Padding( + padding: EdgeInsets.all(32), + child: AButton( + text: _subtitle.editServiceReport, + onPressed: (){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => FutureServiceReport( + request: serviceRequest, + ) + ), + ); + }, + ), + ): SizedBox.shrink(), + ], ); }, - ), - ): SizedBox.shrink(), - ], - ): - _userProvider.user.type == UsersTypes.engineer ? - Center( - child: Padding( - padding: EdgeInsets.all(32), - child: AButton( - text: "Create Report", - onPressed: (){ - Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => CreateServiceReport( - request: serviceRequest, - ) + ); + else + return _userProvider.user.type == UsersTypes.engineer ? + Center( + child: Padding( + padding: EdgeInsets.all(32), + child: AButton( + text: "Create Report", + onPressed: (){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => CreateServiceReport( + request: serviceRequest, + ) + ), + ); + }, ), - ); - }, - ), - ), - ): Center(child: ASubTitle(_subtitle.noDateFound),), - - + ), + ): Center(child: ASubTitle(_subtitle.noDateFound),); + }, + ) ], ), ), @@ -354,4 +393,69 @@ class RequestDetailsPage extends StatelessWidget { ), ); } + + Widget dataList({@required Subtitle subtitle, @required List workOrders, @required UserProvider userProvider, @required BuildContext context}){ + return ListView( + padding: EdgeInsets.symmetric(horizontal: 16), + children: [ + RequestInfoRow( + title: subtitle.callId, + content:"123", + ), + RequestInfoRow( + title: subtitle.orderWorkNumber, + info: "123", + ), + RequestInfoRow( + title: subtitle.visitDate, + info: workOrders[0].visitDate??"", + ), + RequestInfoRow( + title: subtitle.assignedEmployee, + info: "123", + ), + RequestInfoRow( + title: subtitle.assetSN, + info:"123", + ), + RequestInfoRow( + title: subtitle.assetName, + info:"123", + ), + RequestInfoRow( + title: subtitle.model, + info:"123", + ), + RequestInfoRow( + title: subtitle.site, + info:"123", + ), + RequestInfoRow( + title: subtitle.maintenanceSituation, + info:"123", + ), + RequestInfoRow( + title: subtitle.currentSituation, + info:"123", + ), + userProvider.user.type == UsersTypes.engineer + && serviceRequest.reportID != null? + Padding( + padding: EdgeInsets.all(32), + child: AButton( + text: subtitle.editServiceReport, + onPressed: (){ + Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => FutureServiceReport( + request: serviceRequest, + ) + ), + ); + }, + ), + ): SizedBox.shrink(), + ], + ); + } }