|
|
|
@ -61,6 +61,7 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
void populateForm() {
|
|
|
|
void populateForm() {
|
|
|
|
formModel.requestId = widget.model?.id;
|
|
|
|
formModel.requestId = widget.model?.id;
|
|
|
|
formModel.id = widget.model?.id;
|
|
|
|
formModel.id = widget.model?.id;
|
|
|
|
|
|
|
|
formModel.debrief = widget.model?.engineerData?.debrief;
|
|
|
|
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
|
|
|
|
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
|
|
|
|
|
|
|
|
|
|
|
|
calculateWorkingTime();
|
|
|
|
calculateWorkingTime();
|
|
|
|
@ -91,33 +92,38 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_onSubmit(BuildContext context) async {
|
|
|
|
_onSubmit(BuildContext context) async {
|
|
|
|
|
|
|
|
/// Need to refactor this code when timer requirements clear keep picker or both.
|
|
|
|
|
|
|
|
// // formModel.auditTimers ??= [];
|
|
|
|
|
|
|
|
// // if (formModel.auditTimePicker != null) {
|
|
|
|
|
|
|
|
// // int durationInSecond = formModel.auditTimePicker!.endAt!.difference(formModel.auditTimePicker!.startAt!).inSeconds;
|
|
|
|
|
|
|
|
// // formModel.auditTimers?.add(
|
|
|
|
|
|
|
|
// // InternalAuditTimerModel(
|
|
|
|
|
|
|
|
// // id: 0,
|
|
|
|
|
|
|
|
// // startDate: formModel.auditTimePicker!.startAt!.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
// // endDate: formModel.auditTimePicker!.endAt?.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
// // // endDate: formModel.auditTimePicker!.startAt?.add(const Duration(hours: 1)).toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
// // totalWorkingHour: ((durationInSecond) / 60 / 60),
|
|
|
|
|
|
|
|
// // ),
|
|
|
|
|
|
|
|
// // );
|
|
|
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
// // formModel.timerModelList?.forEach((timer) {
|
|
|
|
|
|
|
|
// // int durationInSecond = timer.endAt!.difference(timer.startAt!).inSeconds;
|
|
|
|
|
|
|
|
// // formModel.auditTimers?.add(
|
|
|
|
|
|
|
|
// // InternalAuditTimerModel(
|
|
|
|
|
|
|
|
// // id: 0,
|
|
|
|
|
|
|
|
// // startDate: timer.startAt!.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
// // endDate: timer.endAt?.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
// // totalWorkingHour: ((durationInSecond) / 60 / 60),
|
|
|
|
|
|
|
|
// // ),
|
|
|
|
|
|
|
|
// // );
|
|
|
|
|
|
|
|
// // });
|
|
|
|
bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
|
|
|
|
bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
|
|
|
|
InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false);
|
|
|
|
InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false);
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
if ( formModel.startTime == null) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "Working Hours Required");
|
|
|
|
formModel.auditTimers ??= [];
|
|
|
|
return;
|
|
|
|
if (formModel.auditTimePicker != null) {
|
|
|
|
|
|
|
|
int durationInSecond = formModel.auditTimePicker!.endAt!.difference(formModel.auditTimePicker!.startAt!).inSeconds;
|
|
|
|
|
|
|
|
formModel.auditTimers?.add(
|
|
|
|
|
|
|
|
InternalAuditTimerModel(
|
|
|
|
|
|
|
|
id: 0,
|
|
|
|
|
|
|
|
startDate: formModel.auditTimePicker!.startAt!.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
endDate: formModel.auditTimePicker!.endAt?.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
totalWorkingHour: ((durationInSecond) / 60 / 60),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
formModel.timerModelList?.forEach((timer) {
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
int durationInSecond = timer.endAt!.difference(timer.startAt!).inSeconds;
|
|
|
|
|
|
|
|
formModel.auditTimers?.add(
|
|
|
|
|
|
|
|
InternalAuditTimerModel(
|
|
|
|
|
|
|
|
id: 0,
|
|
|
|
|
|
|
|
startDate: timer.startAt!.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
endDate: timer.endAt?.toIso8601String(), // Handle potential null
|
|
|
|
|
|
|
|
totalWorkingHour: ((durationInSecond) / 60 / 60),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
formModel.attachments = [];
|
|
|
|
formModel.attachments = [];
|
|
|
|
@ -131,20 +137,14 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log('submit press');
|
|
|
|
|
|
|
|
log('data ${formModel.toJson()}');
|
|
|
|
|
|
|
|
final success = await provider.updateSystemInternalAudit(model: formModel);
|
|
|
|
final success = await provider.updateSystemInternalAudit(model: formModel);
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
if (formModel.isComplete == true) {
|
|
|
|
|
|
|
|
//Navigate to List screen.
|
|
|
|
|
|
|
|
} else if (formModel.isComplete == false) {
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
if (success) {
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Fluttertoast.showToast(msg: 'Failed to update');
|
|
|
|
Fluttertoast.showToast(msg: 'Failed to update');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
@ -162,6 +162,9 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
formModel.startTime = start;
|
|
|
|
formModel.startTime = start;
|
|
|
|
formModel.endTime = end;
|
|
|
|
formModel.endTime = end;
|
|
|
|
formModel.totalHours = totalHours;
|
|
|
|
formModel.totalHours = totalHours;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -231,7 +234,6 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
buttonColor: context.isDark ? AppColor.neutral70 : AppColor.white60,
|
|
|
|
buttonColor: context.isDark ? AppColor.neutral70 : AppColor.white60,
|
|
|
|
textColor: context.isDark ? AppColor.white10 : AppColor.black10,
|
|
|
|
textColor: context.isDark ? AppColor.white10 : AppColor.black10,
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
log('button press ');
|
|
|
|
|
|
|
|
formModel.isComplete = false;
|
|
|
|
formModel.isComplete = false;
|
|
|
|
_onSubmit(context);
|
|
|
|
_onSubmit(context);
|
|
|
|
}).expanded,
|
|
|
|
}).expanded,
|
|
|
|
@ -283,8 +285,9 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
AppTimer(
|
|
|
|
AppTimer(
|
|
|
|
label: context.translation.workingHours,
|
|
|
|
label: context.translation.workingHours,
|
|
|
|
showPicker: false,
|
|
|
|
showTimer: false,
|
|
|
|
timer: formModel.auditTimerModel,
|
|
|
|
timer: formModel.auditTimerModel,
|
|
|
|
|
|
|
|
// enabled:formModel.endTime==null,
|
|
|
|
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),
|
|
|
|
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),
|
|
|
|
pickerTimer: formModel.auditTimePicker,
|
|
|
|
pickerTimer: formModel.auditTimePicker,
|
|
|
|
onPick: (time) {
|
|
|
|
onPick: (time) {
|
|
|
|
|