ppm timer fix.

design_3.0_latest
Sikander Saleem 8 months ago
parent 58c0f176a6
commit 1893b45dc9

@ -365,7 +365,7 @@ class CategoryTabs {
static List<CategoryTabs> getTabs({required UsersTypes userType, required BuildContext context}) {
List<CategoryTabs> 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));

@ -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>? preventiveVisitTimers;
List<PreventiveVisitSuppliers>? preventiveVisitSuppliers;
TimerModel? tbsTimer = TimerModel();
List<TimerModel>? timerModelList = [];
PlanPreventiveVisit(
{this.id,
@ -86,6 +85,7 @@ class PlanPreventiveVisit {
this.preventiveVisitChecklists,
this.preventiveVisitKits,
this.preventiveVisitTimers,
this.timerModelList,
this.preventiveVisitSuppliers});
PlanPreventiveVisit.fromJson(Map<String, dynamic> 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 = <PreventiveVisitCalibrations>[];
@ -218,7 +217,6 @@ class PlanPreventiveVisit {
// data['nurseSignature'] = nurseSignature;
if (preventiveVisitAttachments != null) {
data['preventiveVisitAttachments'] = preventiveVisitAttachments!.map((v) => v.toJson()).toList();
}
if (preventiveVisitCalibrations != null) {

@ -110,6 +110,7 @@ class _PpmDetailsPageState extends State<PpmDetailsPage> {
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)

@ -52,7 +52,20 @@ class _UpdatePpmState extends State<UpdatePpm> 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<UpdatePpm> with SingleTickerProviderStateMix
16.width,
AppFilledButton(
onPressed: () {
if (tabIndex == 0) {
_onSubmit(status: 1);
return;

@ -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<WoInfoForm> {
'${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<WoInfoForm> {
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
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<WoInfoForm> {
selectedTime.hour,
selectedTime.minute,
);
setState(() {
widget.planPreventiveVisit.acutalDateOfVisit = selectedDate;
});
setState(() {
widget.planPreventiveVisit.acutalDateOfVisit = selectedDate;
});
}
});
},
@ -202,6 +198,7 @@ class _WoInfoFormState extends State<WoInfoForm> {
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
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<WoInfoForm> {
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
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<WoInfoForm> {
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
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<WoInfoForm> {
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<WoInfoForm> {
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;
},
),

Loading…
Cancel
Save