diff --git a/android/app/build.gradle b/android/app/build.gradle index e55e2b22..4f0659df 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -54,22 +54,25 @@ android { } signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] - } +// release { +// keyAlias keystoreProperties['keyAlias'] +// keyPassword keystoreProperties['keyPassword'] +// storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null +// storePassword keystoreProperties['storePassword'] +// } } buildTypes { debug { signingConfig signingConfigs.debug } release { - minifyEnabled true - shrinkResources true - signingConfig signingConfigs.release + signingConfig signingConfigs.debug } +// release { +// minifyEnabled true +// shrinkResources true +// signingConfig signingConfigs.release +// } } } diff --git a/lib/controllers/api_routes/api_manager.dart b/lib/controllers/api_routes/api_manager.dart index 54d0fc0d..3bbfed51 100644 --- a/lib/controllers/api_routes/api_manager.dart +++ b/lib/controllers/api_routes/api_manager.dart @@ -87,7 +87,7 @@ class ApiManager { headers.addAll(_headers); Uri _url = Uri.parse(url); - // print(_url); + print(_url); // print(headers); // log(json.encode(body)); var request = http.Request('PUT', _url); diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index 9fb46d7c..b621caed 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -474,7 +474,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // body["token"] = user.token; // body["job_id"] = request.id; // body["report_id"] = request.reportID; - try { + // try { Map body = report.toMap(request); // body["uid"] = user.id; // body["token"] = user.token; @@ -491,9 +491,10 @@ class ServiceRequestsProvider extends ChangeNotifier { notifyListeners(); } return response.statusCode; - } catch (error) { - return -1; - } + // } catch (error) { + // print(error); + // return -1; + // } } Future updateWorkOrderDetails({@required SearchWorkOrder workOrder}) async { diff --git a/lib/models/service_report.dart b/lib/models/service_report.dart index 3b681d2a..03092c3c 100644 --- a/lib/models/service_report.dart +++ b/lib/models/service_report.dart @@ -17,6 +17,7 @@ class ServiceReport { DateTime startDate; Lookup assetType; Lookup callLastSituation; + Lookup currentSituation; Lookup repairLocation; Engineer engineer; Lookup equipmentStatus; @@ -25,7 +26,7 @@ class ServiceReport { int faultDescriptionId; String workPreformed; - //String workHours; + num workingHours; double travelingHours; String invoiceNumber; String invoiceCode; @@ -40,7 +41,7 @@ class ServiceReport { String comment; Uint8List localNurseSignature; Uint8List localEngineerSignature; - int travelingExpense; + num travelingExpense; String reviewComment; FaultDescription faultDescription; @@ -52,7 +53,7 @@ class ServiceReport { this.equipmentStatus, this.type, this.faultDescriptionId, - //this.workHours, + this.workingHours, this.travelingHours, this.parts, this.engineer, @@ -60,6 +61,7 @@ class ServiceReport { this.reason, this.operatingHours, this.callLastSituation, + this.currentSituation, this.jobSheetNumber, this.image, this.device, @@ -83,7 +85,7 @@ class ServiceReport { if (id != null) _map["id"] = id; if (visitDate != null) _map["visitDate"] = visitDate.toIso8601String(); //if(serviceType != null) _map["service_type"] = serviceType.id.toString(); - if (equipmentStatus != null) _map["status"] = equipmentStatus?.toMap(); + if (equipmentStatus != null) _map["equipmentStatus"] = equipmentStatus?.toMap(); if (type != null) _map["typeOfWO"] = type?.toMap(); if (assetType != null) _map["TypeOfWO"] = assetType?.toMap(); //if(faultDescriptionId != null && faultDescriptionId.isNotEmpty) _map["fault_description"] = faultDescriptionId; @@ -93,17 +95,19 @@ class ServiceReport { _map["endofWorkTime"] = (timer.endAt ?? DateTime.now()).toIso8601String(); _map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5); } - if (travelingHours != null && travelingHours.toString().isNotEmpty) _map["traveling_hours"] = travelingHours; + if (travelingHours != null && travelingHours.toString().isNotEmpty) _map["travelingHours"] = travelingHours; // if(workPreformed != null && workPreformed.isNotEmpty){ // _map["faultDescription"] = { - // //"id":faultDescriptionId ?? 0, + // "id":faultDescriptionId ?? 0, // "workPerformed":workPreformed // }; // } - if (travelingHours != null) _map["traveling_hours"] = travelingHours; - if (workPreformed != null && workPreformed.isNotEmpty) { - _map["faultDescription"] = faultDescription.toJson(); - } + _map["faultDescription"] = {"id": faultDescription?.id ?? 0, "workPerformed": faultDescription?.workPerformed}; + if (travelingHours != null) _map["travelingHours"] = travelingHours; + // if (workingHours != null) _map["workingHours"] = workingHours; + // if (workPreformed != null && workPreformed.isNotEmpty) { + // _map["faultDescription"] = faultDescription.toJson(); + // } if (jobSheetNumber != null && jobSheetNumber.isNotEmpty) _map["job_sheet_no"] = jobSheetNumber; if (parts != null && parts.isNotEmpty) { _map["sparePartsWorkOrders"] = parts.map((e) => e.toJson()).toList(); @@ -122,6 +126,7 @@ class ServiceReport { if (reason != null) _map["reason"] = reason.toMap(); //if(operatingHours != null && operatingHours.isNotEmpty) _map["operation_hours"] = operatingHours; if (callLastSituation != null) _map["calllastSituation"] = callLastSituation.toMap(); + if (currentSituation != null) _map["currentSituation"] = currentSituation.toMap(); //if(image != null) _map["image"] = image; //if(invoiceCode != null) _map["invoice_no"] = invoiceCode; //if(invoiceNumber != null) _map["invoice_code"] = invoiceNumber; @@ -133,15 +138,20 @@ class ServiceReport { _map["nurseSignature"] = signatureNurse; _map["engSignature"] = signatureEngineer; _map["comment"] = comment; - _map["travelingExpense"] = travelingExpense; - _map["startofWorkTime"] = startDate; - _map["endofWorkTime"] = endDate; + _map["travelingExpenses"] = travelingExpense; + _map["startofWorkTime"] = startDate.toIso8601String(); + _map["endofWorkTime"] = endDate.toIso8601String(); _map["workingHours"] = endDate?.difference(startDate)?.inHours ?? 0; _map["reviewComment"] = reviewComment; return _map; } bool validate() { + print("visitDate:$visitDate"); + print("equipmentStatus:$equipmentStatus"); + print("callLastSituation:${callLastSituation.toMap()}"); + print("parts:$parts"); + print("reason:${reason.toMap()}"); if (visitDate == null) return false; //if(serviceType == null) return false; if (equipmentStatus == null) return false; @@ -174,27 +184,34 @@ class ServiceReport { id: id, assetType: Lookup.fromJson(parsedJson["assetType"]), callLastSituation: Lookup.fromJson(parsedJson["calllastSituation"]), + currentSituation: Lookup.fromJson(parsedJson["currentSituation"]), + repairLocation: Lookup.fromJson(parsedJson["repairLocation"]), reason: Lookup.fromJson(parsedJson["reason"]), - equipmentStatus: Lookup.fromJson(parsedJson["status"]), + equipmentStatus: Lookup.fromJson(parsedJson["equipmentStatus"]), type: Lookup.fromJson(parsedJson["typeOfWO"]), - faultDescriptionId: parsedJson["fault_description"], - endDate: DateTime.tryParse(parsedJson["endofWorkTime"]), + faultDescription: parsedJson['faultDescription'] != null ? FaultDescription.fromJson(parsedJson['faultDescription']) : null, + + // faultDescription: parsedJson["faultDescription"], + startDate: DateTime.tryParse(parsedJson["startofWorkTime"]?? ""), + endDate: DateTime.tryParse(parsedJson["endofWorkTime"]??""), //invoiceCode: parsedJson["invoice_code"], //invoiceNumber: parsedJson["invoice_no"], //jobSheetNumber: parsedJson["job_sheet_no"], - operatingHours: parsedJson["workingHours"], + // workingHours: parsedJson["workingHours"], engineer: Engineer.fromJson(parsedJson["assignedEmployee"]), parts: _parts, //quantity: parsedJson["nid"], - travelingHours: parsedJson["traveling_hours"], + travelingHours: parsedJson["travelingHours"], + travelingExpense: parsedJson["travelingExpenses"], visitDate: DateTime.tryParse(parsedJson["visitDate"]), - //workHours: parsedJson["working_hours"], + workingHours: parsedJson["workingHours"], timer: TimerModel( - startAt: DateTime.tryParse(parsedJson["startofWorkTime"]), endAt: DateTime.tryParse(parsedJson["endofWorkTime"]), durationInSecond: ((parsedJson["workingHours"] ?? 0) * 60 * 60).toInt()), + startAt: DateTime.tryParse(parsedJson["startofWorkTime"]??""), endAt: DateTime.tryParse(parsedJson["endofWorkTime"]??""), durationInSecond: ((parsedJson["workingHours"] ?? 0) * 60 * 60).toInt()), //workPreformed: parsedJson["work_performed"], device: Device.fromJson(parsedJson["callRequest"]["asset"]), signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]), signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]), + comment: parsedJson['comment'], reviewComment: parsedJson['reviewComment'], ); } diff --git a/lib/views/pages/user/requests/report/edit_service_report.dart b/lib/views/pages/user/requests/report/edit_service_report.dart index 848fc4f2..0db15bb7 100644 --- a/lib/views/pages/user/requests/report/edit_service_report.dart +++ b/lib/views/pages/user/requests/report/edit_service_report.dart @@ -8,9 +8,12 @@ import 'package:test_sa/controllers/api_routes/http_status_manger.dart'; import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/providers/api/service_requests_provider.dart'; import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart'; +import 'package:test_sa/controllers/providers/api/status_drop_down/report/service_types_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/validator/validator.dart'; +import 'package:test_sa/models/call_request_for_work_order_model.dart'; +import 'package:test_sa/models/engineer.dart'; import 'package:test_sa/models/part.dart'; import 'package:test_sa/models/service_report.dart'; import 'package:test_sa/models/service_request/service_request.dart'; @@ -21,6 +24,7 @@ import 'package:test_sa/views/widgets/app_text_form_field.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart'; import 'package:test_sa/views/widgets/date_and_time/date_picker.dart'; +import 'package:test_sa/views/widgets/date_and_time/time_picker.dart'; import 'package:test_sa/views/widgets/e_signature/e_signature.dart'; import 'package:test_sa/views/widgets/equipment/auto_complete_devices_field.dart'; import 'package:test_sa/views/widgets/images/mini_one_image_picker.dart'; @@ -28,8 +32,11 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/parts/auto_complete_parts_field.dart'; import 'package:test_sa/views/widgets/parts/part_item.dart'; import 'package:test_sa/views/widgets/status/employee/engineers_mune.dart'; +import 'package:test_sa/views/widgets/status/report/service_report_equipment_status.dart'; +import 'package:test_sa/views/widgets/status/report/service_report_fault_description.dart'; import 'package:test_sa/views/widgets/status/report/service_report_last_call.dart'; import 'package:test_sa/views/widgets/status/report/service_report_reasons.dart'; +import 'package:test_sa/views/widgets/status/report/service_report_repair_location.dart'; import 'package:test_sa/views/widgets/status/report/service_report_status.dart'; import 'package:test_sa/views/widgets/status/report/service_report_type.dart'; import 'package:test_sa/views/widgets/status/report/service_status.dart'; @@ -42,6 +49,7 @@ class EditServiceReport extends StatefulWidget { final ServiceReport report; const EditServiceReport({Key key, this.request, this.report}) : super(key: key); + @override _EditServiceReportState createState() => _EditServiceReportState(); } @@ -54,6 +62,7 @@ class _EditServiceReportState extends State with TickerProvid bool _validate = false; ServiceReport _serviceReport; bool _isLoading = false; + bool _showCommentField = false; Subtitle _subtitle; File _image; @@ -62,12 +71,26 @@ class _EditServiceReportState extends State with TickerProvid TextEditingController _faultController = TextEditingController(); TextEditingController _workPreformedController = TextEditingController(); + ServiceStatusProvider _assetTypeProvider; + + CallRequestForWorkOrder _callRequestForWorkOrder; + @override void initState() { _serviceReport = widget.report; super.initState(); } + void getRequestForWorkOrder() async { + _isLoading = true; + setState(() {}); + _callRequestForWorkOrder = await _serviceRequestsProvider.getCallRequestForWorkOrder(callId: widget.request.id); + _serviceReport.engineer = Engineer.fromJson(_callRequestForWorkOrder?.assignedEmployee?.toJson()); + await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + _isLoading = false; + setState(() {}); + } + @override void dispose() { _faultController.dispose(); @@ -80,6 +103,15 @@ class _EditServiceReportState extends State with TickerProvid _userProvider = Provider.of(context); _settingProvider = Provider.of(context); _serviceRequestsProvider = Provider.of(context); + + _assetTypeProvider = Provider.of(context); + if (_callRequestForWorkOrder == null) { + getRequestForWorkOrder(); + } + _serviceReport.assetType = _assetTypeProvider.statuses?.firstWhere( + (element) => element.value == _callRequestForWorkOrder?.assetType, + orElse: () => null, + ); _subtitle = AppLocalization.of(context).subtitle; return Scaffold( key: _scaffoldKey, @@ -94,11 +126,9 @@ class _EditServiceReportState extends State with TickerProvid child: Stack( children: [ ListView( + padding: const EdgeInsets.all(16), children: [ - //AppNameBar(), - const SizedBox( - height: 16, - ), + const SizedBox(height: 16), Center( child: Padding( padding: const EdgeInsets.all(8.0), @@ -108,22 +138,22 @@ class _EditServiceReportState extends State with TickerProvid ), ), ), - Container( - padding: const EdgeInsets.symmetric(horizontal: 16), - margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [ - const BoxShadow( - color: AColors.grey, - offset: Offset(0, -1), - ) - ]), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 8, - ), - Wrap( + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle("Caller Info"), + const SizedBox(height: 8), + Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + margin: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: const [ + BoxShadow( + color: AColors.grey, + offset: Offset(0, -1), + ) + ]), + child: Wrap( spacing: 10, children: [ ASubTitle( @@ -146,186 +176,161 @@ class _EditServiceReportState extends State with TickerProvid ) ], ), - const Divider(), - - // Report type and Reasons - Row( + ), + const SizedBox(height: 8), + ASubTitle("Work Order Details"), + const SizedBox(height: 8), + Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + margin: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [ + const BoxShadow( + color: AColors.grey, + offset: Offset(0, -1), + ) + ]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Report Status - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.reportType), - _validate && _serviceReport.type == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - const SizedBox( - height: 4, - ), - ServiceReportTypeMenu( - initialValue: _serviceReport.type, - onSelect: (status) { - _serviceReport.type = status; - }, - ), - ], - ), - ), - const SizedBox( - width: 8, - ), - // visit date - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.visitDate), - _validate && _serviceReport.visitDate == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - Row( + // Report type and Reasons + Row( + children: [ + // Report Status + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.reportType), + // _validate && _serviceReport.type == null + // ? ASubTitle( + // _subtitle.requiredWord, + // color: Colors.red, + // ) + // : const SizedBox.shrink(), + // const SizedBox( + // height: 4, + // ), + // ServiceReportTypeMenu( + // initialValue: _serviceReport.type, + // onSelect: (status) { + // _serviceReport.type = status; + // }, + // ), + // ], + // ), + // ), + // const SizedBox( + // width: 8, + // ), + // visit date + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: ADatePicker( - date: _serviceReport.visitDate, - from: DateTime.now().subtract(const Duration(days: 365)), - to: DateTime.now().add(const Duration(days: 365)), - onDatePicker: (date) { - _serviceReport.visitDate = date; - setState(() {}); - }, - ), + ASubTitle(_subtitle.visitDate), + _validate && _serviceReport.visitDate == null + ? ASubTitle( + _subtitle.requiredWord, + color: Colors.red, + ) + : const SizedBox.shrink(), + Row( + children: [ + Expanded( + child: ADatePicker( + date: _serviceReport.visitDate, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDatePicker: (date) { + _serviceReport.visitDate = date; + setState(() {}); + }, + ), + ), + ], ), ], ), - ], - ), + ), + ], ), - ], - ), - const SizedBox( - height: 8, - ), - // device sn - Visibility( - visible: true, //widget.report.device == null, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.deviceSN), - _validate && _serviceReport.device?.id == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - AutoCompleteDeviceField( - hospitalId: widget.request.hospitalId, - initialValue: _serviceReport.device, - onPick: (id) { - _serviceReport.device.id = id; - }, - ), - const SizedBox( - height: 8, - ), - ], - ), - ), - const SizedBox( - height: 8, - ), - ASubTitle(_subtitle.serviceType), - _validate && _serviceReport.assetType == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - const SizedBox( - height: 4, - ), - ServiceAssetTypeMenu( - initialValue: _serviceReport.assetType, - onSelect: (status) { - _serviceReport.assetType = status; - }, - ), - const SizedBox( - height: 8, - ), - SizedBox( - height: 8 * AppStyle.getScaleFactor(context), - ), - const ASubTitle("Assign Employee"), - const SizedBox( - height: 8, - ), - _validate && _serviceReport.engineer == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - const SizedBox( - height: 4, - ), - EngineersMenu( - initialValue: _serviceReport.engineer, - onSelect: (engineer) { - _serviceReport.engineer = engineer; - }, - ), - const SizedBox( - height: 8, - ), - // Report status and Service Type - Row( - children: [ - // report status - Expanded( + const SizedBox( + height: 8, + ), + // device sn + Visibility( + visible: widget.request.deviceSerialNumber == null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.reportStatus), - _validate && _serviceReport.equipmentStatus == null + ASubTitle(_subtitle.deviceSN), + _validate && _serviceReport.device?.id == null ? ASubTitle( _subtitle.requiredWord, color: Colors.red, ) : const SizedBox.shrink(), - const SizedBox( - height: 4, - ), - ServiceReportStatusMenu( - report: _serviceReport, - request: widget.request, - onSelect: (status) { - _serviceReport.equipmentStatus = status; + AutoCompleteDeviceField( + hospitalId: widget.request.hospitalId, + initialValue: _serviceReport.device, + onPick: (id) { + _serviceReport.device.id = id; }, ), + const SizedBox(height: 8), ], ), ), + const SizedBox(height: 8), + ASubTitle(_subtitle.serviceType), + _validate && _serviceReport.assetType == null + ? ASubTitle( + _subtitle.requiredWord, + color: Colors.red, + ) + : const SizedBox.shrink(), + const SizedBox( + height: 4, + ), + LoadingManager( + isLoading: _assetTypeProvider.isLoading, + isFailedLoading: _assetTypeProvider.statuses == null, + stateCode: _assetTypeProvider.stateCode, + onRefresh: () async { + _assetTypeProvider.reset(); + await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + _serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere( + (element) => element.value == _callRequestForWorkOrder.assetType, + orElse: () => null, + ); + }, + child: ATextFormField( + initialValue: _serviceReport?.assetType?.name ?? "NULL", + textAlign: TextAlign.center, + enable: false, + style: Theme.of(context).textTheme.titleMedium, + ), + ), + // ServiceAssetTypeMenu( + // initialValue: _serviceReport.assetType, + // onSelect: (status) { + // _serviceReport.assetType = status; + // }, + // ), const SizedBox( - width: 8, + height: 8, ), - Consumer( - builder: (_, provider, __) { - if (provider.isLoading == null) return const SizedBox.shrink(); - return Expanded( + Row( + children: [ + // report status + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.callLastSituation), - _validate && _serviceReport.callLastSituation == null + // ASubTitle(_subtitle.reportStatus), + ASubTitle("Equipment Status"), + _validate && _serviceReport.equipmentStatus == null ? ASubTitle( _subtitle.requiredWord, color: Colors.red, @@ -334,336 +339,667 @@ class _EditServiceReportState extends State with TickerProvid const SizedBox( height: 4, ), - ServiceReportLastCallsMenu( + // ServiceReportStatusMenu( + // report: _serviceReport, + // request: widget.request, + // onSelect: (status) { + // _serviceReport.status = status; + // }, + // ), + ServiceReportEquipmentStatusMenu( report: _serviceReport, + request: widget.request, onSelect: (status) { - if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) { - _serviceReport.callLastSituation = status; - setState(() {}); - } else { - _serviceReport.callLastSituation = status; - } + _serviceReport.equipmentStatus = status; }, - ), + ) ], ), - ); - }, + ), + const SizedBox( + width: 8, + ), + // Provider.of(context).isLoading == null + // ? const SizedBox.shrink(): + // Call's last Situation + Consumer( + builder: (_, provider, __) { + if (provider.isLoading == null) return const SizedBox.shrink(); + return Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.callLastSituation), + _validate && _serviceReport.callLastSituation == null + ? ASubTitle( + _subtitle.requiredWord, + color: Colors.red, + ) + : const SizedBox.shrink(), + const SizedBox(height: 4), + ServiceReportLastCallsMenu( + report: _serviceReport, + onSelect: (status) { + if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) { + _serviceReport.callLastSituation = status; + setState(() {}); + } else { + _serviceReport.callLastSituation = status; + } + }, + ), + ], + ), + ); + }, + ), + ], ), - ], - ), - const SizedBox( - height: 8, - ), - // invoice number & code - _serviceReport.callLastSituation?.value != 12 - ? const SizedBox.shrink() - : Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.invoiceNumber), - const SizedBox( - height: 8, - ), - ATextFormField( - initialValue: _serviceReport?.invoiceNumber, - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle1, - validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, - textInputType: TextInputType.number, - onSaved: (value) { - _serviceReport.invoiceNumber = value; - }, - ), - ], - ), - ), - const SizedBox( - width: 8, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.invoiceCode), - const SizedBox( - height: 4, + if (_showCommentField) + const SizedBox( + height: 8, + ), + if (_showCommentField) + ATextFormField( + initialValue: _serviceReport?.reviewComment, + hintText: "Review Comment", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.multiline, + onSaved: (value) { + _serviceReport.reviewComment = value; + }, + ), + + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), + // const ASubTitle("Assign Employee"), + // const SizedBox( + // height: 8, + // ), + // _validate && _serviceReport.engineer == null + // ? ASubTitle( + // _subtitle.requiredWord, + // color: Colors.red, + // ) + // : const SizedBox.shrink(), + // const SizedBox( + // height: 4, + // ), + // EngineersMenu( + // initialValue: _serviceReport.engineer, + // onSelect: (engineer) { + // _serviceReport.engineer = engineer; + // }, + // ), + // const SizedBox( + // height: 8, + // ), + // Report status and Service Type + // Row( + // children: [ + // // report status + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.reportStatus), + // _validate && _serviceReport.equipmentStatus == null + // ? ASubTitle( + // _subtitle.requiredWord, + // color: Colors.red, + // ) + // : const SizedBox.shrink(), + // const SizedBox( + // height: 4, + // ), + // ServiceReportStatusMenu( + // report: _serviceReport, + // request: widget.request, + // onSelect: (status) { + // _serviceReport.equipmentStatus = status; + // }, + // ), + // ], + // ), + // ), + // const SizedBox( + // width: 8, + // ), + // Consumer( + // builder: (_, provider, __) { + // if (provider.isLoading == null) return const SizedBox.shrink(); + // return Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.callLastSituation), + // _validate && _serviceReport.callLastSituation == null + // ? ASubTitle( + // _subtitle.requiredWord, + // color: Colors.red, + // ) + // : const SizedBox.shrink(), + // const SizedBox( + // height: 4, + // ), + // ServiceReportLastCallsMenu( + // report: _serviceReport, + // onSelect: (status) { + // if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) { + // _serviceReport.callLastSituation = status; + // setState(() {}); + // } else { + // _serviceReport.callLastSituation = status; + // } + // }, + // ), + // ], + // ), + // ); + // }, + // ), + // ], + // ), + const SizedBox( + height: 8, + ), + // invoice number & code + _serviceReport.callLastSituation?.value != 12 + ? const SizedBox.shrink() + : Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.invoiceNumber), + const SizedBox( + height: 8, + ), + ATextFormField( + initialValue: _serviceReport?.invoiceNumber, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.subtitle1, + validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, + textInputType: TextInputType.number, + onSaved: (value) { + _serviceReport.invoiceNumber = value; + }, + ), + ], ), - ATextFormField( - initialValue: _serviceReport?.invoiceCode, - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.subtitle1, - validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, - textInputType: TextInputType.text, - onSaved: (value) { - _serviceReport.invoiceCode = value; - }, + ), + const SizedBox( + width: 8, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.invoiceCode), + const SizedBox( + height: 4, + ), + ATextFormField( + initialValue: _serviceReport?.invoiceCode, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.subtitle1, + validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, + textInputType: TextInputType.text, + onSaved: (value) { + _serviceReport.invoiceCode = value; + }, + ), + ], ), - ], - ), + ), + ], ), - ], - ), - - // const SizedBox(height: 8,), - // Row( - // children: [ - // ASubTitle(_subtitle.faultDescription), - // Expanded( - // child: SizedBox( - // height: 32 * AppStyle.getScaleFactor(context), - // child: SpeechToTextButton( - // controller: _faultController, - // mini: true, - // ), - // ), - // ), - // ], - // ), - // const SizedBox(height: 4,), - // ATextFormField( - // initialValue: _serviceReport?.faultDescriptionId, - // textAlign: TextAlign.center, - // controller: _faultController, - // style: Theme.of(context).textTheme.subtitle1, - // validator: (value) => - // Validator.hasValue(value) - // ? null : _subtitle.requiredWord, - // textInputType: TextInputType.multiline, - // onSaved: (value){ - // _serviceReport.faultDescriptionId = value; - // }, - // ), - // const SizedBox(height: 8,), - // Row( - // children: [ - // ASubTitle(_subtitle.workPreformed), - // Expanded( - // child: SizedBox( - // height: 32 * AppStyle.getScaleFactor(context), - // child: SpeechToTextButton( - // controller: _workPreformedController, - // mini: true, - // ), - // ), - // ), - // ], - // ), - // const SizedBox(height: 4,), - // ATextFormField( - // initialValue: _serviceReport?.workPreformed, - // textAlign: TextAlign.center, - // controller: _workPreformedController, - // style: Theme.of(context).textTheme.subtitle1, - // validator: (value) => - // Validator.hasValue(value) - // ? null : _subtitle.requiredWord, - // textInputType: TextInputType.multiline, - // onSaved: (value){ - // _serviceReport.workPreformed = value; - // }, - // ), - // const SizedBox(height: 8,), - const SizedBox( - height: 8, - ), - Row( - children: [ - // reasons - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.reasons), - const SizedBox( - height: 4, + // const SizedBox(height: 8,), + // Row( + // children: [ + // ASubTitle(_subtitle.faultDescription), + // Expanded( + // child: SizedBox( + // height: 32 * AppStyle.getScaleFactor(context), + // child: SpeechToTextButton( + // controller: _faultController, + // mini: true, + // ), + // ), + // ), + // ], + // ), + // const SizedBox(height: 4,), + // ATextFormField( + // initialValue: _serviceReport?.faultDescriptionId, + // textAlign: TextAlign.center, + // controller: _faultController, + // style: Theme.of(context).textTheme.subtitle1, + // validator: (value) => + // Validator.hasValue(value) + // ? null : _subtitle.requiredWord, + // textInputType: TextInputType.multiline, + // onSaved: (value){ + // _serviceReport.faultDescriptionId = value; + // }, + // ), + // const SizedBox(height: 8,), + // Row( + // children: [ + // ASubTitle(_subtitle.workPreformed), + // Expanded( + // child: SizedBox( + // height: 32 * AppStyle.getScaleFactor(context), + // child: SpeechToTextButton( + // controller: _workPreformedController, + // mini: true, + // ), + // ), + // ), + // ], + // ), + // const SizedBox(height: 4,), + // ATextFormField( + // initialValue: _serviceReport?.workPreformed, + // textAlign: TextAlign.center, + // controller: _workPreformedController, + // style: Theme.of(context).textTheme.subtitle1, + // validator: (value) => + // Validator.hasValue(value) + // ? null : _subtitle.requiredWord, + // textInputType: TextInputType.multiline, + // onSaved: (value){ + // _serviceReport.workPreformed = value; + // }, + // ), + // const SizedBox(height: 8,), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const ASubTitle("Start of Work"), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), + ADateTimePicker( + date: _serviceReport.startDate, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDateTimePicker: (date) { + _serviceReport.startDate = date; + setState(() {}); + }, + ), + ], ), - ServiceReportReasonsMenu( - initialValue: _serviceReport.reason, - onSelect: (status) { - _serviceReport.reason = status; - }, + ), + const SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const ASubTitle("End of Work"), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), + ADateTimePicker( + date: _serviceReport.endDate, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDateTimePicker: (date) { + _serviceReport.endDate = date; + setState(() {}); + }, + ), + ], ), - ], - ), + ), + ], + ), + const SizedBox(height: 8), + ASubTitle(_subtitle.workingHours), + const SizedBox(height: 4), + ATextFormField( + initialValue: null, + textAlign: TextAlign.center, + hintText: _serviceReport.startDate == null + ? "0" + : ((_serviceReport?.endDate?.difference(_serviceReport?.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0", + enable: false, + style: Theme.of(context).textTheme.subtitle1, + validator: (value) => Validator.isNumeric(value) ? null : _subtitle.requiredWord, + textInputType: TextInputType.number, + onSaved: (value) { + // _serviceReport.workHours = value; + }, ), const SizedBox( - width: 8, + height: 8, ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.attachImage), - AMiniOneImagePicker( - //error: _validate && _serviceReport.image == null, - image: _image, - onPick: (image) { - _image = image; - _serviceReport.image = base64Encode(image.readAsBytesSync()); - }, - ), - ], + if (_showCommentField) + const SizedBox( + height: 8, + ), + if (_showCommentField) + ATextFormField( + initialValue: _serviceReport?.reviewComment, + hintText: "Review Comment", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.multiline, + onSaved: (value) { + _serviceReport.reviewComment = value; + }, ), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), ), - ], - ), - const SizedBox( - height: 8, - ), - // Traveling Hours & Working Hours - Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.workingHours), - const SizedBox( - height: 8, + const SizedBox(height: 8), + ASubTitle(_subtitle.faultDescription), + const SizedBox( + height: 4, + ), + ServiceReportFaultDescription( + requestId: widget.request?.id, + initialValue: _serviceReport.faultDescription, + onSelect: (status) { + print("faluttt:${status?.toJson()}"); + _serviceReport.faultDescription = status; + if(mounted) + setState(() {}); + }, + ), + const SizedBox(height: 8), + ASubTitle(_subtitle.workPreformed), + const SizedBox(height: 4), + ATextFormField( + initialValue: _serviceReport?.workPreformed, + textAlign: TextAlign.center, + enable: false, + hintText: _serviceReport.faultDescription?.workPerformed ?? "", + controller: _workPreformedController, + style: Theme.of(context).textTheme.subtitle1, + validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, + textInputType: TextInputType.multiline, + onSaved: (value) { + // _serviceReport.workPreformed = value; + }, + ), + const SizedBox(height: 4), + Row( + children: [ + // reasons + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ASubTitle(_subtitle.reasons), + const SizedBox( + height: 4, + ), + ServiceReportReasonsMenu( + initialValue: _serviceReport.reason, + onSelect: (status) { + _serviceReport.reason = status; + }, + ), + ], ), - Row( + ), + const SizedBox( + width: 8, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: AppTimer( - timer: _serviceReport.timer, - onChange: (timer) async { - _serviceReport.timer = timer; - return true; - }, - ), + ASubTitle(_subtitle.attachImage), + AMiniOneImagePicker( + //error: _validate && _serviceReport.image == null, + image: _image, + onPick: (image) { + _image = image; + _serviceReport.image = base64Encode(image.readAsBytesSync()); + }, ), ], ), - // ATextFormField( - // initialValue: _serviceReport?.workHours, - // textAlign: TextAlign.center, - // hintText: "i.e 3, 3.5, 4", - // style: Theme.of(context).textTheme.subtitle1, - // validator: (value) => - // Validator.isNumeric(value) - // ? null : _subtitle.requiredWord, - // textInputType: TextInputType.number, - // onSaved: (value){ - // _serviceReport.workHours = value; - // }, - // ), - ], - ), + ), + ], ), - // const SizedBox(width: 8,), - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // ASubTitle(_subtitle.travelingHours), - // const SizedBox(height: 4,), - // ATextFormField( - // initialValue: _serviceReport?.travelingHours, - // textAlign: TextAlign.center, - // hintText: "i.e 3, 3.5, 4", - // style: Theme.of(context).textTheme.subtitle1, - // validator: (value) => - // Validator.isNumeric(value) - // ? null : _subtitle.requiredWord, - // textInputType: TextInputType.number, - // onSaved: (value){ - // _serviceReport.travelingHours = value; - // }, + const SizedBox( + height: 8, + ), + const SizedBox(height: 8), + ASubTitle(_subtitle.repairLocation), + const SizedBox(height: 4), + ServiceReportRepairLocation( + initialValue: _serviceReport.repairLocation, + onSelect: (status) { + _serviceReport.repairLocation = status; + }, + ), + const SizedBox(height: 16), + ASubTitle(_subtitle.travelingExpense), + const SizedBox( + height: 4, + ), + ATextFormField( + initialValue: _serviceReport?.travelingExpense?.toString(), + hintText: _subtitle.travelingExpense, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.number, + onSaved: (value) { + if (value != null && value.isEmpty) { + _serviceReport.travelingExpense = int.tryParse(_serviceReport?.travelingExpense?.toString() ?? "") ?? 0; + } else + _serviceReport.travelingExpense = int.tryParse(value) ?? 0; + }, + ), + + const SizedBox(height: 8), + ASubTitle(_subtitle.travelingHours), + const SizedBox(height: 4), + ATextFormField( + initialValue: _serviceReport?.travelingHours?.toString(), + textAlign: TextAlign.center, + hintText: "i.e 3, 3.5, 4", + style: Theme.of(context).textTheme.subtitle1, + // validator: (value) => + // Validator.isNumeric(value) + // ? null : _subtitle.requiredWord, + textInputType: TextInputType.number, + onSaved: (value) { + _serviceReport.travelingHours = double.tryParse(value) ?? 0.0; + }, + ), + // Traveling Hours & Working Hours + // Row( + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.workingHours), + // const SizedBox( + // height: 8, + // ), + // Row( + // children: [ + // Expanded( + // child: AppTimer( + // timer: _serviceReport.timer, + // onChange: (timer) async { + // _serviceReport.timer = timer; + // return true; + // }, + // ), + // ), + // ], + // ), + // // ATextFormField( + // // initialValue: _serviceReport?.workHours, + // // textAlign: TextAlign.center, + // // hintText: "i.e 3, 3.5, 4", + // // style: Theme.of(context).textTheme.subtitle1, + // // validator: (value) => + // // Validator.isNumeric(value) + // // ? null : _subtitle.requiredWord, + // // textInputType: TextInputType.number, + // // onSaved: (value){ + // // _serviceReport.workHours = value; + // // }, + // // ), + // ], + // ), + // ), + // // const SizedBox(width: 8,), + // // Expanded( + // // child: Column( + // // crossAxisAlignment: CrossAxisAlignment.start, + // // children: [ + // // ASubTitle(_subtitle.travelingHours), + // // const SizedBox(height: 4,), + // // ATextFormField( + // // initialValue: _serviceReport?.travelingHours, + // // textAlign: TextAlign.center, + // // hintText: "i.e 3, 3.5, 4", + // // style: Theme.of(context).textTheme.subtitle1, + // // validator: (value) => + // // Validator.isNumeric(value) + // // ? null : _subtitle.requiredWord, + // // textInputType: TextInputType.number, + // // onSaved: (value){ + // // _serviceReport.travelingHours = value; + // // }, + // // ), + // // ], + // // ), + // // ), + // ], + // ), + // const SizedBox( + // height: 8, + // ), + // Operating Hours and Job Sheet Number + // Row( + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.operatingHours), + // const SizedBox(height: 4,), + // ATextFormField( + // initialValue: _serviceReport?.operatingHours, + // textAlign: TextAlign.center, + // hintText: "i.e 3, 3.5, 4", + // style: Theme.of(context).textTheme.subtitle1, + // validator: (value) => + // Validator.isNumeric(value) + // ? null : _subtitle.requiredWord, + // textInputType: TextInputType.number, + // onSaved: (value){ + // _serviceReport.operatingHours = value; + // }, + // ), + // ], + // ), + // ), + // const SizedBox(width: 8,), + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.jobSheetNumber), + // const SizedBox(height: 4,), + // ATextFormField( + // initialValue: _serviceReport?.jobSheetNumber, + // textAlign: TextAlign.center, + // style: Theme.of(context).textTheme.subtitle1, + // textInputType: TextInputType.name, + // onSaved: (value){ + // _serviceReport.jobSheetNumber = value; + // }, + // ), + // ], // ), - // ], - // ), + // ), + // ], // ), + //const SizedBox(height: 8,), + + const SizedBox(height: 8), + ASubTitle(_subtitle.comment), + const SizedBox(height: 4), + ATextFormField( + initialValue: _serviceReport?.comment, + hintText: "Technical Comment", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.multiline, + onSaved: (value) { + _serviceReport.comment = value; + }, + ), + const SizedBox(height: 8), + const ASubTitle("Nurse Signature"), + ESignature( + oldSignature: _serviceReport.signatureNurse, + newSignature: _serviceReport.localNurseSignature, + onSaved: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + _serviceReport.localNurseSignature = signature; + _serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Engineer Signature"), + ESignature( + oldSignature: _serviceReport.signatureEngineer, + newSignature: _serviceReport.localNurseSignature, + onSaved: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + _serviceReport.localNurseSignature = signature; + _serviceReport.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), + const SizedBox( + height: 8, + ), + // Part Number and Quantity ], ), - const SizedBox( - height: 8, - ), - // Operating Hours and Job Sheet Number - // Row( - // children: [ - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // ASubTitle(_subtitle.operatingHours), - // const SizedBox(height: 4,), - // ATextFormField( - // initialValue: _serviceReport?.operatingHours, - // textAlign: TextAlign.center, - // hintText: "i.e 3, 3.5, 4", - // style: Theme.of(context).textTheme.subtitle1, - // validator: (value) => - // Validator.isNumeric(value) - // ? null : _subtitle.requiredWord, - // textInputType: TextInputType.number, - // onSaved: (value){ - // _serviceReport.operatingHours = value; - // }, - // ), - // ], - // ), - // ), - // const SizedBox(width: 8,), - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // ASubTitle(_subtitle.jobSheetNumber), - // const SizedBox(height: 4,), - // ATextFormField( - // initialValue: _serviceReport?.jobSheetNumber, - // textAlign: TextAlign.center, - // style: Theme.of(context).textTheme.subtitle1, - // textInputType: TextInputType.name, - // onSaved: (value){ - // _serviceReport.jobSheetNumber = value; - // }, - // ), - // ], - // ), - // ), - // ], - // ), - //const SizedBox(height: 8,), - const SizedBox( - height: 8, - ), - const ASubTitle("Nurse Signature"), - ESignature( - oldSignature: _serviceReport.signatureNurse, - newSignature: _serviceReport.localNurseSignature, - onChange: (signature) { - if (signature == null || signature.isEmpty) { - return; - } - _serviceReport.localNurseSignature = signature; - _serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Engineer Signature"), - ESignature( - oldSignature: _serviceReport.signatureEngineer, - newSignature: _serviceReport.localNurseSignature, - onChange: (signature) { - if (signature == null || signature.isEmpty) { - return; - } - _serviceReport.localNurseSignature = signature; - _serviceReport.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }, - ), - const SizedBox( - height: 8, - ), - // Part Number and Quantity + ), + ], + ), + ASubTitle("Spare Parts"), + Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + margin: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [ + BoxShadow( + color: AColors.grey, + offset: Offset(0, -1), + ) + ]), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ Row( children: [ Expanded( @@ -713,53 +1049,49 @@ class _EditServiceReportState extends State with TickerProvid ); }), ), - const SizedBox( height: 16, ), ], ), ), - Padding( - padding: const EdgeInsets.all(16.0), - child: AButton( - text: _subtitle.update, - onPressed: () async { - _validate = true; - if (!_formKey.currentState.validate()) { - setState(() {}); - return; - } - if (!_serviceReport.validate()) { - setState(() {}); - return; - } - _formKey.currentState.save(); + AButton( + text: _subtitle.update, + onPressed: () async { + _validate = true; + print("jere1245"); + // if (!_formKey.currentState.validate()) { + // setState(() {}); + // return; + // } + // print("jere124"); + // if (!_serviceReport.validate()) { + // setState(() {}); + // return; + // } + // print("jere14"); + _formKey.currentState.save(); - _isLoading = true; - setState(() {}); + _isLoading = true; + setState(() {}); - int status = await _serviceRequestsProvider.updateServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request); - _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 _serviceRequestsProvider.updateServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request); + _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), + )); + } + }, ), - const SizedBox( - height: 300, - ) ], ), const ABackButton(), 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 466ab8f2..c391b669 100644 --- a/lib/views/pages/user/requests/report/future_service_report.dart +++ b/lib/views/pages/user/requests/report/future_service_report.dart @@ -31,6 +31,8 @@ class _FutureServiceReportState extends State { _userProvider = Provider.of(context); _settingProvider = Provider.of(context); Subtitle _subtitle = AppLocalization.of(context).subtitle; + ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle) + ; return Scaffold( body: FutureBuilder( future: ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle), diff --git a/lib/views/pages/user/requests/request_details.dart b/lib/views/pages/user/requests/request_details.dart index de9cc066..03ef6573 100644 --- a/lib/views/pages/user/requests/request_details.dart +++ b/lib/views/pages/user/requests/request_details.dart @@ -345,7 +345,7 @@ class RequestDetailsPage extends StatelessWidget { title: _subtitle.visitDate, info: workOrders[index].visitDate, ), - RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee.name), + RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee?.name??""), RequestInfoRow( title: _subtitle.assetSN, info: workOrders[index].callRequest.asset.assetSerialNo, diff --git a/lib/views/widgets/status/report/fault_desc_menu.dart b/lib/views/widgets/status/report/fault_desc_menu.dart index 9250c7dd..5229aff5 100644 --- a/lib/views/widgets/status/report/fault_desc_menu.dart +++ b/lib/views/widgets/status/report/fault_desc_menu.dart @@ -26,7 +26,7 @@ class _SingleStatusMenuState extends State { void didUpdateWidget(covariant FaultDescriptionMenu oldWidget) { if (widget.initialStatus != null) { final result = widget.statuses?.where((element) { - return element == widget.initialStatus; + return element.id == widget.initialStatus.id; }); if (result.isNotEmpty) { _selectedStatus = result.first; @@ -44,9 +44,11 @@ class _SingleStatusMenuState extends State { @override void initState() { + if (widget.initialStatus != null) { final result = widget.statuses?.where((element) { - return element == widget.initialStatus; + + return element.id == widget.initialStatus.id; }); if (result.isNotEmpty) _selectedStatus = result.first; if (widget.initialStatus.id != _selectedStatus?.id) { diff --git a/lib/views/widgets/status/report/service_report_equipment_status.dart b/lib/views/widgets/status/report/service_report_equipment_status.dart index 1af9ac9c..95182977 100644 --- a/lib/views/widgets/status/report/service_report_equipment_status.dart +++ b/lib/views/widgets/status/report/service_report_equipment_status.dart @@ -63,7 +63,7 @@ class _ServiceReportEquipmentStatusMenuState extends State(context); + print("report?.callLastSituation:${report?.callLastSituation?.toMap()}"); return LoadingManager( isLoading: _menuProvider.isLoading, isFailedLoading: _menuProvider.calls == null,