From ebd9297646c981fa6a14b689046c54fcd0eee9f8 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Mon, 19 Jun 2023 14:55:40 +0300 Subject: [PATCH 1/2] Update Work order [Sub work orders] --- .../api/service_requests_provider.dart | 29 ++ .../service_request/search_work_order.dart | 398 +++++++++++------- .../spare_parts_details_bottom_sheet.dart | 101 +++-- .../work_order_details_bottom_sheet.dart | 62 +-- 4 files changed, 364 insertions(+), 226 deletions(-) diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index 755ffff0..0d0d397d 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -478,6 +478,35 @@ class ServiceRequestsProvider extends ChangeNotifier { } } + Future updateWorkOrderDetails({@required SearchWorkOrders workOrder}) async { + Response response; + //Map body = report.toMap(request); + // body["uid"] = user.id; + // body["token"] = user.token; + // body["job_id"] = request.id; + // body["report_id"] = request.reportID; + try { + Map body = workOrder.toJson(); + // body["uid"] = user.id; + // body["token"] = user.token; + response = await ApiManager.instance.put(URLs.updateServiceReport, body: body); + // response = await post( + // Uri.parse( + // host+URLs.updateServiceReport), + // body: body, + // ); + // stateCode = response.statusCode; + + if (response.statusCode >= 200 && response.statusCode < 300) { + reset(); + notifyListeners(); + } + return response.statusCode; + } catch (error) { + return -1; + } + } + Future updateServiceReportTimer({ @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 index 0fc6907b..afe53d84 100644 --- a/lib/models/service_request/search_work_order.dart +++ b/lib/models/service_request/search_work_order.dart @@ -26,7 +26,7 @@ class SearchWorkOrders { num travelingHours; num travelingExpenses; ModelDefRelatedDefects faultDescription; - List sparePartsWorkOrders; + List sparePartsWorkOrders; String reviewComment; String comment; String attachmentsWorkOrder; @@ -79,9 +79,9 @@ class SearchWorkOrders { workOrderNo = json['workOrderNo']; workOrderYear = json['workOrderYear']; workOrderSequennce = json['workOrderSequennce']; - callRequest = json['callRequest'] != null ? new CallRequest.fromJson(json['callRequest']) : CallRequest(); + callRequest = json['callRequest'] != null ? CallRequest.fromJson(json['callRequest']) : CallRequest(); assetType = json['assetType']; - assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee(); + assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee(); visitDate = json['visitDate']; startDate = json['startDate']; endDate = json['endDate']; @@ -93,8 +93,8 @@ class SearchWorkOrders { 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(); + calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : const Lookup(); + currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : const Lookup(); repairLocation = json['repairLocation']; reason = json['reason']; startofWorkTime = json['startofWorkTime']; @@ -102,9 +102,12 @@ class SearchWorkOrders { workingHours = json['workingHours']; travelingHours = json['travelingHours']; travelingExpenses = json['travelingExpenses']; - faultDescription = json['faultDescription'] != null ? new ModelDefRelatedDefects.fromJson(json['faultDescription']) : ModelDefRelatedDefects(); + faultDescription = json['faultDescription'] != null ? ModelDefRelatedDefects.fromJson(json['faultDescription']) : ModelDefRelatedDefects(); if (json['sparePartsWorkOrders'] != null) { - sparePartsWorkOrders = json['sparePartsWorkOrders']; + sparePartsWorkOrders = []; + json['sparePartsWorkOrders'].forEach((v) { + sparePartsWorkOrders.add(SparePartWorkOrder.fromJson(v)); + }); } reviewComment = json['reviewComment']; comment = json['comment']; @@ -119,63 +122,148 @@ class SearchWorkOrders { } 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(); + final Map data = {}; + data['id'] = id; + data['parentWOId'] = parentWOId; + data['workOrderNo'] = workOrderNo; + data['workOrderYear'] = workOrderYear; + data['workOrderSequennce'] = workOrderSequennce; + if (callRequest != null) { + data['callRequest'] = callRequest.toJson(); } - data['assetType'] = this.assetType; - if (this.assignedEmployee != null) { - data['assignedEmployee'] = this.assignedEmployee.toJson(); + if (assetType != null) data['assetType'] = assetType; + if (assignedEmployee != null) { + data['assignedEmployee'] = assignedEmployee.toJson(); } - data['visitDate'] = this.visitDate; - data['startDate'] = this.startDate; - data['endDate'] = this.endDate; - if (this.assistantEmployees != null) { - data['assistantEmployees'] = this.assistantEmployees.map((v) => v.toJson()).toList(); + if (data['visitDate'] != null) data['visitDate'] = visitDate; + if (data['startDate'] != null) data['startDate'] = startDate; + if (data['endDate'] != null) data['endDate'] = endDate; + if (assistantEmployees != null) { + data['assistantEmployees'] = 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 (supplier != null) data['supplier'] = supplier; + data['vendorTicketNumber'] = vendorTicketNumber; + if (contactPersonWorkOrders != null) { + data['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList(); } - if (this.calllastSituation != null) { - data['calllastSituation'] = this.calllastSituation.toMap(); + if (calllastSituation != null) { + data['calllastSituation'] = calllastSituation.toMap(); } - if (this.currentSituation != null) { - data['currentSituation'] = this.currentSituation.toMap(); + if (currentSituation != null) { + data['currentSituation'] = 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 (repairLocation != null) data['repairLocation'] = repairLocation; + if (reason != null) data['reason'] = reason; + if (startofWorkTime != null) data['startofWorkTime'] = startofWorkTime; + if (endofWorkTime != null) data['endofWorkTime'] = endofWorkTime; + if (workingHours != null) data['workingHours'] = workingHours; + if (travelingHours != null) data['travelingHours'] = travelingHours; + if (travelingExpenses != null) data['travelingExpenses'] = travelingExpenses; + if (faultDescription != null) { + data['faultDescription'] = faultDescription.toJson(); } - if (this.sparePartsWorkOrders != null) { - data['sparePartsWorkOrders'] = this.sparePartsWorkOrders.map((v) => v.toJson()).toList(); + if (sparePartsWorkOrders != null) { + data['sparePartsWorkOrders'] = 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['reviewComment'] = reviewComment; + data['comment'] = comment; + data['attachmentsWorkOrder'] = attachmentsWorkOrder; + data['equipmentStatus'] = equipmentStatus; + if (suppEngineerWorkOrders != null) { + data['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); } - data['engSignature'] = this.engSignature; - data['nurseSignature'] = this.nurseSignature; - data['woParentDto'] = this.woParentDto; + data['engSignature'] = engSignature; + data['nurseSignature'] = nurseSignature; + data['woParentDto'] = woParentDto; return data; } } +class SparePart { + int id; + String partNo; + String partName; + SparePart({ + this.id, + this.partNo, + this.partName, + }); + + SparePart.fromJson(Map json) { + id = json['id']; + partNo = json['partNo']; + partName = json['partName']; + } + + SparePart copyWith({ + int id, + String partNo, + String partName, + }) => + SparePart( + id: id ?? this.id, + partNo: partNo ?? this.partNo, + partName: partName ?? this.partName, + ); + + Map toJson() { + final map = {}; + map['id'] = id ?? 0; + map['partNo'] = partNo; + map['partName'] = partName; + return map; + } +} + +class SparePartWorkOrder { + int id; + SparePart sparePart; + double qty; + double returnQty; + double installQty; + + SparePartWorkOrder({ + this.id, + this.sparePart, + this.qty, + this.returnQty, + this.installQty, + }); + + SparePartWorkOrder.fromJson(Map json) { + id = json['id']; + sparePart = SparePart.fromJson(json['sparePart'] ?? {}); + qty = json['qty']; + returnQty = json['returnQty']; + installQty = json['installQty']; + } + + SparePartWorkOrder copyWith({ + int id, + SparePart sparePart, + double qty, + double returnQty, + double installQty, + }) => + SparePartWorkOrder( + id: id ?? this.id, + sparePart: sparePart ?? this.sparePart, + qty: qty ?? this.qty, + returnQty: returnQty ?? this.returnQty, + installQty: installQty ?? this.installQty, + ); + + Map toJson() { + final map = {}; + map['id'] = id ?? 0; + map['sparePart'] = sparePart?.toJson(); + map['qty'] = qty; + map['returnQty'] = returnQty; + map['installQty'] = installQty; + return map; + } +} + class CallRequest { int id; String callNo; @@ -193,40 +281,40 @@ class CallRequest { 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(); + asset = json['asset'] != null ? Asset.fromJson(json['asset']) : Asset(); + assignedEmployee = json['assignedEmployee'] != null ? 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(); + status = json['status'] != null ? Lookup.fromJson(json['status']) : const Lookup(); + callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : const 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(); + final Map data = {}; + data['id'] = id; + data['callNo'] = callNo; + if (asset != null) { + data['asset'] = asset.toJson(); } - if (this.assignedEmployee != null) { - data['assignedEmployee'] = this.assignedEmployee.toJson(); + if (assignedEmployee != null) { + data['assignedEmployee'] = assignedEmployee.toJson(); } - if (this.callSiteContactPerson != null) { - data['callSiteContactPerson'] = this.callSiteContactPerson.map((v) => v.toJson()).toList(); + if (callSiteContactPerson != null) { + data['callSiteContactPerson'] = callSiteContactPerson.map((v) => v.toJson()).toList(); } - if (this.status != null) { - data['status'] = this.status.toMap(); + if (status != null) { + data['status'] = status.toMap(); } - if (this.callLastSituation != null) { - data['callLastSituation'] = this.callLastSituation.toMap(); + if (callLastSituation != null) { + data['callLastSituation'] = callLastSituation.toMap(); } - data['defectType'] = this.defectType; - data['firstAction'] = this.firstAction; - data['assetType'] = this.assetType; + data['defectType'] = defectType; + data['firstAction'] = firstAction; + data['assetType'] = assetType; return data; } } @@ -336,7 +424,7 @@ class Asset { assetSerialNo = json['assetSerialNo']; systemID = json['systemID']; assetNumber = json['assetNumber']; - modelDefinition = json['modelDefinition'] != null ? new ModelDefinition.fromJson(json['modelDefinition']) : ModelDefinition(); + modelDefinition = json['modelDefinition'] != null ? ModelDefinition.fromJson(json['modelDefinition']) : ModelDefinition(); supplier = json['supplier']; ipAddress = json['ipAddress']; macAddress = json['macAddress']; @@ -346,70 +434,70 @@ class Asset { isParent = json['isParent']; parentAsset = json['parentAsset']; assetType = json['assetType']; - site = json['site'] != null ? new Site.fromJson(json['site']) : Site(); + site = json['site'] != null ? 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(); + final Map data = {}; + data['id'] = id; + data['assetSerialNo'] = assetSerialNo; + data['systemID'] = systemID; + data['assetNumber'] = assetNumber; + if (modelDefinition != null) { + data['modelDefinition'] = 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['supplier'] = supplier; + data['ipAddress'] = ipAddress; + data['macAddress'] = macAddress; + data['portNumber'] = portNumber; + data['assetReplace'] = assetReplace; + data['oldAsset'] = oldAsset; + data['isParent'] = isParent; + data['parentAsset'] = parentAsset; + data['assetType'] = assetType; + if (site != null) { + data['site'] = 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['building'] = building; + data['floor'] = floor; + data['department'] = department; + data['room'] = room; + data['testsDay'] = testsDay; + data['purchasingPrice'] = purchasingPrice; + data['nbv'] = nbv; + data['currency'] = currency; + data['poNo'] = poNo; + data['invoiceNumber'] = invoiceNumber; + data['invoiceDate'] = invoiceDate; + data['replacementDate'] = replacementDate; + data['originDepartment'] = originDepartment; + if (originSite != null) { + data['originSite'] = 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['budgetYear'] = budgetYear; + data['lastPOPrice'] = lastPOPrice; + data['commissioningStatus'] = commissioningStatus; + data['productionDate'] = productionDate; + if (edd != null) data['edd'] = edd; + data['technicalInspectionDate'] = technicalInspectionDate; + data['deliveryInspectionDate'] = deliveryInspectionDate; + data['endUserAcceptanceDate'] = endUserAcceptanceDate; + data['receivingCommittee'] = receivingCommittee; + data['siteWarrantyMonths'] = siteWarrantyMonths; + data['extendedWarrantyMonths'] = extendedWarrantyMonths; + data['remainderWarrantyMonths'] = remainderWarrantyMonths; + data['eomWarrantyMonthsNo'] = eomWarrantyMonthsNo; + data['warrantyValue'] = warrantyValue; + data['warrantyEndDate'] = warrantyEndDate; + data['warrantyContractConditions'] = warrantyContractConditions; + if (technicalGuidanceBooks != null) { + data['technicalGuidanceBooks'] = technicalGuidanceBooks.map((v) => v.toJson()).toList(); } - data['comment'] = this.comment; - data['tagCode'] = this.tagCode; + data['comment'] = comment; + data['tagCode'] = tagCode; return data; } } @@ -453,7 +541,7 @@ class ModelDefinition { if (json['modelDefRelatedDefects'] != null) { modelDefRelatedDefects = []; json['modelDefRelatedDefects'].forEach((v) { - modelDefRelatedDefects.add(new ModelDefRelatedDefects.fromJson(v)); + modelDefRelatedDefects.add(ModelDefRelatedDefects.fromJson(v)); }); } if (json['suppliers'] != null) { @@ -462,21 +550,21 @@ class ModelDefinition { } 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(); + final Map data = {}; + data['id'] = id; + data['assetName'] = assetName; + data['modelDefCode'] = modelDefCode; + data['modelName'] = modelName; + data['manufacturerId'] = manufacturerId; + data['manufacturerName'] = manufacturerName; + data['supplierName'] = supplierName; + data['replacementDate'] = replacementDate; + data['lifeSpan'] = lifeSpan; + if (modelDefRelatedDefects != null) { + data['modelDefRelatedDefects'] = modelDefRelatedDefects.map((v) => v.toJson()).toList(); } - if (this.suppliers != null) { - data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList(); + if (suppliers != null) { + data['suppliers'] = suppliers.map((v) => v.toJson()).toList(); } return data; } @@ -498,11 +586,11 @@ class ModelDefRelatedDefects { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['defectName'] = this.defectName; - data['workPerformed'] = this.workPerformed; - data['estimatedTime'] = this.estimatedTime; + final Map data = {}; + data['id'] = id; + data['defectName'] = defectName; + data['workPerformed'] = workPerformed; + data['estimatedTime'] = estimatedTime; return data; } } @@ -525,12 +613,12 @@ class Site { } 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(); + final Map data = {}; + data['id'] = id; + data['customerCode'] = customerCode; + data['custName'] = custName; + if (buildings != null) { + data['buildings'] = buildings.map((v) => v.toJson()).toList(); } return data; } @@ -548,9 +636,9 @@ class AssignedEmployee { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['name'] = this.name; + final Map data = {}; + data['id'] = id; + data['name'] = name; return data; } } diff --git a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart index 048a6158..927a07bd 100644 --- a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart @@ -3,11 +3,11 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/models/service_request/search_work_order.dart'; import 'package:test_sa/views/app_style/colors.dart'; +import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import '../../../controllers/api_routes/http_status_manger.dart'; import '../../../controllers/localization/localization.dart'; import '../../../controllers/providers/api/service_requests_provider.dart'; -import '../../../models/service_report.dart'; import '../../../models/subtitle.dart'; import '../../widgets/app_text_form_field.dart'; import '../../widgets/buttons/app_button.dart'; @@ -72,21 +72,37 @@ class _SparePartsBottomSheetState extends State { final wo = _workOrder.sparePartsWorkOrders[index]; return Column( children: [ - const ATextFormField(labelText: "Part No."), - const SizedBox(height: 8), - const ATextFormField( - labelText: "Description", - hintText: "Add Some Text", - textInputType: TextInputType.multiline, + ATextFormField( + labelText: "Part No.", + onChange: (value) { + _workOrder.sparePartsWorkOrders[index].sparePart = SparePart(partNo: value); + }, ), + // const SizedBox(height: 8), + // ATextFormField( + // labelText: "Description", + // hintText: "Add Some Text", + // textInputType: TextInputType.multiline, + // onSaved: (value) { + // _workOrder.sparePartsWorkOrders[index].sparePart = value; + // }, + // ), const SizedBox(height: 8), - const ATextFormField( + ATextFormField( labelText: "Quantity", textInputType: TextInputType.number, + onSaved: (value) { + _workOrder.sparePartsWorkOrders[index].qty = double.tryParse(value ?? ""); + }, ), const SizedBox(height: 8), InkWell( - onTap: () {}, + onTap: () { + _workOrder.sparePartsWorkOrders.removeWhere( + (element) => (element.sparePart?.partNo == wo.sparePart?.partNo && element.id == wo.id), + ); + setState(() {}); + }, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -106,7 +122,10 @@ class _SparePartsBottomSheetState extends State { const Divider(), const SizedBox(height: 8), InkWell( - onTap: () {}, + onTap: () { + _workOrder.sparePartsWorkOrders.add(SparePartWorkOrder()); + setState(() {}); + }, child: Container( decoration: BoxDecoration( color: AColors.primaryColor.withOpacity(0.15), @@ -116,9 +135,7 @@ class _SparePartsBottomSheetState extends State { child: ListTile( title: Text( "Add Part", - style: Theme.of(context).textTheme.bodyMedium?.copyWith( - color: AColors.primaryColor, - ), + style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: AColors.primaryColor), ), trailing: const Icon( Icons.add_circle, @@ -135,36 +152,38 @@ class _SparePartsBottomSheetState extends State { ), ), ), - AButton( - text: subtitle.update, - onPressed: () async { - // _validate = true; - if (!_formKey.currentState.validate()) { - setState(() {}); - return; - } - // if (!_serviceReport.validate()) { - // setState(() {}); - // return; - // } - _formKey.currentState.save(); + _isLoading + ? const ALoading() + : AButton( + text: subtitle.update, + onPressed: () async { + // _validate = true; + if (!_formKey.currentState.validate()) { + setState(() {}); + return; + } + // if (!_serviceReport.validate()) { + // setState(() {}); + // return; + // } + _formKey.currentState.save(); - _isLoading = true; - setState(() {}); + _isLoading = true; + setState(() {}); - int status = await Provider.of(context).updateServiceReport(report: ServiceReport()); - _isLoading = false; - setState(() {}); - if (status >= 200 && status < 300) { - Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully); - Navigator.of(context).pop(); - // Navigator.of(context).pop(); - } else { - String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: subtitle); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); - } - }, - ), + int status = await Provider.of(context, listen: false).updateWorkOrderDetails(workOrder: _workOrder); + _isLoading = false; + setState(() {}); + if (status >= 200 && status < 300) { + Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully); + Navigator.of(context).pop(); + // Navigator.of(context).pop(); + } else { + String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: subtitle); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); + } + }, + ), ], ), ), diff --git a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart index 12df4c57..31c8de92 100644 --- a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart @@ -7,13 +7,13 @@ import 'package:test_sa/models/service_request/search_work_order.dart'; import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/views/widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart'; +import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/status/report/service_report_maintenance_situation.dart'; import 'package:test_sa/views/widgets/status/report/service_report_repair_location.dart'; import '../../../controllers/api_routes/http_status_manger.dart'; import '../../../controllers/localization/localization.dart'; import '../../../models/engineer.dart'; -import '../../../models/service_report.dart'; import '../../app_style/sizing.dart'; import '../../widgets/date_and_time/time_picker.dart'; import '../../widgets/status/report/service_report_all_users.dart'; @@ -135,7 +135,7 @@ class _WorkOrderDetailsBottomSheetState extends State Validator.isNumeric(value) ? null : _subtitle.requiredWord, @@ -200,36 +200,38 @@ class _WorkOrderDetailsBottomSheetState extends State(context).updateServiceReport(report: ServiceReport()); - _isLoading = false; - setState(() {}); - if (status >= 200 && status < 300) { - Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully); - Navigator.of(context).pop(); - // Navigator.of(context).pop(); - } else { - String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: subtitle); - ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); - } - }, - ), + int status = await Provider.of(context, listen: false).updateWorkOrderDetails(workOrder: _workOrder); + _isLoading = false; + setState(() {}); + if (status >= 200 && status < 300) { + Fluttertoast.showToast(msg: subtitle.requestCompleteSuccessfully); + Navigator.of(context).pop(); + // Navigator.of(context).pop(); + } else { + String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: subtitle); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(errorMessage))); + } + }, + ), ], ), ), From 19cee08954fb03dfebd06dc1fe786020c992ec08 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Tue, 20 Jun 2023 09:27:41 +0300 Subject: [PATCH 2/2] Updating Search Work Order Model --- .../api/service_requests_provider.dart | 16 +- .../service_request/search_work_order.dart | 3201 ++++++++++++++--- .../create_sub_workorder_page.dart | 6 +- .../search_sub_workorder_page.dart | 63 +- .../spare_parts_details_bottom_sheet.dart | 6 +- .../work_order_details_bottom_sheet.dart | 46 +- .../sub_workorder/workorder_details.dart | 10 +- .../pages/sub_workorder/workorder_item.dart | 25 +- .../pages/sub_workorder/workorder_list.dart | 48 +- .../pages/sub_workorder/workorder_update.dart | 8 +- .../report/future_service_report.dart | 2 +- .../pages/user/requests/request_details.dart | 4 +- 12 files changed, 2803 insertions(+), 632 deletions(-) diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index 0d0d397d..1b64bb03 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -13,9 +13,9 @@ import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/models/service_request/service_request_search.dart'; 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'; +import '../../../models/user.dart'; class ServiceRequestsProvider extends ChangeNotifier { // number of items call in each request @@ -38,7 +38,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // list of user requests List serviceRequests; - List workOrders = []; + List workOrders = []; // when requests in-process _loading = true // done _loading = true @@ -387,7 +387,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future> searchWorkOrders({@required String callId}) async { + Future> searchWorkOrders({@required String callId}) async { Response response; try { @@ -402,7 +402,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // client's request was successfully received List workOrdersJson = json.decode(response.body)["data"]; print(workOrdersJson); - workOrders = workOrdersJson.map((request) => SearchWorkOrders.fromJson(request)).toList(); + workOrders = workOrdersJson.map((request) => SearchWorkOrder.fromJson(request)).toList(); if (workOrders.length == pageItemNumber) { nextPage = true; } else { @@ -478,7 +478,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future updateWorkOrderDetails({@required SearchWorkOrders workOrder}) async { + Future updateWorkOrderDetails({@required SearchWorkOrder workOrder}) async { Response response; //Map body = report.toMap(request); // body["uid"] = user.id; @@ -588,8 +588,8 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future> searchForWorkOrders( - SearchWorkOrders search, + Future> searchForWorkOrders( + SearchWorkOrder search, String callerId, Lookup dateOperator, String site, @@ -619,7 +619,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // client's request was successfully received List workOrdersJson = json.decode(response.body)["data"]; print(workOrdersJson); - workOrders = workOrdersJson.map((request) => SearchWorkOrders.fromJson(request)).toList(); + workOrders = workOrdersJson.map((request) => SearchWorkOrder.fromJson(request)).toList(); if (workOrders.length == pageItemNumber) { nextPage = true; } else { diff --git a/lib/models/service_request/search_work_order.dart b/lib/models/service_request/search_work_order.dart index afe53d84..78a43616 100644 --- a/lib/models/service_request/search_work_order.dart +++ b/lib/models/service_request/search_work_order.dart @@ -1,644 +1,2805 @@ 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; - String startDate; - String endDate; - List assistantEmployees; - String supplier; - String vendorTicketNumber; - List contactPersonWorkOrders; - Lookup calllastSituation; - Lookup currentSituation; - String repairLocation; - String reason; - String startofWorkTime; - String endofWorkTime; - double workingHours; - num travelingHours; - num 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.startDate, - this.endDate, - 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']); +class SearchWorkOrder { + SearchWorkOrder({ + 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, + }); + + SearchWorkOrder.fromJson(dynamic json) { id = json['id']; parentWOId = json['parentWOId']; workOrderNo = json['workOrderNo']; workOrderYear = json['workOrderYear']; workOrderSequennce = json['workOrderSequennce']; - callRequest = json['callRequest'] != null ? CallRequest.fromJson(json['callRequest']) : CallRequest(); - assetType = json['assetType']; - assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee(); + callRequest = json['callRequest'] != null ? CallRequest.fromJson(json['callRequest']) : null; + assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null; + assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null; visitDate = json['visitDate']; - startDate = json['startDate']; - endDate = json['endDate']; if (json['assistantEmployees'] != null) { - assistantEmployees = json['assistantEmployees']; + assistantEmployees = []; + json['assistantEmployees'].forEach((v) { + assistantEmployees.add(AssistantEmployees.fromJson(v)); + }); } - supplier = json['supplier']; + supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null; vendorTicketNumber = json['vendorTicketNumber']; if (json['contactPersonWorkOrders'] != null) { - contactPersonWorkOrders = json['contactPersonWorkOrders']; + contactPersonWorkOrders = []; + json['contactPersonWorkOrders'].forEach((v) { + contactPersonWorkOrders.add(ContactPersonWorkOrders.fromJson(v)); + }); } - calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : const Lookup(); - currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : const Lookup(); - repairLocation = json['repairLocation']; - reason = json['reason']; + calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : null; + currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null; + repairLocation = json['repairLocation'] != null ? Lookup.fromJson(json['repairLocation']) : null; + reason = json['reason'] != null ? Reason.fromJson(json['reason']) : null; startofWorkTime = json['startofWorkTime']; endofWorkTime = json['endofWorkTime']; workingHours = json['workingHours']; travelingHours = json['travelingHours']; travelingExpenses = json['travelingExpenses']; - faultDescription = json['faultDescription'] != null ? ModelDefRelatedDefects.fromJson(json['faultDescription']) : ModelDefRelatedDefects(); + faultDescription = json['faultDescription'] != null ? FaultDescription.fromJson(json['faultDescription']) : null; if (json['sparePartsWorkOrders'] != null) { - sparePartsWorkOrders = []; + sparePartsWorkOrders = []; json['sparePartsWorkOrders'].forEach((v) { - sparePartsWorkOrders.add(SparePartWorkOrder.fromJson(v)); + sparePartsWorkOrders.add(SparePartsWorkOrders.fromJson(v)); }); } reviewComment = json['reviewComment']; comment = json['comment']; - attachmentsWorkOrder = json['attachmentsWorkOrder']; - equipmentStatus = json['equipmentStatus']; + if (json['attachmentsWorkOrder'] != null) { + attachmentsWorkOrder = []; + json['attachmentsWorkOrder'].forEach((v) { + attachmentsWorkOrder.add(AttachmentsWorkOrder.fromJson(v)); + }); + } + equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null; if (json['suppEngineerWorkOrders'] != null) { - suppEngineerWorkOrders = json['suppEngineerWorkOrders']; + suppEngineerWorkOrders = []; + json['suppEngineerWorkOrders'].forEach((v) { + suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v)); + }); } engSignature = json['engSignature']; nurseSignature = json['nurseSignature']; - woParentDto = json['woParentDto']; + woParentDto = json['woParentDto'] != null ? WoParentDto.fromJson(json['woParentDto']) : null; } - + num id; + num parentWOId; + String workOrderNo; + num workOrderYear; + num workOrderSequennce; + CallRequest callRequest; + Lookup assetType; + AssignedEmployee assignedEmployee; + String visitDate; + List assistantEmployees; + SupplierModel supplier; + String vendorTicketNumber; + List contactPersonWorkOrders; + Lookup calllastSituation; + Lookup currentSituation; + Lookup repairLocation; + Reason reason; + String startofWorkTime; + String endofWorkTime; + num workingHours; + num travelingHours; + num travelingExpenses; + FaultDescription faultDescription; + List sparePartsWorkOrders; + String reviewComment; + String comment; + List attachmentsWorkOrder; + Lookup equipmentStatus; + List suppEngineerWorkOrders; + String engSignature; + String nurseSignature; + WoParentDto woParentDto; + SearchWorkOrder copyWith({ + num id, + num parentWOId, + String workOrderNo, + num workOrderYear, + num workOrderSequennce, + CallRequest callRequest, + Lookup assetType, + AssignedEmployee assignedEmployee, + String visitDate, + List assistantEmployees, + SupplierModel supplier, + String vendorTicketNumber, + List contactPersonWorkOrders, + Lookup calllastSituation, + Lookup currentSituation, + Lookup repairLocation, + Reason reason, + String startofWorkTime, + String endofWorkTime, + num workingHours, + num travelingHours, + num travelingExpenses, + FaultDescription faultDescription, + List sparePartsWorkOrders, + String reviewComment, + String comment, + List attachmentsWorkOrder, + Lookup equipmentStatus, + List suppEngineerWorkOrders, + String engSignature, + String nurseSignature, + WoParentDto woParentDto, + }) => + SearchWorkOrder( + id: id ?? this.id, + parentWOId: parentWOId ?? this.parentWOId, + workOrderNo: workOrderNo ?? this.workOrderNo, + workOrderYear: workOrderYear ?? this.workOrderYear, + workOrderSequennce: workOrderSequennce ?? this.workOrderSequennce, + callRequest: callRequest ?? this.callRequest, + assetType: assetType ?? this.assetType, + assignedEmployee: assignedEmployee ?? this.assignedEmployee, + visitDate: visitDate ?? this.visitDate, + assistantEmployees: assistantEmployees ?? this.assistantEmployees, + supplier: supplier ?? this.supplier, + vendorTicketNumber: vendorTicketNumber ?? this.vendorTicketNumber, + contactPersonWorkOrders: contactPersonWorkOrders ?? this.contactPersonWorkOrders, + calllastSituation: calllastSituation ?? this.calllastSituation, + currentSituation: currentSituation ?? this.currentSituation, + repairLocation: repairLocation ?? this.repairLocation, + reason: reason ?? this.reason, + startofWorkTime: startofWorkTime ?? this.startofWorkTime, + endofWorkTime: endofWorkTime ?? this.endofWorkTime, + workingHours: workingHours ?? this.workingHours, + travelingHours: travelingHours ?? this.travelingHours, + travelingExpenses: travelingExpenses ?? this.travelingExpenses, + faultDescription: faultDescription ?? this.faultDescription, + sparePartsWorkOrders: sparePartsWorkOrders ?? this.sparePartsWorkOrders, + reviewComment: reviewComment ?? this.reviewComment, + comment: comment ?? this.comment, + attachmentsWorkOrder: attachmentsWorkOrder ?? this.attachmentsWorkOrder, + equipmentStatus: equipmentStatus ?? this.equipmentStatus, + suppEngineerWorkOrders: suppEngineerWorkOrders ?? this.suppEngineerWorkOrders, + engSignature: engSignature ?? this.engSignature, + nurseSignature: nurseSignature ?? this.nurseSignature, + woParentDto: woParentDto ?? this.woParentDto, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['parentWOId'] = parentWOId; - data['workOrderNo'] = workOrderNo; - data['workOrderYear'] = workOrderYear; - data['workOrderSequennce'] = workOrderSequennce; + final map = {}; + map['id'] = id; + map['parentWOId'] = parentWOId; + map['workOrderNo'] = workOrderNo; + map['workOrderYear'] = workOrderYear; + map['workOrderSequennce'] = workOrderSequennce; if (callRequest != null) { - data['callRequest'] = callRequest.toJson(); + map['callRequest'] = callRequest.toJson(); + } + if (assetType != null) { + map['assetType'] = assetType.toMap(); } - if (assetType != null) data['assetType'] = assetType; if (assignedEmployee != null) { - data['assignedEmployee'] = assignedEmployee.toJson(); + map['assignedEmployee'] = assignedEmployee.toJson(); } - if (data['visitDate'] != null) data['visitDate'] = visitDate; - if (data['startDate'] != null) data['startDate'] = startDate; - if (data['endDate'] != null) data['endDate'] = endDate; + map['visitDate'] = visitDate; if (assistantEmployees != null) { - data['assistantEmployees'] = assistantEmployees.map((v) => v.toJson()).toList(); + map['assistantEmployees'] = assistantEmployees.map((v) => v.toJson()).toList(); + } + if (supplier != null) { + map['supplier'] = supplier.toJson(); } - if (supplier != null) data['supplier'] = supplier; - data['vendorTicketNumber'] = vendorTicketNumber; + map['vendorTicketNumber'] = vendorTicketNumber; if (contactPersonWorkOrders != null) { - data['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList(); + map['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList(); } if (calllastSituation != null) { - data['calllastSituation'] = calllastSituation.toMap(); + map['calllastSituation'] = calllastSituation.toMap(); } if (currentSituation != null) { - data['currentSituation'] = currentSituation.toMap(); - } - if (repairLocation != null) data['repairLocation'] = repairLocation; - if (reason != null) data['reason'] = reason; - if (startofWorkTime != null) data['startofWorkTime'] = startofWorkTime; - if (endofWorkTime != null) data['endofWorkTime'] = endofWorkTime; - if (workingHours != null) data['workingHours'] = workingHours; - if (travelingHours != null) data['travelingHours'] = travelingHours; - if (travelingExpenses != null) data['travelingExpenses'] = travelingExpenses; + map['currentSituation'] = currentSituation.toMap(); + } + if (repairLocation != null) { + map['repairLocation'] = repairLocation.toMap(); + } + if (reason != null) { + map['reason'] = reason.toJson(); + } + map['startofWorkTime'] = startofWorkTime; + map['endofWorkTime'] = endofWorkTime; + map['workingHours'] = workingHours; + map['travelingHours'] = travelingHours; + map['travelingExpenses'] = travelingExpenses; if (faultDescription != null) { - data['faultDescription'] = faultDescription.toJson(); + map['faultDescription'] = faultDescription.toJson(); } if (sparePartsWorkOrders != null) { - data['sparePartsWorkOrders'] = sparePartsWorkOrders.map((v) => v.toJson()).toList(); + map['sparePartsWorkOrders'] = sparePartsWorkOrders.map((v) => v.toJson()).toList(); + } + map['reviewComment'] = reviewComment; + map['comment'] = comment; + if (attachmentsWorkOrder != null) { + map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => v.toJson()).toList(); + } + if (equipmentStatus != null) { + map['equipmentStatus'] = equipmentStatus.toMap(); } - data['reviewComment'] = reviewComment; - data['comment'] = comment; - data['attachmentsWorkOrder'] = attachmentsWorkOrder; - data['equipmentStatus'] = equipmentStatus; if (suppEngineerWorkOrders != null) { - data['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + } + map['engSignature'] = engSignature; + map['nurseSignature'] = nurseSignature; + if (woParentDto != null) { + map['woParentDto'] = woParentDto.toJson(); } - data['engSignature'] = engSignature; - data['nurseSignature'] = nurseSignature; - data['woParentDto'] = woParentDto; - return data; + return map; } } -class SparePart { - int id; - String partNo; - String partName; - SparePart({ +class WoParentDto { + WoParentDto({ + this.callLastSituation, + this.supplier, + this.assetType, + this.vendorTicketNumber, + this.callId, this.id, - this.partNo, - this.partName, + this.stepsWorkOrderDto, + this.suppEngineerWorkOrders, + this.equipmentStatus, + this.currentSituation, }); - SparePart.fromJson(Map json) { + WoParentDto.fromJson(dynamic json) { + callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : null; + supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null; + assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null; + vendorTicketNumber = json['vendorTicketNumber']; + callId = json['callId']; id = json['id']; - partNo = json['partNo']; - partName = json['partName']; + stepsWorkOrderDto = json['stepsWorkOrderDto'] != null ? StepsWorkOrderDto.fromJson(json['stepsWorkOrderDto']) : null; + if (json['suppEngineerWorkOrders'] != null) { + suppEngineerWorkOrders = []; + json['suppEngineerWorkOrders'].forEach((v) { + suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v)); + }); + } + equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null; + currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null; } - - SparePart copyWith({ - int id, - String partNo, - String partName, + Lookup callLastSituation; + SupplierModel supplier; + Lookup assetType; + String vendorTicketNumber; + num callId; + num id; + StepsWorkOrderDto stepsWorkOrderDto; + List suppEngineerWorkOrders; + Lookup equipmentStatus; + Lookup currentSituation; + WoParentDto copyWith({ + Lookup callLastSituation, + SupplierModel supplier, + Lookup assetType, + String vendorTicketNumber, + num callId, + num id, + StepsWorkOrderDto stepsWorkOrderDto, + List suppEngineerWorkOrders, + Lookup equipmentStatus, + Lookup currentSituation, }) => - SparePart( + WoParentDto( + callLastSituation: callLastSituation ?? this.callLastSituation, + supplier: supplier ?? this.supplier, + assetType: assetType ?? this.assetType, + vendorTicketNumber: vendorTicketNumber ?? this.vendorTicketNumber, + callId: callId ?? this.callId, id: id ?? this.id, - partNo: partNo ?? this.partNo, - partName: partName ?? this.partName, + stepsWorkOrderDto: stepsWorkOrderDto ?? this.stepsWorkOrderDto, + suppEngineerWorkOrders: suppEngineerWorkOrders ?? this.suppEngineerWorkOrders, + equipmentStatus: equipmentStatus ?? this.equipmentStatus, + currentSituation: currentSituation ?? this.currentSituation, ); - Map toJson() { final map = {}; - map['id'] = id ?? 0; - map['partNo'] = partNo; - map['partName'] = partName; + if (callLastSituation != null) { + map['callLastSituation'] = callLastSituation.toMap(); + } + if (supplier != null) { + map['supplier'] = supplier.toJson(); + } + if (assetType != null) { + map['assetType'] = assetType.toMap(); + } + map['vendorTicketNumber'] = vendorTicketNumber; + map['callId'] = callId; + map['id'] = id; + if (stepsWorkOrderDto != null) { + map['stepsWorkOrderDto'] = stepsWorkOrderDto.toJson(); + } + if (suppEngineerWorkOrders != null) { + map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + } + if (equipmentStatus != null) { + map['equipmentStatus'] = equipmentStatus.toMap(); + } + if (currentSituation != null) { + map['currentSituation'] = currentSituation.toMap(); + } return map; } } -class SparePartWorkOrder { - int id; - SparePart sparePart; - double qty; - double returnQty; - double installQty; - - SparePartWorkOrder({ +class SuppEngineerWorkOrders { + SuppEngineerWorkOrders({ this.id, - this.sparePart, - this.qty, - this.returnQty, - this.installQty, + this.supplierContactId, + this.personName, + this.personRoleName, + this.contact, + this.externalEngCode, + this.email, }); - SparePartWorkOrder.fromJson(Map json) { + SuppEngineerWorkOrders.fromJson(dynamic json) { id = json['id']; - sparePart = SparePart.fromJson(json['sparePart'] ?? {}); - qty = json['qty']; - returnQty = json['returnQty']; - installQty = json['installQty']; + supplierContactId = json['supplierContactId']; + personName = json['personName']; + personRoleName = json['personRoleName']; + contact = json['contact']; + externalEngCode = json['externalEngCode']; + email = json['email']; } - - SparePartWorkOrder copyWith({ - int id, - SparePart sparePart, - double qty, - double returnQty, - double installQty, + num id; + num supplierContactId; + String personName; + String personRoleName; + String contact; + String externalEngCode; + String email; + SuppEngineerWorkOrders copyWith({ + num id, + num supplierContactId, + String personName, + String personRoleName, + String contact, + String externalEngCode, + String email, }) => - SparePartWorkOrder( + SuppEngineerWorkOrders( id: id ?? this.id, - sparePart: sparePart ?? this.sparePart, - qty: qty ?? this.qty, - returnQty: returnQty ?? this.returnQty, - installQty: installQty ?? this.installQty, + supplierContactId: supplierContactId ?? this.supplierContactId, + personName: personName ?? this.personName, + personRoleName: personRoleName ?? this.personRoleName, + contact: contact ?? this.contact, + externalEngCode: externalEngCode ?? this.externalEngCode, + email: email ?? this.email, ); - Map toJson() { final map = {}; - map['id'] = id ?? 0; - map['sparePart'] = sparePart?.toJson(); - map['qty'] = qty; - map['returnQty'] = returnQty; - map['installQty'] = installQty; + map['id'] = id; + map['supplierContactId'] = supplierContactId; + map['personName'] = personName; + map['personRoleName'] = personRoleName; + map['contact'] = contact; + map['externalEngCode'] = externalEngCode; + map['email'] = email; return map; } } -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}); +class StepsWorkOrderDto { + StepsWorkOrderDto({ + this.sequence, + this.id, + this.name, + this.statusValue, + this.typeTransaction, + this.processed, + this.parentWOId, + this.callId, + }); - CallRequest.fromJson(Map json) { + StepsWorkOrderDto.fromJson(dynamic json) { + sequence = json['sequence']; id = json['id']; - callNo = json['callNo']; - asset = json['asset'] != null ? Asset.fromJson(json['asset']) : Asset(); - assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee(); - if (json['callSiteContactPerson'] != null) { - callSiteContactPerson = json['callSiteContactPerson']; - } - status = json['status'] != null ? Lookup.fromJson(json['status']) : const Lookup(); - callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : const Lookup(); - defectType = json['defectType']; - firstAction = json['firstAction']; - assetType = json['assetType']; + name = json['name']; + statusValue = json['statusValue']; + typeTransaction = json['typeTransaction']; + processed = json['processed']; + parentWOId = json['parentWOId']; + callId = json['callId']; } - + num sequence; + num id; + String name; + num statusValue; + String typeTransaction; + bool processed; + num parentWOId; + num callId; + StepsWorkOrderDto copyWith({ + num sequence, + num id, + String name, + num statusValue, + String typeTransaction, + bool processed, + num parentWOId, + num callId, + }) => + StepsWorkOrderDto( + sequence: sequence ?? this.sequence, + id: id ?? this.id, + name: name ?? this.name, + statusValue: statusValue ?? this.statusValue, + typeTransaction: typeTransaction ?? this.typeTransaction, + processed: processed ?? this.processed, + parentWOId: parentWOId ?? this.parentWOId, + callId: callId ?? this.callId, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['callNo'] = callNo; - if (asset != null) { - data['asset'] = asset.toJson(); - } - if (assignedEmployee != null) { - data['assignedEmployee'] = assignedEmployee.toJson(); - } - if (callSiteContactPerson != null) { - data['callSiteContactPerson'] = callSiteContactPerson.map((v) => v.toJson()).toList(); - } - if (status != null) { - data['status'] = status.toMap(); - } - if (callLastSituation != null) { - data['callLastSituation'] = callLastSituation.toMap(); - } - data['defectType'] = defectType; - data['firstAction'] = firstAction; - data['assetType'] = assetType; - return data; + final map = {}; + map['sequence'] = sequence; + map['id'] = id; + map['name'] = name; + map['statusValue'] = statusValue; + map['typeTransaction'] = typeTransaction; + map['processed'] = processed; + map['parentWOId'] = parentWOId; + map['callId'] = callId; + return map; } } -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; - int 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; +class SupplierModel { + SupplierModel({ + this.id, + this.suppliername, + this.name, + this.website, + this.email, + this.code, + this.suppNo, + this.suppStatusId, + this.cityId, + this.person, + this.comment, + this.zipcode, + this.contact, + this.telephones, + this.faxes, + this.addresses, + this.attachments, + this.suppPersons, + this.suppTCodes, + }); - 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) { + SupplierModel.fromJson(dynamic json) { id = json['id']; - assetSerialNo = json['assetSerialNo']; - systemID = json['systemID']; - assetNumber = json['assetNumber']; - modelDefinition = json['modelDefinition'] != null ? 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 ? Site.fromJson(json['site']) : Site(); - building = json['building']; - floor = json['floor']; - department = json['department']; - } - - Map toJson() { - final Map data = {}; - data['id'] = id; - data['assetSerialNo'] = assetSerialNo; - data['systemID'] = systemID; - data['assetNumber'] = assetNumber; - if (modelDefinition != null) { - data['modelDefinition'] = modelDefinition.toJson(); - } - data['supplier'] = supplier; - data['ipAddress'] = ipAddress; - data['macAddress'] = macAddress; - data['portNumber'] = portNumber; - data['assetReplace'] = assetReplace; - data['oldAsset'] = oldAsset; - data['isParent'] = isParent; - data['parentAsset'] = parentAsset; - data['assetType'] = assetType; - if (site != null) { - data['site'] = site.toJson(); - } - data['building'] = building; - data['floor'] = floor; - data['department'] = department; - data['room'] = room; - data['testsDay'] = testsDay; - data['purchasingPrice'] = purchasingPrice; - data['nbv'] = nbv; - data['currency'] = currency; - data['poNo'] = poNo; - data['invoiceNumber'] = invoiceNumber; - data['invoiceDate'] = invoiceDate; - data['replacementDate'] = replacementDate; - data['originDepartment'] = originDepartment; - if (originSite != null) { - data['originSite'] = originSite.toJson(); - } - data['budgetYear'] = budgetYear; - data['lastPOPrice'] = lastPOPrice; - data['commissioningStatus'] = commissioningStatus; - data['productionDate'] = productionDate; - if (edd != null) data['edd'] = edd; - data['technicalInspectionDate'] = technicalInspectionDate; - data['deliveryInspectionDate'] = deliveryInspectionDate; - data['endUserAcceptanceDate'] = endUserAcceptanceDate; - data['receivingCommittee'] = receivingCommittee; - data['siteWarrantyMonths'] = siteWarrantyMonths; - data['extendedWarrantyMonths'] = extendedWarrantyMonths; - data['remainderWarrantyMonths'] = remainderWarrantyMonths; - data['eomWarrantyMonthsNo'] = eomWarrantyMonthsNo; - data['warrantyValue'] = warrantyValue; - data['warrantyEndDate'] = warrantyEndDate; - data['warrantyContractConditions'] = warrantyContractConditions; - if (technicalGuidanceBooks != null) { - data['technicalGuidanceBooks'] = technicalGuidanceBooks.map((v) => v.toJson()).toList(); + suppliername = json['suppliername']; + name = json['name']; + website = json['website']; + email = json['email']; + code = json['code']; + suppNo = json['suppNo']; + suppStatusId = json['suppStatusId']; + cityId = json['cityId']; + person = json['person']; + comment = json['comment']; + zipcode = json['zipcode']; + contact = json['contact']; + if (json['telephones'] != null) { + telephones = []; + json['telephones'].forEach((v) { + telephones.add(Telephones.fromJson(v)); + }); } - data['comment'] = comment; - data['tagCode'] = 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(ModelDefRelatedDefects.fromJson(v)); + if (json['faxes'] != null) { + faxes = []; + json['faxes'].forEach((v) { + faxes.add(Faxes.fromJson(v)); }); } - if (json['suppliers'] != null) { - suppliers = json['suppliers']; + if (json['addresses'] != null) { + addresses = []; + json['addresses'].forEach((v) { + addresses.add(Addresses.fromJson(v)); + }); + } + if (json['attachments'] != null) { + attachments = []; + json['attachments'].forEach((v) { + attachments.add(Attachments.fromJson(v)); + }); + } + if (json['suppPersons'] != null) { + suppPersons = []; + json['suppPersons'].forEach((v) { + suppPersons.add(SuppPersons.fromJson(v)); + }); + } + if (json['suppTCodes'] != null) { + suppTCodes = []; + json['suppTCodes'].forEach((v) { + suppTCodes.add(SuppTCodes.fromJson(v)); + }); } } - + num id; + String suppliername; + String name; + String website; + String email; + String code; + num suppNo; + num suppStatusId; + num cityId; + String person; + String comment; + num zipcode; + String contact; + List telephones; + List faxes; + List addresses; + List attachments; + List suppPersons; + List suppTCodes; + SupplierModel copyWith({ + num id, + String suppliername, + String name, + String website, + String email, + String code, + num suppNo, + num suppStatusId, + num cityId, + String person, + String comment, + num zipcode, + String contact, + List telephones, + List faxes, + List addresses, + List attachments, + List suppPersons, + List suppTCodes, + }) => + SupplierModel( + id: id ?? this.id, + suppliername: suppliername ?? this.suppliername, + name: name ?? this.name, + website: website ?? this.website, + email: email ?? this.email, + code: code ?? this.code, + suppNo: suppNo ?? this.suppNo, + suppStatusId: suppStatusId ?? this.suppStatusId, + cityId: cityId ?? this.cityId, + person: person ?? this.person, + comment: comment ?? this.comment, + zipcode: zipcode ?? this.zipcode, + contact: contact ?? this.contact, + telephones: telephones ?? this.telephones, + faxes: faxes ?? this.faxes, + addresses: addresses ?? this.addresses, + attachments: attachments ?? this.attachments, + suppPersons: suppPersons ?? this.suppPersons, + suppTCodes: suppTCodes ?? this.suppTCodes, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['assetName'] = assetName; - data['modelDefCode'] = modelDefCode; - data['modelName'] = modelName; - data['manufacturerId'] = manufacturerId; - data['manufacturerName'] = manufacturerName; - data['supplierName'] = supplierName; - data['replacementDate'] = replacementDate; - data['lifeSpan'] = lifeSpan; - if (modelDefRelatedDefects != null) { - data['modelDefRelatedDefects'] = modelDefRelatedDefects.map((v) => v.toJson()).toList(); + final map = {}; + map['id'] = id; + map['suppliername'] = suppliername; + map['name'] = name; + map['website'] = website; + map['email'] = email; + map['code'] = code; + map['suppNo'] = suppNo; + map['suppStatusId'] = suppStatusId; + map['cityId'] = cityId; + map['person'] = person; + map['comment'] = comment; + map['zipcode'] = zipcode; + map['contact'] = contact; + if (telephones != null) { + map['telephones'] = telephones.map((v) => v.toJson()).toList(); } - if (suppliers != null) { - data['suppliers'] = suppliers.map((v) => v.toJson()).toList(); + if (faxes != null) { + map['faxes'] = faxes.map((v) => v.toJson()).toList(); + } + if (addresses != null) { + map['addresses'] = addresses.map((v) => v.toJson()).toList(); + } + if (attachments != null) { + map['attachments'] = attachments.map((v) => v.toJson()).toList(); } - return data; + if (suppPersons != null) { + map['suppPersons'] = suppPersons.map((v) => v.toJson()).toList(); + } + if (suppTCodes != null) { + map['suppTCodes'] = suppTCodes.map((v) => v.toJson()).toList(); + } + return map; } } -class ModelDefRelatedDefects { - int id; - String defectName; - String workPerformed; - String estimatedTime; - - ModelDefRelatedDefects({this.id, this.defectName, this.workPerformed, this.estimatedTime}); +class SuppTCodes { + SuppTCodes({ + this.id, + this.supplierId, + this.codeTypeId, + this.codeValue, + }); - ModelDefRelatedDefects.fromJson(Map json) { + SuppTCodes.fromJson(dynamic json) { id = json['id']; - defectName = json['defectName']; - workPerformed = json['workPerformed']; - estimatedTime = json['estimatedTime']; + supplierId = json['supplierId']; + codeTypeId = json['codeTypeId']; + codeValue = json['codeValue']; } - + num id; + num supplierId; + num codeTypeId; + String codeValue; + SuppTCodes copyWith({ + num id, + num supplierId, + num codeTypeId, + String codeValue, + }) => + SuppTCodes( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + codeTypeId: codeTypeId ?? this.codeTypeId, + codeValue: codeValue ?? this.codeValue, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['defectName'] = defectName; - data['workPerformed'] = workPerformed; - data['estimatedTime'] = estimatedTime; - return data; + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['codeTypeId'] = codeTypeId; + map['codeValue'] = codeValue; + return map; } } -class Site { - int id; - int customerCode; - String custName; - List buildings; - - Site({this.id, this.customerCode, this.custName, this.buildings}); +class SuppPersons { + SuppPersons({ + this.id, + this.supplierId, + this.personName, + this.personRoleId, + this.contact, + this.externalEngCode, + this.email, + }); - Site.fromJson(Map json) { + SuppPersons.fromJson(dynamic json) { id = json['id']; - customerCode = json['customerCode']; - custName = json['custName']; - if (json['buildings'] != null) { - buildings = json['buildings']; - } + supplierId = json['supplierId']; + personName = json['personName']; + personRoleId = json['personRoleId']; + contact = json['contact']; + externalEngCode = json['externalEngCode']; + email = json['email']; } - + num id; + num supplierId; + String personName; + num personRoleId; + String contact; + String externalEngCode; + String email; + SuppPersons copyWith({ + num id, + num supplierId, + String personName, + num personRoleId, + String contact, + String externalEngCode, + String email, + }) => + SuppPersons( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + personName: personName ?? this.personName, + personRoleId: personRoleId ?? this.personRoleId, + contact: contact ?? this.contact, + externalEngCode: externalEngCode ?? this.externalEngCode, + email: email ?? this.email, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['customerCode'] = customerCode; - data['custName'] = custName; + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['personName'] = personName; + map['personRoleId'] = personRoleId; + map['contact'] = contact; + map['externalEngCode'] = externalEngCode; + map['email'] = email; + return map; + } +} + +class Attachments { + Attachments({ + this.id, + this.supplierId, + this.attachmentName, + this.attachmentURL, + }); + + Attachments.fromJson(dynamic json) { + id = json['id']; + supplierId = json['supplierId']; + attachmentName = json['attachmentName']; + attachmentURL = json['attachmentURL']; + } + num id; + num supplierId; + String attachmentName; + String attachmentURL; + Attachments copyWith({ + num id, + num supplierId, + String attachmentName, + String attachmentURL, + }) => + Attachments( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + attachmentName: attachmentName ?? this.attachmentName, + attachmentURL: attachmentURL ?? this.attachmentURL, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['attachmentName'] = attachmentName; + map['attachmentURL'] = attachmentURL; + return map; + } +} + +class Addresses { + Addresses({ + this.id, + this.supplierId, + this.address, + }); + + Addresses.fromJson(dynamic json) { + id = json['id']; + supplierId = json['supplierId']; + address = json['address']; + } + num id; + num supplierId; + String address; + Addresses copyWith({ + num id, + num supplierId, + String address, + }) => + Addresses( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + address: address ?? this.address, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['address'] = address; + return map; + } +} + +class Faxes { + Faxes({ + this.id, + this.supplierId, + this.fax, + }); + + Faxes.fromJson(dynamic json) { + id = json['id']; + supplierId = json['supplierId']; + fax = json['fax']; + } + num id; + num supplierId; + String fax; + Faxes copyWith({ + num id, + num supplierId, + String fax, + }) => + Faxes( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + fax: fax ?? this.fax, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['fax'] = fax; + return map; + } +} + +class Telephones { + Telephones({ + this.id, + this.supplierId, + this.telephone, + }); + + Telephones.fromJson(dynamic json) { + id = json['id']; + supplierId = json['supplierId']; + telephone = json['telephone']; + } + num id; + num supplierId; + String telephone; + Telephones copyWith({ + num id, + num supplierId, + String telephone, + }) => + Telephones( + id: id ?? this.id, + supplierId: supplierId ?? this.supplierId, + telephone: telephone ?? this.telephone, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['supplierId'] = supplierId; + map['telephone'] = telephone; + return map; + } +} + +class AttachmentsWorkOrder { + AttachmentsWorkOrder({ + this.id, + this.name, + }); + + AttachmentsWorkOrder.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + } + num id; + String name; + AttachmentsWorkOrder copyWith({ + num id, + String name, + }) => + AttachmentsWorkOrder( + id: id ?? this.id, + name: name ?? this.name, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + return map; + } +} + +class SparePartsWorkOrders { + SparePartsWorkOrders({ + this.id, + this.sparePart, + this.qty, + this.returnQty, + this.installQty, + }); + + SparePartsWorkOrders.fromJson(dynamic json) { + id = json['id']; + sparePart = json['sparePart'] != null ? SparePart.fromJson(json['sparePart']) : null; + qty = json['qty']; + returnQty = json['returnQty']; + installQty = json['installQty']; + } + num id; + SparePart sparePart; + num qty; + num returnQty; + num installQty; + SparePartsWorkOrders copyWith({ + num id, + SparePart sparePart, + num qty, + num returnQty, + num installQty, + }) => + SparePartsWorkOrders( + id: id ?? this.id, + sparePart: sparePart ?? this.sparePart, + qty: qty ?? this.qty, + returnQty: returnQty ?? this.returnQty, + installQty: installQty ?? this.installQty, + ); + Map toJson() { + final map = {}; + map['id'] = id; + if (sparePart != null) { + map['sparePart'] = sparePart.toJson(); + } + map['qty'] = qty; + map['returnQty'] = returnQty; + map['installQty'] = installQty; + return map; + } +} + +class SparePart { + SparePart({ + this.id, + this.partNo, + this.partName, + }); + + SparePart.fromJson(dynamic json) { + id = json['id']; + partNo = json['partNo']; + partName = json['partName']; + } + num id; + String partNo; + String partName; + SparePart copyWith({ + num id, + String partNo, + String partName, + }) => + SparePart( + id: id ?? this.id, + partNo: partNo ?? this.partNo, + partName: partName ?? this.partName, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['partNo'] = partNo; + map['partName'] = partName; + return map; + } +} + +class FaultDescription { + FaultDescription({ + this.id, + this.defectName, + this.workPerformed, + this.estimatedTime, + }); + + FaultDescription.fromJson(dynamic json) { + id = json['id']; + defectName = json['defectName']; + workPerformed = json['workPerformed']; + estimatedTime = json['estimatedTime']; + } + num id; + String defectName; + String workPerformed; + String estimatedTime; + FaultDescription copyWith({ + num id, + String defectName, + String workPerformed, + String estimatedTime, + }) => + FaultDescription( + id: id ?? this.id, + defectName: defectName ?? this.defectName, + workPerformed: workPerformed ?? this.workPerformed, + estimatedTime: estimatedTime ?? this.estimatedTime, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['defectName'] = defectName; + map['workPerformed'] = workPerformed; + map['estimatedTime'] = estimatedTime; + return map; + } +} + +class Reason { + Reason({ + this.id, + this.name, + this.value, + }); + + Reason.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + Reason copyWith({ + num id, + String name, + num value, + }) => + Reason( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class ContactPersonWorkOrders { + ContactPersonWorkOrders({ + this.id, + this.employeeCode, + this.name, + this.telephone, + this.job, + this.email, + this.land, + this.contactUserId, + }); + + ContactPersonWorkOrders.fromJson(dynamic json) { + id = json['id']; + employeeCode = json['employeeCode']; + name = json['name']; + telephone = json['telephone']; + job = json['job']; + email = json['email']; + land = json['land']; + contactUserId = json['contactUserId']; + } + num id; + String employeeCode; + String name; + String telephone; + String job; + String email; + String land; + String contactUserId; + ContactPersonWorkOrders copyWith({ + num id, + String employeeCode, + String name, + String telephone, + String job, + String email, + String land, + String contactUserId, + }) => + ContactPersonWorkOrders( + id: id ?? this.id, + employeeCode: employeeCode ?? this.employeeCode, + name: name ?? this.name, + telephone: telephone ?? this.telephone, + job: job ?? this.job, + email: email ?? this.email, + land: land ?? this.land, + contactUserId: contactUserId ?? this.contactUserId, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['employeeCode'] = employeeCode; + map['name'] = name; + map['telephone'] = telephone; + map['job'] = job; + map['email'] = email; + map['land'] = land; + map['contactUserId'] = contactUserId; + return map; + } +} + +class AssistantEmployees { + AssistantEmployees({ + this.id, + this.user, + }); + + AssistantEmployees.fromJson(dynamic json) { + id = json['id']; + user = json['user'] != null ? UserModel.fromJson(json['user']) : null; + } + num id; + UserModel user; + AssistantEmployees copyWith({ + num id, + UserModel user, + }) => + AssistantEmployees( + id: id ?? this.id, + user: user ?? this.user, + ); + Map toJson() { + final map = {}; + map['id'] = id; + if (user != null) { + map['user'] = user.toJson(); + } + return map; + } +} + +class UserModel { + UserModel({ + this.id, + this.name, + }); + + UserModel.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + } + String id; + String name; + UserModel copyWith({ + String id, + String name, + }) => + UserModel( + id: id ?? this.id, + name: name ?? this.name, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + return map; + } +} + +class AssignedEmployee { + AssignedEmployee({ + this.id, + this.name, + }); + + AssignedEmployee.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + } + String id; + String name; + AssignedEmployee copyWith({ + String id, + String name, + }) => + AssignedEmployee( + id: id ?? this.id, + name: name ?? this.name, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + return map; + } +} + +class CallRequest { + CallRequest({ + this.id, + this.callNo, + this.callComments, + this.asset, + this.assignedEmployee, + this.callSiteContactPerson, + this.status, + this.callLastSituation, + this.defectType, + this.firstAction, + this.assetType, + }); + + CallRequest.fromJson(dynamic json) { + id = json['id']; + callNo = json['callNo']; + callComments = json['callComments']; + asset = json['asset'] != null ? Asset.fromJson(json['asset']) : null; + assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null; + if (json['callSiteContactPerson'] != null) { + callSiteContactPerson = []; + json['callSiteContactPerson'].forEach((v) { + callSiteContactPerson.add(CallSiteContactPerson.fromJson(v)); + }); + } + status = json['status'] != null ? Status.fromJson(json['status']) : null; + callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : null; + defectType = json['defectType'] != null ? DefectType.fromJson(json['defectType']) : null; + firstAction = json['firstAction'] != null ? FirstAction.fromJson(json['firstAction']) : null; + assetType = json['assetType']; + } + num id; + String callNo; + String callComments; + Asset asset; + AssignedEmployee assignedEmployee; + List callSiteContactPerson; + Status status; + Lookup callLastSituation; + DefectType defectType; + FirstAction firstAction; + num assetType; + CallRequest copyWith({ + num id, + String callNo, + String callComments, + Asset asset, + AssignedEmployee assignedEmployee, + List callSiteContactPerson, + Status status, + Lookup callLastSituation, + DefectType defectType, + FirstAction firstAction, + num assetType, + }) => + CallRequest( + id: id ?? this.id, + callNo: callNo ?? this.callNo, + callComments: callComments ?? this.callComments, + asset: asset ?? this.asset, + assignedEmployee: assignedEmployee ?? this.assignedEmployee, + callSiteContactPerson: callSiteContactPerson ?? this.callSiteContactPerson, + status: status ?? this.status, + callLastSituation: callLastSituation ?? this.callLastSituation, + defectType: defectType ?? this.defectType, + firstAction: firstAction ?? this.firstAction, + assetType: assetType ?? this.assetType, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['callNo'] = callNo; + map['callComments'] = callComments; + if (asset != null) { + map['asset'] = asset.toJson(); + } + if (assignedEmployee != null) { + map['assignedEmployee'] = assignedEmployee.toJson(); + } + if (callSiteContactPerson != null) { + map['callSiteContactPerson'] = callSiteContactPerson.map((v) => v.toJson()).toList(); + } + if (status != null) { + map['status'] = status.toJson(); + } + if (callLastSituation != null) { + map['callLastSituation'] = callLastSituation.toMap(); + } + if (defectType != null) { + map['defectType'] = defectType.toJson(); + } + if (firstAction != null) { + map['firstAction'] = firstAction.toJson(); + } + map['assetType'] = assetType; + return map; + } +} + +class FirstAction { + FirstAction({ + this.id, + this.name, + this.value, + }); + + FirstAction.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + FirstAction copyWith({ + num id, + String name, + num value, + }) => + FirstAction( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class DefectType { + DefectType({ + this.id, + this.name, + this.value, + }); + + DefectType.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + DefectType copyWith({ + num id, + String name, + num value, + }) => + DefectType( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class Status { + Status({ + this.id, + this.name, + this.value, + }); + + Status.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + Status copyWith({ + num id, + String name, + num value, + }) => + Status( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class CallSiteContactPerson { + CallSiteContactPerson({ + this.id, + this.employeeCode, + this.name, + this.telephone, + this.job, + this.email, + this.land, + this.contactUserId, + }); + + CallSiteContactPerson.fromJson(dynamic json) { + id = json['id']; + employeeCode = json['employeeCode']; + name = json['name']; + telephone = json['telephone']; + job = json['job']; + email = json['email']; + land = json['land']; + contactUserId = json['contactUserId']; + } + num id; + String employeeCode; + String name; + String telephone; + String job; + String email; + String land; + String contactUserId; + CallSiteContactPerson copyWith({ + num id, + String employeeCode, + String name, + String telephone, + String job, + String email, + String land, + String contactUserId, + }) => + CallSiteContactPerson( + id: id ?? this.id, + employeeCode: employeeCode ?? this.employeeCode, + name: name ?? this.name, + telephone: telephone ?? this.telephone, + job: job ?? this.job, + email: email ?? this.email, + land: land ?? this.land, + contactUserId: contactUserId ?? this.contactUserId, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['employeeCode'] = employeeCode; + map['name'] = name; + map['telephone'] = telephone; + map['job'] = job; + map['email'] = email; + map['land'] = land; + map['contactUserId'] = contactUserId; + return map; + } +} + +class Asset { + 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(dynamic json) { + id = json['id']; + assetSerialNo = json['assetSerialNo']; + systemID = json['systemID']; + assetNumber = json['assetNumber']; + modelDefinition = json['modelDefinition'] != null ? ModelDefinition.fromJson(json['modelDefinition']) : null; + supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null; + ipAddress = json['ipAddress']; + macAddress = json['macAddress']; + portNumber = json['portNumber']; + assetReplace = json['assetReplace'] != null ? AssetReplace.fromJson(json['assetReplace']) : null; + oldAsset = json['oldAsset'] != null ? OldAsset.fromJson(json['oldAsset']) : null; + isParent = json['isParent'] != null ? IsParent.fromJson(json['isParent']) : null; + parentAsset = json['parentAsset'] != null ? ParentAsset.fromJson(json['parentAsset']) : null; + assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null; + site = json['site'] != null ? Site.fromJson(json['site']) : null; + building = json['building'] != null ? Building.fromJson(json['building']) : null; + floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null; + department = json['department'] != null ? Department.fromJson(json['department']) : null; + room = json['room']; + testsDay = json['testsDay']; + purchasingPrice = json['purchasingPrice']; + nbv = json['nbv']; + currency = json['currency'] != null ? Currency.fromJson(json['currency']) : null; + poNo = json['poNo']; + invoiceNumber = json['invoiceNumber']; + invoiceDate = json['invoiceDate']; + replacementDate = json['replacementDate']; + originDepartment = json['originDepartment'] != null ? OriginDepartment.fromJson(json['originDepartment']) : null; + originSite = json['originSite'] != null ? OriginSite.fromJson(json['originSite']) : null; + budgetYear = json['budgetYear']; + lastPOPrice = json['lastPOPrice']; + commissioningStatus = json['commissioningStatus'] != null ? CommissioningStatus.fromJson(json['commissioningStatus']) : null; + productionDate = json['productionDate']; + edd = json['edd']; + technicalInspectionDate = json['technicalInspectionDate']; + deliveryInspectionDate = json['deliveryInspectionDate']; + endUserAcceptanceDate = json['endUserAcceptanceDate']; + receivingCommittee = json['receivingCommittee']; + siteWarrantyMonths = json['siteWarrantyMonths'] != null ? SiteWarrantyMonths.fromJson(json['siteWarrantyMonths']) : null; + extendedWarrantyMonths = json['extendedWarrantyMonths'] != null ? ExtendedWarrantyMonths.fromJson(json['extendedWarrantyMonths']) : null; + remainderWarrantyMonths = json['remainderWarrantyMonths'] != null ? RemainderWarrantyMonths.fromJson(json['remainderWarrantyMonths']) : null; + eomWarrantyMonthsNo = json['eomWarrantyMonthsNo']; + warrantyValue = json['warrantyValue']; + warrantyEndDate = json['warrantyEndDate']; + warrantyContractConditions = json['warrantyContractConditions']; + if (json['technicalGuidanceBooks'] != null) { + technicalGuidanceBooks = []; + json['technicalGuidanceBooks'].forEach((v) { + technicalGuidanceBooks.add(TechnicalGuidanceBooks.fromJson(v)); + }); + } + comment = json['comment']; + tagCode = json['tagCode']; + } + num id; + String assetSerialNo; + String systemID; + String assetNumber; + ModelDefinition modelDefinition; + SupplierModel supplier; + String ipAddress; + String macAddress; + String portNumber; + AssetReplace assetReplace; + OldAsset oldAsset; + IsParent isParent; + ParentAsset parentAsset; + Lookup assetType; + Site site; + Building building; + Floor floor; + Department department; + String room; + num testsDay; + num purchasingPrice; + String nbv; + Currency currency; + String poNo; + String invoiceNumber; + String invoiceDate; + String replacementDate; + OriginDepartment originDepartment; + OriginSite originSite; + num budgetYear; + num lastPOPrice; + CommissioningStatus commissioningStatus; + String productionDate; + String edd; + String technicalInspectionDate; + String deliveryInspectionDate; + String endUserAcceptanceDate; + String receivingCommittee; + SiteWarrantyMonths siteWarrantyMonths; + ExtendedWarrantyMonths extendedWarrantyMonths; + RemainderWarrantyMonths remainderWarrantyMonths; + num eomWarrantyMonthsNo; + num warrantyValue; + String warrantyEndDate; + String warrantyContractConditions; + List technicalGuidanceBooks; + String comment; + String tagCode; + Asset copyWith({ + num id, + String assetSerialNo, + String systemID, + String assetNumber, + ModelDefinition modelDefinition, + SupplierModel supplier, + String ipAddress, + String macAddress, + String portNumber, + AssetReplace assetReplace, + OldAsset oldAsset, + IsParent isParent, + ParentAsset parentAsset, + Lookup assetType, + Site site, + Building building, + Floor floor, + Department department, + String room, + num testsDay, + num purchasingPrice, + String nbv, + Currency currency, + String poNo, + String invoiceNumber, + String invoiceDate, + String replacementDate, + OriginDepartment originDepartment, + OriginSite originSite, + num budgetYear, + num lastPOPrice, + CommissioningStatus commissioningStatus, + String productionDate, + String edd, + String technicalInspectionDate, + String deliveryInspectionDate, + String endUserAcceptanceDate, + String receivingCommittee, + SiteWarrantyMonths siteWarrantyMonths, + ExtendedWarrantyMonths extendedWarrantyMonths, + RemainderWarrantyMonths remainderWarrantyMonths, + num eomWarrantyMonthsNo, + num warrantyValue, + String warrantyEndDate, + String warrantyContractConditions, + List technicalGuidanceBooks, + String comment, + String tagCode, + }) => + Asset( + id: id ?? this.id, + assetSerialNo: assetSerialNo ?? this.assetSerialNo, + systemID: systemID ?? this.systemID, + assetNumber: assetNumber ?? this.assetNumber, + modelDefinition: modelDefinition ?? this.modelDefinition, + supplier: supplier ?? this.supplier, + ipAddress: ipAddress ?? this.ipAddress, + macAddress: macAddress ?? this.macAddress, + portNumber: portNumber ?? this.portNumber, + assetReplace: assetReplace ?? this.assetReplace, + oldAsset: oldAsset ?? this.oldAsset, + isParent: isParent ?? this.isParent, + parentAsset: parentAsset ?? this.parentAsset, + assetType: assetType ?? this.assetType, + site: site ?? this.site, + building: building ?? this.building, + floor: floor ?? this.floor, + department: department ?? this.department, + room: room ?? this.room, + testsDay: testsDay ?? this.testsDay, + purchasingPrice: purchasingPrice ?? this.purchasingPrice, + nbv: nbv ?? this.nbv, + currency: currency ?? this.currency, + poNo: poNo ?? this.poNo, + invoiceNumber: invoiceNumber ?? this.invoiceNumber, + invoiceDate: invoiceDate ?? this.invoiceDate, + replacementDate: replacementDate ?? this.replacementDate, + originDepartment: originDepartment ?? this.originDepartment, + originSite: originSite ?? this.originSite, + budgetYear: budgetYear ?? this.budgetYear, + lastPOPrice: lastPOPrice ?? this.lastPOPrice, + commissioningStatus: commissioningStatus ?? this.commissioningStatus, + productionDate: productionDate ?? this.productionDate, + edd: edd ?? this.edd, + technicalInspectionDate: technicalInspectionDate ?? this.technicalInspectionDate, + deliveryInspectionDate: deliveryInspectionDate ?? this.deliveryInspectionDate, + endUserAcceptanceDate: endUserAcceptanceDate ?? this.endUserAcceptanceDate, + receivingCommittee: receivingCommittee ?? this.receivingCommittee, + siteWarrantyMonths: siteWarrantyMonths ?? this.siteWarrantyMonths, + extendedWarrantyMonths: extendedWarrantyMonths ?? this.extendedWarrantyMonths, + remainderWarrantyMonths: remainderWarrantyMonths ?? this.remainderWarrantyMonths, + eomWarrantyMonthsNo: eomWarrantyMonthsNo ?? this.eomWarrantyMonthsNo, + warrantyValue: warrantyValue ?? this.warrantyValue, + warrantyEndDate: warrantyEndDate ?? this.warrantyEndDate, + warrantyContractConditions: warrantyContractConditions ?? this.warrantyContractConditions, + technicalGuidanceBooks: technicalGuidanceBooks ?? this.technicalGuidanceBooks, + comment: comment ?? this.comment, + tagCode: tagCode ?? this.tagCode, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['assetSerialNo'] = assetSerialNo; + map['systemID'] = systemID; + map['assetNumber'] = assetNumber; + if (modelDefinition != null) { + map['modelDefinition'] = modelDefinition.toJson(); + } + if (supplier != null) { + map['supplier'] = supplier.toJson(); + } + map['ipAddress'] = ipAddress; + map['macAddress'] = macAddress; + map['portNumber'] = portNumber; + if (assetReplace != null) { + map['assetReplace'] = assetReplace.toJson(); + } + if (oldAsset != null) { + map['oldAsset'] = oldAsset.toJson(); + } + if (isParent != null) { + map['isParent'] = isParent.toJson(); + } + if (parentAsset != null) { + map['parentAsset'] = parentAsset.toJson(); + } + if (assetType != null) { + map['assetType'] = assetType.toMap(); + } + if (site != null) { + map['site'] = site.toJson(); + } + if (building != null) { + map['building'] = building.toJson(); + } + if (floor != null) { + map['floor'] = floor.toJson(); + } + if (department != null) { + map['department'] = department.toJson(); + } + map['room'] = room; + map['testsDay'] = testsDay; + map['purchasingPrice'] = purchasingPrice; + map['nbv'] = nbv; + if (currency != null) { + map['currency'] = currency.toJson(); + } + map['poNo'] = poNo; + map['invoiceNumber'] = invoiceNumber; + map['invoiceDate'] = invoiceDate; + map['replacementDate'] = replacementDate; + if (originDepartment != null) { + map['originDepartment'] = originDepartment.toJson(); + } + if (originSite != null) { + map['originSite'] = originSite.toJson(); + } + map['budgetYear'] = budgetYear; + map['lastPOPrice'] = lastPOPrice; + if (commissioningStatus != null) { + map['commissioningStatus'] = commissioningStatus.toJson(); + } + map['productionDate'] = productionDate; + map['edd'] = edd; + map['technicalInspectionDate'] = technicalInspectionDate; + map['deliveryInspectionDate'] = deliveryInspectionDate; + map['endUserAcceptanceDate'] = endUserAcceptanceDate; + map['receivingCommittee'] = receivingCommittee; + if (siteWarrantyMonths != null) { + map['siteWarrantyMonths'] = siteWarrantyMonths.toJson(); + } + if (extendedWarrantyMonths != null) { + map['extendedWarrantyMonths'] = extendedWarrantyMonths.toJson(); + } + if (remainderWarrantyMonths != null) { + map['remainderWarrantyMonths'] = remainderWarrantyMonths.toJson(); + } + map['eomWarrantyMonthsNo'] = eomWarrantyMonthsNo; + map['warrantyValue'] = warrantyValue; + map['warrantyEndDate'] = warrantyEndDate; + map['warrantyContractConditions'] = warrantyContractConditions; + if (technicalGuidanceBooks != null) { + map['technicalGuidanceBooks'] = technicalGuidanceBooks.map((v) => v.toJson()).toList(); + } + map['comment'] = comment; + map['tagCode'] = tagCode; + return map; + } +} + +class TechnicalGuidanceBooks { + TechnicalGuidanceBooks({ + this.id, + this.guidanceBook, + }); + + TechnicalGuidanceBooks.fromJson(dynamic json) { + id = json['id']; + guidanceBook = json['guidanceBook'] != null ? GuidanceBook.fromJson(json['guidanceBook']) : null; + } + num id; + GuidanceBook guidanceBook; + TechnicalGuidanceBooks copyWith({ + num id, + GuidanceBook guidanceBook, + }) => + TechnicalGuidanceBooks( + id: id ?? this.id, + guidanceBook: guidanceBook ?? this.guidanceBook, + ); + Map toJson() { + final map = {}; + map['id'] = id; + if (guidanceBook != null) { + map['guidanceBook'] = guidanceBook.toJson(); + } + return map; + } +} + +class GuidanceBook { + GuidanceBook({ + this.id, + this.name, + this.value, + }); + + GuidanceBook.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + GuidanceBook copyWith({ + num id, + String name, + num value, + }) => + GuidanceBook( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class RemainderWarrantyMonths { + RemainderWarrantyMonths({ + this.id, + this.name, + this.value, + }); + + RemainderWarrantyMonths.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + RemainderWarrantyMonths copyWith({ + num id, + String name, + num value, + }) => + RemainderWarrantyMonths( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class ExtendedWarrantyMonths { + ExtendedWarrantyMonths({ + this.id, + this.name, + this.value, + }); + + ExtendedWarrantyMonths.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + ExtendedWarrantyMonths copyWith({ + num id, + String name, + num value, + }) => + ExtendedWarrantyMonths( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class SiteWarrantyMonths { + SiteWarrantyMonths({ + this.id, + this.name, + this.value, + }); + + SiteWarrantyMonths.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + SiteWarrantyMonths copyWith({ + num id, + String name, + num value, + }) => + SiteWarrantyMonths( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class CommissioningStatus { + CommissioningStatus({ + this.id, + this.name, + this.value, + }); + + CommissioningStatus.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + CommissioningStatus copyWith({ + num id, + String name, + num value, + }) => + CommissioningStatus( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class OriginSite { + OriginSite({ + this.id, + this.customerCode, + this.custName, + this.buildings, + }); + + OriginSite.fromJson(dynamic json) { + id = json['id']; + customerCode = json['customerCode']; + custName = json['custName']; + if (json['buildings'] != null) { + buildings = []; + json['buildings'].forEach((v) { + buildings.add(Buildings.fromJson(v)); + }); + } + } + num id; + num customerCode; + String custName; + List buildings; + OriginSite copyWith({ + num id, + num customerCode, + String custName, + List buildings, + }) => + OriginSite( + id: id ?? this.id, + customerCode: customerCode ?? this.customerCode, + custName: custName ?? this.custName, + buildings: buildings ?? this.buildings, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['customerCode'] = customerCode; + map['custName'] = custName; + if (buildings != null) { + map['buildings'] = buildings.map((v) => v.toJson()).toList(); + } + return map; + } +} + +class Buildings { + Buildings({ + this.id, + this.name, + this.value, + this.floors, + }); + + Buildings.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + if (json['floors'] != null) { + floors = []; + json['floors'].forEach((v) { + floors.add(Floors.fromJson(v)); + }); + } + } + num id; + String name; + num value; + List floors; + Buildings copyWith({ + num id, + String name, + num value, + List floors, + }) => + Buildings( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + floors: floors ?? this.floors, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + if (floors != null) { + map['floors'] = floors.map((v) => v.toJson()).toList(); + } + return map; + } +} + +class Floors { + Floors({ + this.id, + this.name, + this.value, + this.departments, + }); + + Floors.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + if (json['departments'] != null) { + departments = []; + json['departments'].forEach((v) { + departments.add(Departments.fromJson(v)); + }); + } + } + num id; + String name; + num value; + List departments; + Floors copyWith({ + num id, + String name, + num value, + List departments, + }) => + Floors( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + departments: departments ?? this.departments, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + if (departments != null) { + map['departments'] = departments.map((v) => v.toJson()).toList(); + } + return map; + } +} + +class Departments { + Departments({ + this.id, + this.name, + }); + + Departments.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + } + num id; + String name; + Departments copyWith({ + num id, + String name, + }) => + Departments( + id: id ?? this.id, + name: name ?? this.name, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + return map; + } +} + +class OriginDepartment { + OriginDepartment({ + this.id, + this.departmentName, + this.departmentCode, + this.ntCode, + }); + + OriginDepartment.fromJson(dynamic json) { + id = json['id']; + departmentName = json['departmentName']; + departmentCode = json['departmentCode']; + ntCode = json['ntCode']; + } + num id; + String departmentName; + String departmentCode; + String ntCode; + OriginDepartment copyWith({ + num id, + String departmentName, + String departmentCode, + String ntCode, + }) => + OriginDepartment( + id: id ?? this.id, + departmentName: departmentName ?? this.departmentName, + departmentCode: departmentCode ?? this.departmentCode, + ntCode: ntCode ?? this.ntCode, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['departmentName'] = departmentName; + map['departmentCode'] = departmentCode; + map['ntCode'] = ntCode; + return map; + } +} + +class Currency { + Currency({ + this.id, + this.name, + this.value, + }); + + Currency.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + Currency copyWith({ + num id, + String name, + num value, + }) => + Currency( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class Department { + Department({ + this.id, + this.departmentName, + this.departmentCode, + this.ntCode, + }); + + Department.fromJson(dynamic json) { + id = json['id']; + departmentName = json['departmentName']; + departmentCode = json['departmentCode']; + ntCode = json['ntCode']; + } + num id; + String departmentName; + String departmentCode; + String ntCode; + Department copyWith({ + num id, + String departmentName, + String departmentCode, + String ntCode, + }) => + Department( + id: id ?? this.id, + departmentName: departmentName ?? this.departmentName, + departmentCode: departmentCode ?? this.departmentCode, + ntCode: ntCode ?? this.ntCode, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['departmentName'] = departmentName; + map['departmentCode'] = departmentCode; + map['ntCode'] = ntCode; + return map; + } +} + +class Floor { + Floor({ + this.id, + this.name, + this.value, + }); + + Floor.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + Floor copyWith({ + num id, + String name, + num value, + }) => + Floor( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class Building { + Building({ + this.id, + this.name, + this.value, + }); + + Building.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + Building copyWith({ + num id, + String name, + num value, + }) => + Building( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class Site { + Site({ + this.id, + this.customerCode, + this.custName, + this.buildings, + }); + + Site.fromJson(dynamic json) { + id = json['id']; + customerCode = json['customerCode']; + custName = json['custName']; + if (json['buildings'] != null) { + buildings = []; + json['buildings'].forEach((v) { + buildings.add(Buildings.fromJson(v)); + }); + } + } + num id; + num customerCode; + String custName; + List buildings; + Site copyWith({ + num id, + num customerCode, + String custName, + List buildings, + }) => + Site( + id: id ?? this.id, + customerCode: customerCode ?? this.customerCode, + custName: custName ?? this.custName, + buildings: buildings ?? this.buildings, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['customerCode'] = customerCode; + map['custName'] = custName; if (buildings != null) { - data['buildings'] = buildings.map((v) => v.toJson()).toList(); + map['buildings'] = buildings.map((v) => v.toJson()).toList(); } - return data; + return map; } } -class AssignedEmployee { - String id; +class ParentAsset { + ParentAsset({ + this.id, + this.assetSerialNo, + this.assetNumber, + this.tagCode, + this.systemId, + }); + + ParentAsset.fromJson(dynamic json) { + id = json['id']; + assetSerialNo = json['assetSerialNo']; + assetNumber = json['assetNumber']; + tagCode = json['tagCode']; + systemId = json['systemId']; + } + num id; + String assetSerialNo; + String assetNumber; + String tagCode; + String systemId; + ParentAsset copyWith({ + num id, + String assetSerialNo, + String assetNumber, + String tagCode, + String systemId, + }) => + ParentAsset( + id: id ?? this.id, + assetSerialNo: assetSerialNo ?? this.assetSerialNo, + assetNumber: assetNumber ?? this.assetNumber, + tagCode: tagCode ?? this.tagCode, + systemId: systemId ?? this.systemId, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['assetSerialNo'] = assetSerialNo; + map['assetNumber'] = assetNumber; + map['tagCode'] = tagCode; + map['systemId'] = systemId; + return map; + } +} + +class IsParent { + IsParent({ + this.id, + this.name, + this.value, + }); + + IsParent.fromJson(dynamic json) { + id = json['id']; + name = json['name']; + value = json['value']; + } + num id; String name; + num value; + IsParent copyWith({ + num id, + String name, + num value, + }) => + IsParent( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class OldAsset { + OldAsset({ + this.id, + this.assetSerialNo, + this.assetNumber, + this.tagCode, + this.systemId, + }); + + OldAsset.fromJson(dynamic json) { + id = json['id']; + assetSerialNo = json['assetSerialNo']; + assetNumber = json['assetNumber']; + tagCode = json['tagCode']; + systemId = json['systemId']; + } + num id; + String assetSerialNo; + String assetNumber; + String tagCode; + String systemId; + OldAsset copyWith({ + num id, + String assetSerialNo, + String assetNumber, + String tagCode, + String systemId, + }) => + OldAsset( + id: id ?? this.id, + assetSerialNo: assetSerialNo ?? this.assetSerialNo, + assetNumber: assetNumber ?? this.assetNumber, + tagCode: tagCode ?? this.tagCode, + systemId: systemId ?? this.systemId, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['assetSerialNo'] = assetSerialNo; + map['assetNumber'] = assetNumber; + map['tagCode'] = tagCode; + map['systemId'] = systemId; + return map; + } +} - AssignedEmployee({this.id, this.name}); +class AssetReplace { + AssetReplace({ + this.id, + this.name, + this.value, + }); - AssignedEmployee.fromJson(Map json) { + AssetReplace.fromJson(dynamic json) { id = json['id']; name = json['name']; + value = json['value']; + } + num id; + String name; + num value; + AssetReplace copyWith({ + num id, + String name, + num value, + }) => + AssetReplace( + id: id ?? this.id, + name: name ?? this.name, + value: value ?? this.value, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['name'] = name; + map['value'] = value; + return map; + } +} + +class Supplier { + Supplier({ + this.id, + this.suppliername, + }); + + Supplier.fromJson(dynamic json) { + id = json['id']; + suppliername = json['suppliername']; + } + num id; + String suppliername; + SupplierModel copyWith({ + num id, + String suppliername, + }) => + SupplierModel( + id: id ?? this.id, + suppliername: suppliername ?? this.suppliername, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['suppliername'] = suppliername; + return map; + } +} + +class ModelDefinition { + ModelDefinition({ + this.id, + this.assetName, + this.modelDefCode, + this.modelName, + this.manufacturerId, + this.manufacturerName, + this.supplierName, + this.replacementDate, + this.essentialEquipement, + this.businessCritical, + this.lifeSpan, + this.modelDefRelatedDefects, + this.suppliers, + }); + + ModelDefinition.fromJson(dynamic 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']; + essentialEquipement = json['essentialEquipement']; + businessCritical = json['businessCritical']; + lifeSpan = json['lifeSpan']; + if (json['modelDefRelatedDefects'] != null) { + modelDefRelatedDefects = []; + json['modelDefRelatedDefects'].forEach((v) { + modelDefRelatedDefects.add(ModelDefRelatedDefects.fromJson(v)); + }); + } + if (json['suppliers'] != null) { + suppliers = []; + json['suppliers'].forEach((v) { + suppliers.add(Suppliers.fromJson(v)); + }); + } + } + num id; + String assetName; + String modelDefCode; + String modelName; + num manufacturerId; + String manufacturerName; + String supplierName; + String replacementDate; + String essentialEquipement; + String businessCritical; + num lifeSpan; + List modelDefRelatedDefects; + List suppliers; + ModelDefinition copyWith({ + num id, + String assetName, + String modelDefCode, + String modelName, + num manufacturerId, + String manufacturerName, + String supplierName, + String replacementDate, + String essentialEquipement, + String businessCritical, + num lifeSpan, + List modelDefRelatedDefects, + List suppliers, + }) => + ModelDefinition( + id: id ?? this.id, + assetName: assetName ?? this.assetName, + modelDefCode: modelDefCode ?? this.modelDefCode, + modelName: modelName ?? this.modelName, + manufacturerId: manufacturerId ?? this.manufacturerId, + manufacturerName: manufacturerName ?? this.manufacturerName, + supplierName: supplierName ?? this.supplierName, + replacementDate: replacementDate ?? this.replacementDate, + essentialEquipement: essentialEquipement ?? this.essentialEquipement, + businessCritical: businessCritical ?? this.businessCritical, + lifeSpan: lifeSpan ?? this.lifeSpan, + modelDefRelatedDefects: modelDefRelatedDefects ?? this.modelDefRelatedDefects, + suppliers: suppliers ?? this.suppliers, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['assetName'] = assetName; + map['modelDefCode'] = modelDefCode; + map['modelName'] = modelName; + map['manufacturerId'] = manufacturerId; + map['manufacturerName'] = manufacturerName; + map['supplierName'] = supplierName; + map['replacementDate'] = replacementDate; + map['essentialEquipement'] = essentialEquipement; + map['businessCritical'] = businessCritical; + map['lifeSpan'] = lifeSpan; + if (modelDefRelatedDefects != null) { + map['modelDefRelatedDefects'] = modelDefRelatedDefects.map((v) => v.toJson()).toList(); + } + if (suppliers != null) { + map['suppliers'] = suppliers.map((v) => v.toJson()).toList(); + } + return map; } +} + +class Suppliers { + Suppliers({ + this.id, + this.suppliername, + }); + + Suppliers.fromJson(dynamic json) { + id = json['id']; + suppliername = json['suppliername']; + } + num id; + String suppliername; + Suppliers copyWith({ + num id, + String suppliername, + }) => + Suppliers( + id: id ?? this.id, + suppliername: suppliername ?? this.suppliername, + ); + Map toJson() { + final map = {}; + map['id'] = id; + map['suppliername'] = suppliername; + return map; + } +} + +class ModelDefRelatedDefects { + ModelDefRelatedDefects({ + this.id, + this.defectName, + this.workPerformed, + this.estimatedTime, + }); + ModelDefRelatedDefects.fromJson(dynamic json) { + id = json['id']; + defectName = json['defectName']; + workPerformed = json['workPerformed']; + estimatedTime = json['estimatedTime']; + } + num id; + String defectName; + String workPerformed; + String estimatedTime; + ModelDefRelatedDefects copyWith({ + num id, + String defectName, + String workPerformed, + String estimatedTime, + }) => + ModelDefRelatedDefects( + id: id ?? this.id, + defectName: defectName ?? this.defectName, + workPerformed: workPerformed ?? this.workPerformed, + estimatedTime: estimatedTime ?? this.estimatedTime, + ); Map toJson() { - final Map data = {}; - data['id'] = id; - data['name'] = name; - return data; + final map = {}; + map['id'] = id; + map['defectName'] = defectName; + map['workPerformed'] = workPerformed; + map['estimatedTime'] = estimatedTime; + return map; } } diff --git a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart index bbf8d7cf..8a26ba40 100644 --- a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart @@ -13,14 +13,10 @@ import '../../../controllers/localization/localization.dart'; import '../../../models/subtitle.dart'; import '../../widgets/buttons/app_back_button.dart'; import '../../widgets/buttons/app_button.dart'; -import '../../widgets/date_and_time/date_picker.dart'; -import '../../widgets/status/report/service_report_equipment_status.dart'; -import '../../widgets/status/report/service_report_reasons.dart'; -import '../../widgets/titles/app_sub_title.dart'; class CreateSubWorkOrderPage extends StatefulWidget { static const id = "/CreateSubWorkOrder"; - final SearchWorkOrders workOrder; + final SearchWorkOrder workOrder; const CreateSubWorkOrderPage({this.workOrder, Key key}) : super(key: key); @override diff --git a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart index f23c6364..afc41b9a 100644 --- a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart @@ -15,7 +15,6 @@ import '../../../controllers/localization/localization.dart'; import '../../app_style/colors.dart'; import '../../widgets/buttons/app_back_button.dart'; import '../../widgets/buttons/app_button.dart'; -import '../../widgets/loaders/app_loading.dart'; import '../../widgets/status/report/service_report_all_users.dart'; import '../../widgets/status/report/service_report_maintenance_situation.dart'; import '../../widgets/status/report/service_report_visit_date_operator.dart'; @@ -31,7 +30,7 @@ class SearchSubWorkOrderPage extends StatefulWidget { class _SearchSubWorkOrderPageState extends State { final GlobalKey _formKey = GlobalKey(); - final SearchWorkOrders _searchWorkOrders = SearchWorkOrders(); + final SearchWorkOrder _searchWorkOrders = SearchWorkOrder(); Subtitle _subtitle; bool _isLoading = false; String _callerId = "", _site = ""; @@ -87,7 +86,9 @@ class _SearchSubWorkOrderPageState extends State { labelText: "Asset S.N.", textInputType: TextInputType.number, onSaved: (value) { - _searchWorkOrders.assetType = value; + if (value != null) { + _searchWorkOrders.assetType = Lookup(name: value); + } }, ), const SizedBox(height: 16), @@ -172,7 +173,7 @@ class _SearchSubWorkOrderPageState extends State { if (_formKey.currentState?.validate() ?? false) {} _formKey.currentState?.save(); final serviceRequestsProvider = Provider.of(context, listen: false); - final List woList = await serviceRequestsProvider.searchForWorkOrders( + final List woList = await serviceRequestsProvider.searchForWorkOrders( _searchWorkOrders, _callerId, _dateOperator, @@ -187,37 +188,41 @@ class _SearchSubWorkOrderPageState extends State { MaterialPageRoute( builder: (context) => Scaffold( body: SafeArea( - child: Column( - children: [ - Container( - color: AColors.primaryColor, - padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Column( + child: Column( + children: [ + Container( + color: AColors.primaryColor, + padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Column( + children: [ + Row( children: [ - Row( - children: [ - ABackButton(), - Expanded( - child: Center( - child: Text( - "Work Order List", - style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), - ), - ), + ABackButton(), + Expanded( + child: Center( + child: Text( + "Work Order List", + style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), ), - const SizedBox( - width: 48, - ) - ], + ), ), + const SizedBox( + width: 48, + ) ], ), - ), - Expanded(child: WorkOrderList(items: woList, nextPage: true, onLazyLoad: (){}, )), - ], + ], + ), ), - ) - ), + Expanded( + child: WorkOrderList( + items: woList, + nextPage: true, + onLazyLoad: () {}, + )), + ], + ), + )), ), ); } else { diff --git a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart index 927a07bd..444207ca 100644 --- a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart @@ -14,7 +14,7 @@ import '../../widgets/buttons/app_button.dart'; import '../../widgets/titles/app_sub_title.dart'; class SparePartsBottomSheet extends StatefulWidget { - final SearchWorkOrders workOrder; + final SearchWorkOrder workOrder; const SparePartsBottomSheet({this.workOrder, Key key}) : super(key: key); @override @@ -23,7 +23,7 @@ class SparePartsBottomSheet extends StatefulWidget { class _SparePartsBottomSheetState extends State { final GlobalKey _formKey = GlobalKey(); - SearchWorkOrders _workOrder; + SearchWorkOrder _workOrder; bool _isLoading = false; @override void initState() { @@ -123,7 +123,7 @@ class _SparePartsBottomSheetState extends State { const SizedBox(height: 8), InkWell( onTap: () { - _workOrder.sparePartsWorkOrders.add(SparePartWorkOrder()); + _workOrder.sparePartsWorkOrders.add(SparePartsWorkOrders()); setState(() {}); }, child: Container( diff --git a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart index 31c8de92..d52ee389 100644 --- a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/service_requests_provider.dart'; -import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/service_request/search_work_order.dart'; import 'package:test_sa/models/subtitle.dart'; import 'package:test_sa/views/widgets/app_text_form_field.dart'; @@ -13,14 +12,12 @@ import 'package:test_sa/views/widgets/status/report/service_report_repair_locati import '../../../controllers/api_routes/http_status_manger.dart'; import '../../../controllers/localization/localization.dart'; -import '../../../models/engineer.dart'; import '../../app_style/sizing.dart'; import '../../widgets/date_and_time/time_picker.dart'; -import '../../widgets/status/report/service_report_all_users.dart'; import '../../widgets/titles/app_sub_title.dart'; class WorkOrderDetailsBottomSheet extends StatefulWidget { - final SearchWorkOrders workOrder; + final SearchWorkOrder workOrder; const WorkOrderDetailsBottomSheet({this.workOrder, Key key}) : super(key: key); @override @@ -29,7 +26,7 @@ class WorkOrderDetailsBottomSheet extends StatefulWidget { class _WorkOrderDetailsBottomSheetState extends State { final GlobalKey _formKey = GlobalKey(); - SearchWorkOrders _workOrder; + SearchWorkOrder _workOrder; bool _isLoading = false; @override @@ -73,14 +70,14 @@ class _WorkOrderDetailsBottomSheetState extends State Validator.isNumeric(value) ? null : _subtitle.requiredWord, @@ -180,18 +180,18 @@ class _WorkOrderDetailsBottomSheetState extends State items; + final List items; final bool nextPage; final Future Function() onLazyLoad; - WorkOrderList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); + const WorkOrderList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); @override Widget build(BuildContext context) { - - if (items.length == 0) { + if (items.isEmpty) { Subtitle subtitle = AppLocalization.of(context).subtitle; return NoItemFound( message: subtitle.noServiceRequestFound, ); } return LazyLoading( - nextPage: nextPage, - onLazyLoad: onLazyLoad, - child: ListView.builder( - itemCount: items.length, - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - itemBuilder: (context, itemIndex) { - return WorkOrderItem(index: itemIndex, onPressed: (model){ - // Navigator.of(context).push(MaterialPageRoute( - // builder: (_) => WorkOrderUpdate(item: model,))); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => CreateSubWorkOrderPage(workOrder:model)), - ); - }, item: items[itemIndex], ); - }), - ); + nextPage: nextPage, + onLazyLoad: onLazyLoad, + child: ListView.builder( + itemCount: items.length, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + itemBuilder: (context, itemIndex) { + return WorkOrderItem( + index: itemIndex, + onPressed: (model) { + // Navigator.of(context).push(MaterialPageRoute( + // builder: (_) => WorkOrderUpdate(item: model,))); + log(model?.toJson()?.toString()); + Navigator.push( + context, + MaterialPageRoute(builder: (context) => CreateSubWorkOrderPage(workOrder: model)), + ); + }, + item: items[itemIndex], + ); + }, + ), + ); } } diff --git a/lib/views/pages/sub_workorder/workorder_update.dart b/lib/views/pages/sub_workorder/workorder_update.dart index 71f589c5..3970aeaa 100644 --- a/lib/views/pages/sub_workorder/workorder_update.dart +++ b/lib/views/pages/sub_workorder/workorder_update.dart @@ -9,9 +9,9 @@ import '../../widgets/buttons/app_back_button.dart'; import '../../widgets/loaders/loading_manager.dart'; class WorkOrderUpdate extends StatefulWidget { - final SearchWorkOrders item; + final SearchWorkOrder item; - const WorkOrderUpdate({@required this.item,Key key}) : super(key: key); + const WorkOrderUpdate({@required this.item, Key key}) : super(key: key); @override State createState() => _WorkOrderUpdateState(); @@ -55,7 +55,9 @@ class _WorkOrderUpdateState extends State { ], ), ), - WorkOrderDetails(item: widget.item,) + WorkOrderDetails( + item: widget.item, + ) ], ), ), diff --git a/lib/views/pages/user/requests/report/future_service_report.dart b/lib/views/pages/user/requests/report/future_service_report.dart index 1a987b0d..466ab8f2 100644 --- a/lib/views/pages/user/requests/report/future_service_report.dart +++ b/lib/views/pages/user/requests/report/future_service_report.dart @@ -15,7 +15,7 @@ import 'edit_service_report.dart'; class FutureServiceReport extends StatefulWidget { final ServiceRequest request; - final SearchWorkOrders workOrder; + final SearchWorkOrder workOrder; const FutureServiceReport({Key key, this.request, this.workOrder}) : super(key: key); diff --git a/lib/views/pages/user/requests/request_details.dart b/lib/views/pages/user/requests/request_details.dart index 03a71d01..70464935 100644 --- a/lib/views/pages/user/requests/request_details.dart +++ b/lib/views/pages/user/requests/request_details.dart @@ -37,7 +37,7 @@ class RequestDetailsPage extends StatelessWidget { Subtitle _subtitle = AppLocalization.of(context).subtitle; UserProvider _userProvider = Provider.of(context); SettingProvider _settingProvider = Provider.of(context); - List workOrders = []; + List workOrders = []; ServiceRequestsProvider _serviceRequestsProvider = Provider.of(context); return DefaultTabController( length: 2, @@ -303,7 +303,7 @@ class RequestDetailsPage extends StatelessWidget { FutureBuilder( future: _serviceRequestsProvider.searchWorkOrders(callId: serviceRequest.requestCode), builder: (context, snap) { - workOrders = snap.data as List; + workOrders = snap.data as List; if (snap.connectionState == ConnectionState.waiting) return Center(child: CircularProgressIndicator()); if (snap.connectionState == ConnectionState.done && (snap.data?.length ?? 0) != 0) { return SingleChildScrollView(