From 934699062673df24de79ff3d57388800d0cc654b Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Wed, 31 May 2023 16:11:34 +0300 Subject: [PATCH] Enhancemnets --- .../api/service_requests_provider.dart | 4 +- lib/models/service_report.dart | 4 + .../report/create_service_report.dart | 171 ++++++++++++------ 3 files changed, 118 insertions(+), 61 deletions(-) diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index 3d0569ba..0019f661 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -314,8 +314,8 @@ class ServiceRequestsProvider extends ChangeNotifier { "currentSituation": null, "repairLocation": report.repairLocation?.toMap(), "reason": report.reason?.toMap(), - "startofWorkTime": report.timer?.startAt?.toIso8601String() ?? "", - "endofWorkTime": report.timer?.endAt?.toIso8601String() ?? "", + "startofWorkTime": report.startDate?.toIso8601String() ?? "", + "endofWorkTime": report.endDate?.toIso8601String() ?? "", "workingHours": report.timer?.durationInSecond, "travelingHours": report.travelingHours, "travelingExpenses": report.travelingExpense ?? 0, diff --git a/lib/models/service_report.dart b/lib/models/service_report.dart index 3e471b7a..60d4e4f2 100644 --- a/lib/models/service_report.dart +++ b/lib/models/service_report.dart @@ -13,6 +13,7 @@ class ServiceReport { String operatingHours; DateTime visitDate; DateTime endDate; + DateTime startDate; Lookup assetType; Lookup callLastSituation; Lookup repairLocation; @@ -69,6 +70,7 @@ class ServiceReport { this.comment, this.repairLocation, this.travelingExpense, + this.startDate, }); Map toMap(ServiceRequest request) { @@ -123,6 +125,8 @@ class ServiceReport { _map["engSignature"] = signatureEngineer; _map["comment"] = comment; _map["travelingExpense"] = travelingExpense; + _map["startofWorkTime"] = startDate; + _map["endofWorkTime"] = endDate; return _map; } diff --git a/lib/views/pages/user/requests/report/create_service_report.dart b/lib/views/pages/user/requests/report/create_service_report.dart index 101be5b2..b2c6cbc2 100644 --- a/lib/views/pages/user/requests/report/create_service_report.dart +++ b/lib/views/pages/user/requests/report/create_service_report.dart @@ -35,6 +35,7 @@ import 'package:test_sa/views/widgets/status/report/service_status.dart'; import 'package:test_sa/views/widgets/timer/app_timer.dart'; import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; +import '../../../../widgets/speech_to_text/speech_to_text.dart'; import '../../../../widgets/status/report/service_report_repair_location.dart'; class CreateServiceReport extends StatefulWidget { @@ -330,6 +331,54 @@ class _CreateServiceReportState extends State with TickerPr SizedBox( height: 8 * AppStyle.getScaleFactor(context), ), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const ASubTitle("Start Date"), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), + ADatePicker( + date: _serviceReport.startDate, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDatePicker: (date) { + _serviceReport.startDate = date; + setState(() {}); + }, + ), + ], + ), + ), + const SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const ASubTitle("End Date"), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), + ADatePicker( + date: _serviceReport.endDate, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDatePicker: (date) { + _serviceReport.endDate = date; + setState(() {}); + }, + ), + ], + ), + ), + ], + ), + SizedBox( + height: 8 * AppStyle.getScaleFactor(context), + ), const ASubTitle("Assigned Employee"), const SizedBox( height: 8, @@ -404,65 +453,69 @@ class _CreateServiceReportState extends State with TickerPr ), ], ), - // 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: [ + 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?.toString(), + textAlign: TextAlign.center, + controller: _faultController, + style: Theme.of(context).textTheme.titleMedium, + validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord, + textInputType: TextInputType.multiline, + onSaved: (value) { + _serviceReport.faultDescriptionId = int.tryParse(value) ?? 0; + }, + ), + 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,