|
|
|
|
@ -1,25 +1,27 @@
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/providers/api/ppm_provider.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/plan_preventive_visit/plan_preventive_visit_model.dart';
|
|
|
|
|
import 'package:test_sa/models/service_request/supplier_details.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/providers/loading_list_notifier.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_asset_availability_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_electrical_safety_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_service_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/ppm_task_status_provider.dart';
|
|
|
|
|
import 'package:test_sa/providers/work_order/vendor_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';
|
|
|
|
|
import '../../../../../providers/ppm_visit_status_provider.dart';
|
|
|
|
|
import '../../../../widgets/date_and_time/date_picker.dart';
|
|
|
|
|
import '../../../../widgets/timer/app_timer.dart';
|
|
|
|
|
|
|
|
|
|
class WoInfoForm extends StatefulWidget {
|
|
|
|
|
@ -33,383 +35,331 @@ class WoInfoForm extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _WoInfoFormState extends State<WoInfoForm> {
|
|
|
|
|
SupplierDetails? initialSupplier;
|
|
|
|
|
SuppPersons? _suppPerson;
|
|
|
|
|
//TODO need to move this to provider ...
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
// TODO need to use model attributes directly no need to assign to new variable. when confirm from backend we need one or multiple suppliers.
|
|
|
|
|
if (widget.planPreventiveVisit.preventiveVisitSuppliers != null && widget.planPreventiveVisit.preventiveVisitSuppliers!.isNotEmpty) {
|
|
|
|
|
initialSupplier = SupplierDetails.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier?.toJson());
|
|
|
|
|
_suppPerson = SuppPersons.fromJson(widget.planPreventiveVisit.preventiveVisitSuppliers?[0].suppPerson?.toJson());
|
|
|
|
|
}
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
|
PpmProvider ppmProvider = Provider.of<PpmProvider>(context, listen: false);
|
|
|
|
|
if (widget.planPreventiveVisit.preventiveVisitAttachments != null && widget.planPreventiveVisit.preventiveVisitAttachments!.isNotEmpty) {
|
|
|
|
|
ppmProvider.ppmPlanAttachments = [];
|
|
|
|
|
ppmProvider.ppmPlanAttachments.addAll(widget.planPreventiveVisit.preventiveVisitAttachments!.map((e) => File(e.attachmentName!)).toList());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
// widget.planPreventiveVisit ??= [];
|
|
|
|
|
// widget.planPreventiveVisit.files = (widget.model.files ?? []).where((element) => element.attachmentName?.isNotEmpty ?? false).toList();
|
|
|
|
|
|
|
|
|
|
double totalWorkingHours =
|
|
|
|
|
widget.planPreventiveVisit.preventiveVisitTimers?.fold(0.0, (sum, item) => (sum ?? 0) + DateTime.parse(item.endDateTime!).difference(DateTime.parse(item.startDateTime!)).inSeconds) ?? 0;
|
|
|
|
|
|
|
|
|
|
totalWorkingHours = totalWorkingHours;
|
|
|
|
|
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (widget.planPreventiveVisit.visitStatus != null)
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: widget.planPreventiveVisit.visitStatus?.name,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
|
|
|
|
|
return Consumer<PpmProvider>(builder: (context, ppmProvider, child) {
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16),
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (widget.planPreventiveVisit.visitStatus != null)
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: widget.planPreventiveVisit.visitStatus?.name,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, widget.planPreventiveVisit.visitStatus?.name),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
2.height,
|
|
|
|
|
'${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.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate != null ? widget.planPreventiveVisit.nextPMDate!.toMonthYearFormat : '-'}'
|
|
|
|
|
.bodyText2(context)
|
|
|
|
|
.custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.assignEngineer}: ${widget.planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""} days'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
12.height,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
"info_icon".toSvgAsset(height: 17, width: 17),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
widget.planPreventiveVisit.planName!.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
2.height,
|
|
|
|
|
'${context.translation.pmPlanNo}: ${widget.planPreventiveVisit.planNo}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.nextPmDate}: ${widget.planPreventiveVisit.nextPMDate?.toMonthYearFormat}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.assignEngineer}: ${widget.planPreventiveVisit.assignedEmployee?.userName ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.executionTimeFrame}: ${widget.planPreventiveVisit.executionTimeFrame ?? ""}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
12.height,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
widget.planPreventiveVisit.assetName!.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
"info_icon".toSvgAsset(height: 17, width: 17),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
2.height,
|
|
|
|
|
'${context.translation.assetNo}: ${widget.planPreventiveVisit.asset?.assetNumber}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.model}: ${widget.planPreventiveVisit.model}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
2.height,
|
|
|
|
|
'${context.translation.assetNo}: ${widget.planPreventiveVisit.asset?.assetNumber}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
'${context.translation.model}: ${widget.planPreventiveVisit.model}'.bodyText2(context).custom(color: AppColor.neutral120),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialValue:
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()),
|
|
|
|
|
// title: context.translation.ppmVisit,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value?.value == 4) {
|
|
|
|
|
// "Status cannot be change to ${value?.name}.".addTranslation.showToast;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.name = value.name;
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.id = value.id;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, PPMVisitStatusProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialValue:
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.id == null ? null : Lookup(name: widget.planPreventiveVisit.visitStatus?.name ?? "", id: widget.planPreventiveVisit.visitStatus?.id?.toInt()),
|
|
|
|
|
// title: context.translation.ppmVisit,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value?.value == 4) {
|
|
|
|
|
// "Status cannot be change to ${value?.name}.".addTranslation.showToast;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.name = value.name;
|
|
|
|
|
// widget.planPreventiveVisit.visitStatus?.id = value.id;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()),
|
|
|
|
|
// title: context.translation.deviceStatus,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
// widget.planPreventiveVisit.deviceStatusId = value.id;
|
|
|
|
|
// widget.planPreventiveVisit.deviceStatusName = value.name;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id),
|
|
|
|
|
title: context.translation.taskStatus,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.taskStatus?.id = value.id;
|
|
|
|
|
widget.planPreventiveVisit.taskStatus?.name = value.name;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.assetAvailability == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id),
|
|
|
|
|
title: "Asset Availability",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.assetAvailability?.id = value.id;
|
|
|
|
|
widget.planPreventiveVisit.assetAvailability?.name = value.name;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, PPMDeviceStatusProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialValue: widget.planPreventiveVisit.deviceStatusId == null ? null : Lookup(name: widget.model.deviceStatusName ?? "", id: widget.model.deviceStatusId?.toInt()),
|
|
|
|
|
// title: context.translation.deviceStatus,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
// widget.planPreventiveVisit.deviceStatusId = value.id;
|
|
|
|
|
// widget.planPreventiveVisit.deviceStatusName = value.name;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
//TODO Ahmed need to provide look up value....
|
|
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
|
|
|
|
|
title: "Electrical Safety",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.safety?.id = value.id;
|
|
|
|
|
widget.planPreventiveVisit.safety?.name = value.name;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue:
|
|
|
|
|
widget.planPreventiveVisit.typeOfService == null ? null : Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()),
|
|
|
|
|
title: context.translation.serviceType,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.typeOfService?.id = value.id;
|
|
|
|
|
widget.planPreventiveVisit.typeOfService?.name = value.name;
|
|
|
|
|
//TODO check this why make all values null..
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmTaskStatusProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.taskStatus == null ? null : Lookup(name: widget.planPreventiveVisit.taskStatus?.name ?? "", id: widget.planPreventiveVisit.taskStatus?.id),
|
|
|
|
|
title: context.translation.pmTestResult,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.taskStatus = value;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.actualVisit,
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
date: widget.planPreventiveVisit.acutalDateOfVisit,
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
onDatePicker: (selectedDate) {
|
|
|
|
|
showTimePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialTime: TimeOfDay.now(),
|
|
|
|
|
).then((selectedTime) {
|
|
|
|
|
if (selectedTime != null) {
|
|
|
|
|
DateTime selectedDateTime = DateTime(
|
|
|
|
|
selectedDate.year,
|
|
|
|
|
selectedDate.month,
|
|
|
|
|
selectedDate.day,
|
|
|
|
|
selectedTime.hour,
|
|
|
|
|
selectedTime.minute,
|
|
|
|
|
);
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.planPreventiveVisit.acutalDateOfVisit = selectedDate;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// widget.planPreventiveVisit?.preventiveVisitSuppliers?. = null;
|
|
|
|
|
// widget.model.supplierName = null;
|
|
|
|
|
// initialSupplier = null;
|
|
|
|
|
// _suppPerson = null;
|
|
|
|
|
// widget.model.suppPersonId = null;
|
|
|
|
|
// widget.model.suppPerson = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
|
|
|
|
|
// context: context,
|
|
|
|
|
// backgroundColor: AppColor.neutral100,
|
|
|
|
|
// initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
|
|
|
|
|
// title: context.translation.actualVisit,
|
|
|
|
|
// onSelect: (value) {
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
// widget.planPreventiveVisit.safety = value;
|
|
|
|
|
// // widget.planPreventiveVisit.safety?.id = value.id;
|
|
|
|
|
// // widget.planPreventiveVisit.safety?.name = value.name;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmElectricalSafetyProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.safety?.id == null ? null : Lookup(name: widget.planPreventiveVisit.safety?.name ?? "", id: widget.planPreventiveVisit.safety?.id),
|
|
|
|
|
title: "Electrical Safety",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.safety = value;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmAssetAvailabilityProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.assetAvailability == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(name: widget.planPreventiveVisit.assetAvailability?.name ?? "", id: widget.planPreventiveVisit.assetAvailability?.id),
|
|
|
|
|
title: "Asset Availability",
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.assetAvailability = value;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, PpmServiceProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
initialValue: widget.planPreventiveVisit.typeOfService == null
|
|
|
|
|
? null
|
|
|
|
|
: Lookup(name: widget.planPreventiveVisit.typeOfService?.name ?? "", id: widget.planPreventiveVisit.typeOfService?.id?.toInt()),
|
|
|
|
|
title: context.translation.typeOfPm,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
widget.planPreventiveVisit.typeOfService = value;
|
|
|
|
|
if (widget.planPreventiveVisit.typeOfService?.id == 66) {
|
|
|
|
|
ppmProvider.totalTabs = 4;
|
|
|
|
|
} else {
|
|
|
|
|
ppmProvider.totalTabs = 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
|
|
_timerWidget(context, totalWorkingHours),
|
|
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.callComments,
|
|
|
|
|
backgroundColor: AppColor.neutral100,
|
|
|
|
|
initialValue: (widget.planPreventiveVisit.comments ?? "").toString(),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
widget.planPreventiveVisit.comments = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
MultiFilesPicker(
|
|
|
|
|
label: context.translation.attachments,
|
|
|
|
|
files: ppmProvider.ppmPlanAttachments,
|
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
//TODO need to check this also...
|
|
|
|
|
// ESignature(
|
|
|
|
|
// title: context.translation.nurseSignature,
|
|
|
|
|
// oldSignature: widget.planPreventiveVisit.nurseSignature,
|
|
|
|
|
// newSignature: widget.planPreventiveVisit.localNurseSignature,
|
|
|
|
|
// onChange: (signature) {
|
|
|
|
|
// widget.planPreventiveVisit.localNurseSignature = signature;
|
|
|
|
|
// widget.planPreventiveVisit.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// ESignature(
|
|
|
|
|
// title: context.translation.engSign,
|
|
|
|
|
// oldSignature: widget.planPreventiveVisit.engSignature,
|
|
|
|
|
// newSignature: widget.planPreventiveVisit.localEngineerSignature,
|
|
|
|
|
// onChange: (signature) {
|
|
|
|
|
// widget.planPreventiveVisit.localEngineerSignature = signature;
|
|
|
|
|
// widget.planPreventiveVisit.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _timerWidget(BuildContext context, double totalWorkingHours) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
AppTimer(
|
|
|
|
|
label: context.translation.timer,
|
|
|
|
|
label: context.translation.workingHours,
|
|
|
|
|
decoration: BoxDecoration(color: AppColor.neutral100, borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
timer: widget.planPreventiveVisit.tbsTimer,
|
|
|
|
|
enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null,
|
|
|
|
|
timerProgress: (isRunning) {
|
|
|
|
|
print("timerProgress:$isRunning");
|
|
|
|
|
},
|
|
|
|
|
// enabled: widget.planPreventiveVisit.tbsTimer?.endAt == null,
|
|
|
|
|
timerProgress: (isRunning) {},
|
|
|
|
|
onChange: (timer) async {
|
|
|
|
|
widget.planPreventiveVisit.tbsTimer = timer;
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
11.height,
|
|
|
|
|
if (totalWorkingHours > 0.0) ...[
|
|
|
|
|
Container(
|
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.isDark ? AppColor.neutral40 : AppColor.background(context),
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"Total Working Time",
|
|
|
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
" ${formatDuration(totalWorkingHours.round())}",
|
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
if (widget.planPreventiveVisit.typeOfService?.id == 66) ...[
|
|
|
|
|
SingleItemDropDownMenu<SupplierDetails, VendorProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.supplier,
|
|
|
|
|
initialValue: initialSupplier,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (supplier) {
|
|
|
|
|
if (supplier != null) {
|
|
|
|
|
initialSupplier = supplier;
|
|
|
|
|
print('supplier dtails is ${supplier.toJson()}');
|
|
|
|
|
// widget.planPreventiveVisit.preventiveVisitSuppliers?[0].supplier=supplier;
|
|
|
|
|
// widget.model.supplierId = supplier.id;
|
|
|
|
|
// widget.model.supplierName = supplier.name;
|
|
|
|
|
// initialSupplier = supplier;
|
|
|
|
|
// _suppPerson = null;
|
|
|
|
|
// widget.model.suppPersonId = null;
|
|
|
|
|
// widget.model.suppPerson = null;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
context.translation.totalWorkingTime.bodyText2(context),
|
|
|
|
|
" ${ServiceRequestUtils.formatTimerDuration(totalWorkingHours.round())}".bodyText(context).custom(color: AppColor.black20),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<SuppPersons, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.supplierEngineer,
|
|
|
|
|
enabled: initialSupplier?.suppPersons?.isNotEmpty ?? false,
|
|
|
|
|
initialValue: _suppPerson,
|
|
|
|
|
staticData: initialSupplier?.suppPersons,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (suppPerson) {
|
|
|
|
|
if (suppPerson != null) {
|
|
|
|
|
// _suppPerson = suppPerson;
|
|
|
|
|
// widget.model.suppPersonId = suppPerson.id;
|
|
|
|
|
// widget.model.suppPerson = suppPerson.name;
|
|
|
|
|
// setState(() {});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: "Telephone",
|
|
|
|
|
// initialValue: (initialSupplier?.telephones?[0].telephone ?? "").toString(),
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
// textInputType: TextInputType.number,
|
|
|
|
|
// onChange: (value) {
|
|
|
|
|
// initialSupplier?.telephones?[0].telephone = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
//TODO implement this after feedback from backend.
|
|
|
|
|
// AppTimer(
|
|
|
|
|
// label: "External Supplier Timer",
|
|
|
|
|
// timer: widget.model.externalEngineerTimer,
|
|
|
|
|
// enabled: widget.model.externalEngineerTimer?.endAt == null,
|
|
|
|
|
// timerProgress: (isRunning) {
|
|
|
|
|
// print("timerProgress:$isRunning");
|
|
|
|
|
// },
|
|
|
|
|
// onChange: (timer) async {
|
|
|
|
|
// widget.model.externalEngineerTimer = timer;
|
|
|
|
|
// return true;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
],
|
|
|
|
|
ADatePicker(
|
|
|
|
|
label: context.translation.actualVisitDate,
|
|
|
|
|
date: DateTime.tryParse(widget.planPreventiveVisit.acutalDateOfVisit ?? ""),
|
|
|
|
|
from: DateTime.now().subtract(const Duration(days: 30)),
|
|
|
|
|
onDatePicker: (date) {
|
|
|
|
|
// if (date.isBefore(DateTime.parse(widget.planPreventiveVisit.expectedDate!))) {
|
|
|
|
|
// "Actual visit date must be greater then expected date".showToast;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// widget.model.actualDate = date.toIso8601String();
|
|
|
|
|
// setState(() {});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.expectedVisitDate,
|
|
|
|
|
// date: DateTime.tryParse(widget.model.nextDate ?? ""),
|
|
|
|
|
// from: DateTime.now().subtract(const Duration(days: 30)),
|
|
|
|
|
// enable: false,
|
|
|
|
|
// onDatePicker: (date) {
|
|
|
|
|
// widget.model.nextDate = date.toIso8601String();
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.travelingHours,
|
|
|
|
|
initialValue: (widget.planPreventiveVisit.travelingHours ?? "").toString(),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
widget.planPreventiveVisit.travelingHours = int.parse(value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
// MultiFilesPicker(
|
|
|
|
|
// label: context.translation.attachImage,
|
|
|
|
|
// files: widget.model.files!.map((e) => File(e.attachmentName!)).toList(),
|
|
|
|
|
// onChange: (files) {
|
|
|
|
|
// widget.model.files = files.map((e) => PpmAttachments(attachmentName: e.path)).toList();
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
labelText: context.translation.comments,
|
|
|
|
|
initialValue: (widget.planPreventiveVisit.comments ?? "").toString(),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
widget.planPreventiveVisit.comments = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
// ESignature(
|
|
|
|
|
// title: context.translation.nurseSignature,
|
|
|
|
|
// oldSignature: widget.planPreventiveVisit.nurseSignature,
|
|
|
|
|
// newSignature: widget.planPreventiveVisit.localNurseSignature,
|
|
|
|
|
// onChange: (signature) {
|
|
|
|
|
// widget.planPreventiveVisit.localNurseSignature = signature;
|
|
|
|
|
// widget.planPreventiveVisit.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
8.height,
|
|
|
|
|
// ESignature(
|
|
|
|
|
// title: context.translation.engSign,
|
|
|
|
|
// oldSignature: widget.planPreventiveVisit.engSignature,
|
|
|
|
|
// newSignature: widget.planPreventiveVisit.localEngineerSignature,
|
|
|
|
|
// onChange: (signature) {
|
|
|
|
|
// widget.planPreventiveVisit.localEngineerSignature = signature;
|
|
|
|
|
// widget.planPreventiveVisit.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String formatDuration1(int seconds) {
|
|
|
|
|
int hours = seconds ~/ 3600;
|
|
|
|
|
int minutes = (seconds % 3600) ~/ 60;
|
|
|
|
|
|
|
|
|
|
String formattedDuration = '';
|
|
|
|
|
if (hours > 0) {
|
|
|
|
|
formattedDuration += '$hours hour${hours > 1 ? 's' : ''} ';
|
|
|
|
|
}
|
|
|
|
|
if (minutes > 0) {
|
|
|
|
|
formattedDuration += '$minutes minute${minutes > 1 ? 's' : ''} ';
|
|
|
|
|
}
|
|
|
|
|
if (formattedDuration.isEmpty) {
|
|
|
|
|
formattedDuration = 'Less than a minute';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formattedDuration.trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String formatDuration(int seconds) {
|
|
|
|
|
int hours = seconds ~/ 3600;
|
|
|
|
|
int minutes = (seconds % 3600) ~/ 60;
|
|
|
|
|
int remainingSeconds = seconds % 60;
|
|
|
|
|
|
|
|
|
|
String formattedDuration = '';
|
|
|
|
|
if (hours > 0) {
|
|
|
|
|
formattedDuration += '$hours hour${hours > 1 ? 's' : ''} ';
|
|
|
|
|
}
|
|
|
|
|
if (minutes > 0) {
|
|
|
|
|
formattedDuration += '$minutes minute${minutes > 1 ? 's' : ''} ';
|
|
|
|
|
}
|
|
|
|
|
if (remainingSeconds > 0) {
|
|
|
|
|
formattedDuration += '$remainingSeconds second${remainingSeconds > 1 ? 's' : ''} ';
|
|
|
|
|
}
|
|
|
|
|
if (formattedDuration.isEmpty) {
|
|
|
|
|
formattedDuration = 'Less than a second';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formattedDuration.trim();
|
|
|
|
|
}
|
|
|
|
|
// String formatDuration1(int seconds) {
|
|
|
|
|
// int hours = seconds ~/ 3600;
|
|
|
|
|
// int minutes = (seconds % 3600) ~/ 60;
|
|
|
|
|
//
|
|
|
|
|
// String formattedDuration = '';
|
|
|
|
|
// if (hours > 0) {
|
|
|
|
|
// formattedDuration += '$hours hour${hours > 1 ? 's' : ''} ';
|
|
|
|
|
// }
|
|
|
|
|
// if (minutes > 0) {
|
|
|
|
|
// formattedDuration += '$minutes minute${minutes > 1 ? 's' : ''} ';
|
|
|
|
|
// }
|
|
|
|
|
// if (formattedDuration.isEmpty) {
|
|
|
|
|
// formattedDuration = 'Less than a minute';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return formattedDuration.trim();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// String formatDuration(int seconds) {
|
|
|
|
|
// int hours = seconds ~/ 3600;
|
|
|
|
|
// int minutes = (seconds % 3600) ~/ 60;
|
|
|
|
|
// int remainingSeconds = seconds % 60;
|
|
|
|
|
//
|
|
|
|
|
// String formattedDuration = '';
|
|
|
|
|
// if (hours > 0) {
|
|
|
|
|
// formattedDuration += '$hours hour${hours > 1 ? 's' : ''} ';
|
|
|
|
|
// }
|
|
|
|
|
// if (minutes > 0) {
|
|
|
|
|
// formattedDuration += '$minutes minute${minutes > 1 ? 's' : ''} ';
|
|
|
|
|
// }
|
|
|
|
|
// if (remainingSeconds > 0) {
|
|
|
|
|
// formattedDuration += '$remainingSeconds second${remainingSeconds > 1 ? 's' : ''} ';
|
|
|
|
|
// }
|
|
|
|
|
// if (formattedDuration.isEmpty) {
|
|
|
|
|
// formattedDuration = 'Less than a second';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return formattedDuration.trim();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|