|
|
|
|
@ -57,6 +57,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
|
List<GenericAttachmentModel> attachments = [];
|
|
|
|
|
List<TaskJobAttachment> otherAttachments = [];
|
|
|
|
|
bool installationType = true;
|
|
|
|
|
String comments = '';
|
|
|
|
|
|
|
|
|
|
@ -76,9 +77,8 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
TaskData? taskModel = _taskProvider?.taskRequestModel;
|
|
|
|
|
_taskProvider?.refresh();
|
|
|
|
|
if (taskModel?.taskJobAttachments != null) {
|
|
|
|
|
attachments.addAll(
|
|
|
|
|
taskModel!.taskJobAttachments!.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '')).toList(),
|
|
|
|
|
);
|
|
|
|
|
attachments = taskModel!.taskJobAttachments!.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '')).toList();
|
|
|
|
|
otherAttachments = taskModel.taskJobAttachments?.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -204,12 +204,15 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
|
taskModel?.statusValue = status;
|
|
|
|
|
if (validate(model: taskModel)) {
|
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
|
List<TaskJobAttachment> attachment = [];
|
|
|
|
|
List<TaskJobAttachment> taskAttachment = [];
|
|
|
|
|
if (otherAttachments.isNotEmpty) {
|
|
|
|
|
taskAttachment.addAll(otherAttachments);
|
|
|
|
|
}
|
|
|
|
|
for (var item in attachments) {
|
|
|
|
|
String fileName = ServiceRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
|
|
|
|
|
attachment.add(TaskJobAttachment(id: item.id, name: fileName));
|
|
|
|
|
taskAttachment.add(TaskJobAttachment(id: item.id, name: fileName));
|
|
|
|
|
}
|
|
|
|
|
taskModel?.taskJobAttachments = attachment;
|
|
|
|
|
taskModel?.taskJobAttachments = taskAttachment;
|
|
|
|
|
if (taskModel?.taskTimePicker != null) {
|
|
|
|
|
int durationInSecond = taskModel!.taskTimePicker!.endAt!.difference(taskModel.taskTimePicker!.startAt!).inSeconds;
|
|
|
|
|
taskModel.taskJobActivityEngineerTimers?.add(
|
|
|
|
|
@ -919,205 +922,3 @@ class EmployeeCard extends StatelessWidget {
|
|
|
|
|
).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)).paddingOnly(bottom: 12);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// class AssistantEmployeeCard extends StatefulWidget {
|
|
|
|
|
// const AssistantEmployeeCard({super.key});
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// State<AssistantEmployeeCard> createState() => _AssistantEmployeeCardState();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
|
// bool status = false;
|
|
|
|
|
// final TextEditingController _workingHoursController = TextEditingController(text: '');
|
|
|
|
|
// bool isExpanded = false;
|
|
|
|
|
// TaskData? taskModel;
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// void initState() {
|
|
|
|
|
// TaskRequestProvider taskRequestProvider = Provider.of<TaskRequestProvider>(context, listen: false);
|
|
|
|
|
// taskModel = taskRequestProvider.taskRequestModel;
|
|
|
|
|
//
|
|
|
|
|
// super.initState();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// void dispose() {
|
|
|
|
|
// // TODO: implement dispose
|
|
|
|
|
//
|
|
|
|
|
// _workingHoursController.dispose();
|
|
|
|
|
// super.dispose();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @override
|
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
|
// return Consumer<TaskRequestProvider>(builder: (context, taskRequestProvider, child) {
|
|
|
|
|
// return Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// SizedBox(
|
|
|
|
|
// height: 56.toScreenHeight,
|
|
|
|
|
// child: Row(
|
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
// children: [
|
|
|
|
|
// context.translation.assistantEmployee.heading6(context).custom(color: AppColor.textColor(context)),
|
|
|
|
|
// Icon(isExpanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// ).onPress(() {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// isExpanded = !isExpanded;
|
|
|
|
|
// });
|
|
|
|
|
// }),
|
|
|
|
|
// isExpanded
|
|
|
|
|
// ? Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
// children: [
|
|
|
|
|
// ServiceReportAssistantEmployeeMenu(
|
|
|
|
|
// title: context.translation.select,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// initialValue: (taskModel?.assistantEmployees?.isNotEmpty ?? false) ? taskModel?.assistantEmployees?.first : null,
|
|
|
|
|
// onSelect: (employee) {
|
|
|
|
|
// if (employee == null) {
|
|
|
|
|
// taskModel?.assistantEmployees = [];
|
|
|
|
|
// } else {
|
|
|
|
|
// taskModel?.assistantEmployees = [employee.copyWith(id: 0)];
|
|
|
|
|
// taskModel?.modelAssistantEmployees?.user = AssignedEmployee(userId: employee.user?.id, userName: employee.user?.name);
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// Row(
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// children: [
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.startTime,
|
|
|
|
|
// hideShadow: true,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// date: taskModel?.modelAssistantEmployees?.startDate,
|
|
|
|
|
// // from: taskModel?.d,
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// // Handle the selected date and time here.
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// DateTime selectedDateTime = DateTime(selectedDate.year, selectedDate.month, selectedDate.day, selectedTime.hour, selectedTime.minute);
|
|
|
|
|
// // if (widget.pickerFromDate != null && selectedDateTime.isBefore(widget.pickerFromDate!)) {
|
|
|
|
|
// // "Start time is before the request time.".showToast;
|
|
|
|
|
// // _pickerStartAt = null;
|
|
|
|
|
// // selectedTime = null;
|
|
|
|
|
// // return;
|
|
|
|
|
// // }
|
|
|
|
|
// if (selectedDateTime.isAfter(DateTime.now())) {
|
|
|
|
|
// "Start time is after than current time".showToast;
|
|
|
|
|
// selectedTime = null;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// taskModel?.modelAssistantEmployees?.startDate = selectedDateTime;
|
|
|
|
|
// taskRequestProvider.updateTaskModel(taskModel);
|
|
|
|
|
// ServiceRequestUtils.calculateAndAssignWorkingHours(
|
|
|
|
|
// startTime: taskModel?.modelAssistantEmployees?.startDate,
|
|
|
|
|
// endTime: taskModel?.modelAssistantEmployees?.startDate,
|
|
|
|
|
// workingHoursController: _workingHoursController,
|
|
|
|
|
// updateModel: (hours) {
|
|
|
|
|
// taskModel!.modelAssistantEmployees!.workingHours = hours;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ).expanded,
|
|
|
|
|
// 8.width,
|
|
|
|
|
// ADatePicker(
|
|
|
|
|
// label: context.translation.endTime,
|
|
|
|
|
// hideShadow: true,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// date: taskModel?.modelAssistantEmployees?.endDate,
|
|
|
|
|
// enable: taskModel?.modelAssistantEmployees?.startDate != null,
|
|
|
|
|
// formatDateWithTime: true,
|
|
|
|
|
// onDatePicker: (selectedDate) {
|
|
|
|
|
// showTimePicker(
|
|
|
|
|
// context: context,
|
|
|
|
|
// initialTime: TimeOfDay.now(),
|
|
|
|
|
// ).then((selectedTime) {
|
|
|
|
|
// // Handle the selected date and time here.
|
|
|
|
|
// if (selectedTime != null) {
|
|
|
|
|
// // DateTime selectedDateTime = DateTime(
|
|
|
|
|
// // selectedDate.year,
|
|
|
|
|
// // selectedDate.month,
|
|
|
|
|
// // selectedDate.day,
|
|
|
|
|
// // selectedTime.hour,
|
|
|
|
|
// // selectedTime.minute,
|
|
|
|
|
// // );
|
|
|
|
|
// //
|
|
|
|
|
// // if (taskModel?.modelAssistantEmployees?.startDate != null && selectedDateTime.isBefore(taskModel!.modelAssistantEmployees!.startDate!)) {
|
|
|
|
|
// // "End Date time must be greater then start date".showToast;
|
|
|
|
|
// // return;
|
|
|
|
|
// // }
|
|
|
|
|
//
|
|
|
|
|
// selectedDate = selectedDate.add(Duration(hours: selectedTime.hour, minutes: selectedTime.minute));
|
|
|
|
|
// bool isBeforeCurrentTime = selectedDate.isBefore(DateTime.now());
|
|
|
|
|
// bool isAfterStartTime = selectedDate.isAfter(taskModel!.modelAssistantEmployees!.startDate!);
|
|
|
|
|
// if (!isBeforeCurrentTime) {
|
|
|
|
|
// "Please select a time before the current time.".showToast;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (!isAfterStartTime) {
|
|
|
|
|
// "End Date time must be greater then start date".showToast;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// taskModel?.modelAssistantEmployees?.endDate = selectedDate;
|
|
|
|
|
// taskRequestProvider.updateTaskModel(taskModel);
|
|
|
|
|
// ServiceRequestUtils.calculateAndAssignWorkingHours(
|
|
|
|
|
// startTime: taskModel?.modelAssistantEmployees?.startDate,
|
|
|
|
|
// endTime: taskModel?.modelAssistantEmployees?.endDate,
|
|
|
|
|
// workingHoursController: _workingHoursController,
|
|
|
|
|
// updateModel: (hours) {
|
|
|
|
|
// taskModel!.modelAssistantEmployees!.workingHours = hours;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// ).expanded,
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: context.translation.workingHours,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// controller: _workingHoursController,
|
|
|
|
|
// suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
|
|
|
|
|
// initialValue: taskModel?.modelAssistantEmployees?.workingHours != null ? taskModel!.modelAssistantEmployees!.workingHours?.toStringAsFixed(2) : '',
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
// enable: false,
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
// ),
|
|
|
|
|
// 8.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// initialValue: taskModel?.modelAssistantEmployees?.comment,
|
|
|
|
|
// labelText: context.translation.comment,
|
|
|
|
|
// backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
// showShadow: false,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
// alignLabelWithHint: true,
|
|
|
|
|
// textInputType: TextInputType.multiline,
|
|
|
|
|
// onChange: (value) {
|
|
|
|
|
// taskModel?.modelAssistantEmployees?.comment = value;
|
|
|
|
|
// },
|
|
|
|
|
// onSaved: (value) {
|
|
|
|
|
// taskModel?.modelAssistantEmployees?.comment = value;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// ],
|
|
|
|
|
// )
|
|
|
|
|
// : const SizedBox(),
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|