diff --git a/lib/dashboard_latest/dashboard_provider.dart b/lib/dashboard_latest/dashboard_provider.dart index 1a8492d8..fafa23bc 100644 --- a/lib/dashboard_latest/dashboard_provider.dart +++ b/lib/dashboard_latest/dashboard_provider.dart @@ -365,7 +365,7 @@ class CategoryTabs { static List getTabs({required UsersTypes userType, required BuildContext context}) { List tabs = []; if (userType == UsersTypes.engineer) { - + tabs.add(CategoryTabs(label: 'Upcoming', tag: 0, id: 0)); // tabs.add(CategoryTabs('Open', 1)); tabs.add(CategoryTabs(label: 'UnAssigned Open', tag: 1, id: 1)); tabs.add(CategoryTabs(label: 'Assigned Open', tag: 1, id: 2)); diff --git a/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart b/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart index a3181577..82c9e43d 100644 --- a/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart +++ b/lib/models/plan_preventive_visit/plan_preventive_visit_model.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'dart:io'; import 'package:flutter/widgets.dart'; @@ -7,7 +6,6 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/service_request/supplier_details.dart'; import 'package:test_sa/models/timer_model.dart'; -import 'package:test_sa/service_request_latest/utilities/service_request_utils.dart'; class PlanPreventiveVisit { String? id; @@ -48,6 +46,7 @@ class PlanPreventiveVisit { List? preventiveVisitTimers; List? preventiveVisitSuppliers; TimerModel? tbsTimer = TimerModel(); + List? timerModelList = []; PlanPreventiveVisit( {this.id, @@ -86,6 +85,7 @@ class PlanPreventiveVisit { this.preventiveVisitChecklists, this.preventiveVisitKits, this.preventiveVisitTimers, + this.timerModelList, this.preventiveVisitSuppliers}); PlanPreventiveVisit.fromJson(Map json) { @@ -115,7 +115,7 @@ class PlanPreventiveVisit { executionTimeFrame = json['executionTimeFrame']; taskStatus = json['taskStatus'] != null ? Lookup.fromJson(json['taskStatus']) : null; deviceStatus = json['deviceStatus'] != null ? Lookup.fromJson(json['deviceStatus']) : null; - assetAvailability = json['assetAvailability'] != null ? Lookup.fromJson(json['assetAvailability']) : null; + assetAvailability = json['assetAvailability'] != null ? Lookup.fromJson(json['assetAvailability']) : null; safety = json['safety'] != null ? Lookup.fromJson(json['safety']) : null; engSignature = json['engSignature']; nurseSignature = json['nurseSignature']; @@ -124,7 +124,6 @@ class PlanPreventiveVisit { json['preventiveVisitAttachments'].forEach((v) { preventiveVisitAttachments!.add(PreventiveVisitAttachments.fromJson(v)); }); - } if (json['preventiveVisitCalibrations'] != null) { preventiveVisitCalibrations = []; @@ -218,7 +217,6 @@ class PlanPreventiveVisit { // data['nurseSignature'] = nurseSignature; if (preventiveVisitAttachments != null) { - data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toJson()).toList(); } if (preventiveVisitCalibrations != null) { diff --git a/lib/views/pages/user/ppm/ppm_details_page.dart b/lib/views/pages/user/ppm/ppm_details_page.dart index d04696bd..d73a16c1 100644 --- a/lib/views/pages/user/ppm/ppm_details_page.dart +++ b/lib/views/pages/user/ppm/ppm_details_page.dart @@ -110,6 +110,7 @@ class _PpmDetailsPageState extends State { AppFilledButton( onPressed: () async { await Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdatePpm(ppm: null, planPreventiveVisit: planPreventiveVisit, details: widget.request))); + getVisitData(); }, label: context.translation.updateRequest, ).paddingAll(16) diff --git a/lib/views/pages/user/ppm/update_ppm/update_ppm.dart b/lib/views/pages/user/ppm/update_ppm/update_ppm.dart index 1cabdd30..73c54a40 100644 --- a/lib/views/pages/user/ppm/update_ppm/update_ppm.dart +++ b/lib/views/pages/user/ppm/update_ppm/update_ppm.dart @@ -52,7 +52,20 @@ class _UpdatePpmState extends State with SingleTickerProviderStateMix } log('data i got is ${ppmProvider.planPreventiveVisit?.toJson(status: status)}'); - await ppmProvider.updateVisitByEngineer(status: status).whenComplete((){ + ppmProvider.planPreventiveVisit?.preventiveVisitTimers = ppmProvider.planPreventiveVisit?.preventiveVisitTimers ?? []; + ppmProvider.planPreventiveVisit?.timerModelList?.forEach((timer) { + int durationInSecond = timer.endAt!.difference(timer.startAt!).inSeconds; + ppmProvider.planPreventiveVisit?.preventiveVisitTimers?.add( + PreventiveVisitTimers( + id: 0, + startDateTime: timer.startAt!.toIso8601String(), // Handle potential null + endDateTime: timer.endAt?.toIso8601String(), // Handle potential null + workingHours: ((durationInSecond) / 60 / 60), + ), + ); + }); + + await ppmProvider.updateVisitByEngineer(status: status).whenComplete(() { // if(status==1){// when click complete then this request remove from the list and status changes to closed.. // // } @@ -157,7 +170,6 @@ class _UpdatePpmState extends State with SingleTickerProviderStateMix 16.width, AppFilledButton( onPressed: () { - if (tabIndex == 0) { _onSubmit(status: 1); return; diff --git a/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart b/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart index a9f2dfc1..12be9735 100644 --- a/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart +++ b/lib/views/pages/user/ppm/update_ppm/wo_info_form.dart @@ -16,9 +16,9 @@ import 'package:test_sa/providers/ppm_service_provider.dart'; import 'package:test_sa/providers/ppm_task_status_provider.dart'; import 'package:test_sa/service_request_latest/utilities/service_request_utils.dart'; import 'package:test_sa/views/widgets/date_and_time/date_picker.dart'; -import 'package:test_sa/views/widgets/e_signature/e_signature.dart'; import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart'; + import '../../../../../models/lookup.dart'; import '../../../../../new_views/common_widgets/app_text_form_field.dart'; import '../../../../../new_views/common_widgets/single_item_drop_down_menu.dart'; @@ -77,12 +77,8 @@ class _WoInfoFormState extends State { '${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120), //need to add in translation it's suggestion from ahmed.. 'Work Order Number: ${widget.planPreventiveVisit.visitNo}'.bodyText2(context).custom(color: AppColor.neutral120), - '${context.translation.from}: ${widget.planPreventiveVisit.fromDate?.toMonthYearFormat}' - .bodyText2(context) - .custom(color: AppColor.neutral120), - '${context.translation.to}: ${widget.planPreventiveVisit.toDate?.toMonthYearFormat}' - .bodyText2(context) - .custom(color: AppColor.neutral120), + '${context.translation.from}: ${widget.planPreventiveVisit.fromDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120), + '${context.translation.to}: ${widget.planPreventiveVisit.toDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120), '${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate != null ? widget.planPreventiveVisit.nextPMDate!.toMonthYearFormat : '-'}' .bodyText2(context) @@ -147,6 +143,7 @@ class _WoInfoFormState extends State { SingleItemDropDownMenu( context: context, + showShadow: false, initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id), title: context.translation.pmTestResult, backgroundColor: AppColor.neutral100, @@ -176,10 +173,9 @@ class _WoInfoFormState extends State { selectedTime.hour, selectedTime.minute, ); - setState(() { - widget.planPreventiveVisit.acutalDateOfVisit = selectedDate; - }); - + setState(() { + widget.planPreventiveVisit.acutalDateOfVisit = selectedDate; + }); } }); }, @@ -202,6 +198,7 @@ class _WoInfoFormState extends State { SingleItemDropDownMenu( context: context, backgroundColor: AppColor.neutral100, + showShadow: false, initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id), title: "Electrical Safety", onSelect: (value) { @@ -214,6 +211,7 @@ class _WoInfoFormState extends State { SingleItemDropDownMenu( context: context, backgroundColor: AppColor.neutral100, + showShadow: false, initialValue: widget.planPreventiveVisit.assetAvailability == null ? null : Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id), @@ -228,6 +226,7 @@ class _WoInfoFormState extends State { SingleItemDropDownMenu( context: context, backgroundColor: AppColor.neutral100, + showShadow: false, initialValue: widget.planPreventiveVisit.typeOfService == null ? null : Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()), @@ -251,6 +250,7 @@ class _WoInfoFormState extends State { AppTextFormField( labelText: context.translation.callComments, backgroundColor: AppColor.neutral100, + showShadow: false, initialValue: (widget.planPreventiveVisit.comments ?? "").toString(), textAlign: TextAlign.center, style: Theme.of(context).textTheme.titleMedium, @@ -304,6 +304,10 @@ class _WoInfoFormState extends State { timerProgress: (isRunning) {}, onChange: (timer) async { widget.planPreventiveVisit.tbsTimer = timer; + if (timer.startAt != null && timer.endAt != null) { + widget.planPreventiveVisit.timerModelList = widget.planPreventiveVisit.timerModelList ?? []; + widget.planPreventiveVisit.timerModelList!.add(timer); + } return true; }, ),