|
|
|
@ -12,6 +12,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/helper/utils.dart';
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
import 'package:test_sa/models/generic_attachment_model.dart';
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
import 'package:test_sa/models/lookup.dart';
|
|
|
|
import 'package:test_sa/models/new_models/building.dart';
|
|
|
|
import 'package:test_sa/models/new_models/building.dart';
|
|
|
|
@ -37,14 +38,14 @@ import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart';
|
|
|
|
import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart';
|
|
|
|
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
|
|
|
import 'package:test_sa/views/widgets/timer/app_timer.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../../models/new_models/site.dart';
|
|
|
|
import '../../../../models/new_models/site.dart';
|
|
|
|
import '../../../../models/new_models/work_order_detail_model.dart';
|
|
|
|
import '../../../models/new_models/work_order_detail_model.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateTaskRequest extends StatefulWidget {
|
|
|
|
class UpdateTaskRequest extends StatefulWidget {
|
|
|
|
final int taskId;
|
|
|
|
final int taskId;
|
|
|
|
|
|
|
|
final String? createdDate;
|
|
|
|
|
|
|
|
|
|
|
|
const UpdateTaskRequest({Key? key, required this.taskId}) : super(key: key);
|
|
|
|
const UpdateTaskRequest({Key? key, required this.taskId, this.createdDate}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
State<UpdateTaskRequest> createState() => _UpdateTaskRequestState();
|
|
|
|
State<UpdateTaskRequest> createState() => _UpdateTaskRequestState();
|
|
|
|
@ -58,8 +59,6 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
List<GenericAttachmentModel> attachments = [];
|
|
|
|
List<GenericAttachmentModel> attachments = [];
|
|
|
|
bool installationType = true;
|
|
|
|
bool installationType = true;
|
|
|
|
String comments = '';
|
|
|
|
String comments = '';
|
|
|
|
List<File> _userAttachments = [];
|
|
|
|
|
|
|
|
List<TaskJobAttachment> _readOnlyAttachments = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
@ -71,19 +70,15 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> assignData() async {
|
|
|
|
Future<void> assignData() async {
|
|
|
|
|
|
|
|
//may need to pass model in class parameters.
|
|
|
|
_taskProvider = Provider.of<TaskRequestProvider>(context, listen: false);
|
|
|
|
_taskProvider = Provider.of<TaskRequestProvider>(context, listen: false);
|
|
|
|
UserProvider _userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
UserProvider _userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
TaskData? taskModel = _taskProvider?.taskRequestModel;
|
|
|
|
TaskData? taskModel = _taskProvider!.taskRequestModel;
|
|
|
|
_taskProvider?.refresh();
|
|
|
|
_userAttachments = _taskProvider?.taskRequestModel?.taskJobAttachments?.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => File(e.name ?? '')).toList() ?? [];
|
|
|
|
if (taskModel?.taskJobAttachments != null) {
|
|
|
|
_readOnlyAttachments = _taskProvider?.taskRequestModel?.taskJobAttachments?.where((e) => e.createdBy != _userProvider.user?.userID).toList() ?? [];
|
|
|
|
attachments.addAll(
|
|
|
|
|
|
|
|
taskModel!.taskJobAttachments!.where((e) => e.createdBy == _userProvider.user?.userID).map((e) => GenericAttachmentModel(id: e.id, name: e.name ?? '')).toList(),
|
|
|
|
_taskProvider?.updateTaskModel(taskModel);
|
|
|
|
);
|
|
|
|
if (taskModel != null) {
|
|
|
|
|
|
|
|
attachments.addAll(taskModel.taskJobAttachments!.map((e) => GenericAttachmentModel(id:e.id,name:e.name ?? '')).toList());
|
|
|
|
|
|
|
|
// if (taskModel.taskType?.isInstallation == true) {
|
|
|
|
|
|
|
|
// await _taskProvider!.getSiteData(siteId: taskModel.asset?.siteId);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -108,78 +103,90 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
? const ALoading()
|
|
|
|
? const ALoading()
|
|
|
|
: taskProvider.taskRequestModel != null
|
|
|
|
: taskProvider.taskRequestModel != null
|
|
|
|
? Form(
|
|
|
|
? Form(
|
|
|
|
key: _formKey,
|
|
|
|
key: _formKey,
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
SingleChildScrollView(
|
|
|
|
SingleChildScrollView(
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_timerWidget(context, true, taskProvider),
|
|
|
|
_timerWidget(context, true, taskProvider),
|
|
|
|
8.height,
|
|
|
|
8.height,
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)],
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isInstallation == true) ...[installationWidget(taskModel: taskProvider.taskRequestModel!)],
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[
|
|
|
|
if (taskProvider.taskRequestModel?.taskType?.isRecallAndAlert == true) ...[
|
|
|
|
recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!),
|
|
|
|
recallAlertTypeWidget(taskModel: taskProvider.taskRequestModel!),
|
|
|
|
],
|
|
|
|
|
|
|
|
// if (previousComments.isNotEmpty) ...[
|
|
|
|
|
|
|
|
// 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50),
|
|
|
|
|
|
|
|
// 8.height,
|
|
|
|
|
|
|
|
buildPreviousComments(taskProvider: taskProvider),
|
|
|
|
|
|
|
|
// 8.height,
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
|
|
|
initialValue: "",
|
|
|
|
|
|
|
|
labelText: context.translation.technicalComment,
|
|
|
|
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
labelStyle: TextStyle(color: AppColor.textColor(context)),
|
|
|
|
|
|
|
|
showShadow: false,
|
|
|
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
|
|
|
comments = value;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
20.height,
|
|
|
|
|
|
|
|
AttachmentPicker(
|
|
|
|
|
|
|
|
label: context.translation.attachFiles,
|
|
|
|
|
|
|
|
attachment: attachments,
|
|
|
|
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).toShadowContainer(context),
|
|
|
|
// if (previousComments.isNotEmpty) ...[
|
|
|
|
16.height,
|
|
|
|
// 'Previous Comments'.bodyText2(context).custom(color: AppColor.neutral50),
|
|
|
|
const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)),
|
|
|
|
// 8.height,
|
|
|
|
],
|
|
|
|
buildPreviousComments(taskProvider: taskProvider),
|
|
|
|
),
|
|
|
|
// 8.height,
|
|
|
|
).expanded,
|
|
|
|
// ],
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
AppTextFormField(
|
|
|
|
context: context,
|
|
|
|
initialValue: "",
|
|
|
|
child: Row(
|
|
|
|
labelText: context.translation.technicalComment,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
children: [
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
AppFilledButton(
|
|
|
|
labelStyle: TextStyle(color: AppColor.textColor(context)),
|
|
|
|
label: context.translation.save,
|
|
|
|
showShadow: false,
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
onChange: (value) {
|
|
|
|
onPressed: () => _updateTask(context: context, status: 0),
|
|
|
|
comments = value;
|
|
|
|
).expanded,
|
|
|
|
setState(() {});
|
|
|
|
12.width,
|
|
|
|
},
|
|
|
|
AppFilledButton(
|
|
|
|
onSaved: (value) {},
|
|
|
|
label: context.translation.complete,
|
|
|
|
),
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
20.height,
|
|
|
|
onPressed: () => _updateTask(context: context, status: 1),
|
|
|
|
AttachmentPicker(
|
|
|
|
).expanded,
|
|
|
|
label: context.translation.attachFiles,
|
|
|
|
],
|
|
|
|
attachment: attachments,
|
|
|
|
),
|
|
|
|
buttonColor: AppColor.black10,
|
|
|
|
|
|
|
|
onlyImages: false,
|
|
|
|
|
|
|
|
buttonIcon: 'image-plus'.toSvgAsset(color: AppColor.neutral120),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
|
|
|
16.height,
|
|
|
|
|
|
|
|
TaskRequestAssistantEmployeeList(
|
|
|
|
|
|
|
|
assetId: taskProvider.taskRequestModel?.asset?.id,
|
|
|
|
|
|
|
|
createdDate: widget.createdDate ?? '',
|
|
|
|
|
|
|
|
//widget.requestDetails?.date
|
|
|
|
|
|
|
|
assistantEmployeeList: taskProvider.taskRequestModel?.taskJobAssistantEmployees,
|
|
|
|
|
|
|
|
cardPadding: 0,
|
|
|
|
|
|
|
|
onListChanged: (updatedList) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
taskProvider.taskRequestModel?.taskJobAssistantEmployees = updatedList;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
// const AssistantEmployeeCard().toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16)),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
).expanded,
|
|
|
|
|
|
|
|
FooterActionButton.footerContainer(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
|
|
|
label: context.translation.save,
|
|
|
|
|
|
|
|
buttonColor: AppColor.white60,
|
|
|
|
|
|
|
|
textColor: AppColor.black10,
|
|
|
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 0),
|
|
|
|
|
|
|
|
).expanded,
|
|
|
|
|
|
|
|
12.width,
|
|
|
|
|
|
|
|
AppFilledButton(
|
|
|
|
|
|
|
|
label: context.translation.complete,
|
|
|
|
|
|
|
|
buttonColor: AppColor.primary10,
|
|
|
|
|
|
|
|
onPressed: () => _updateTask(context: context, status: 1),
|
|
|
|
|
|
|
|
).expanded,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: NoDataFound(message: context.translation.noDataFound).center,
|
|
|
|
: NoDataFound(message: context.translation.noDataFound).center,
|
|
|
|
@ -199,7 +206,7 @@ class _UpdateTaskRequestState extends State<UpdateTaskRequest> {
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
|
|
|
List<TaskJobAttachment> attachment = [];
|
|
|
|
List<TaskJobAttachment> attachment = [];
|
|
|
|
for (var item in attachments) {
|
|
|
|
for (var item in attachments) {
|
|
|
|
String fileName = ServiceRequestUtils.isLocalUrl(item.name??'') ? ("${item.name??''.split("/").last}|${base64Encode(File(item.name??'').readAsBytesSync())}") :item.name??'';
|
|
|
|
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));
|
|
|
|
attachment.add(TaskJobAttachment(id: item.id, name: fileName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
taskModel?.taskJobAttachments = attachment;
|
|
|
|
taskModel?.taskJobAttachments = attachment;
|
|
|
|
@ -608,218 +615,509 @@ bool validate({TaskData? model}) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (model?.assistantEmployees != null) {
|
|
|
|
if (model!.taskJobAssistantEmployees?.isNotEmpty ?? false) {
|
|
|
|
if (model?.modelAssistantEmployees?.startDate == null) {
|
|
|
|
for (int i = 0; i < model.taskJobAssistantEmployees!.length; i++) {
|
|
|
|
Fluttertoast.showToast(msg: "Please Select Assistant Employee Start Time");
|
|
|
|
final employee = model.taskJobAssistantEmployees![i];
|
|
|
|
return false;
|
|
|
|
final position = Utils.getOrdinal(i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (model?.modelAssistantEmployees?.endDate == null) {
|
|
|
|
if (employee.user == null) {
|
|
|
|
Fluttertoast.showToast(msg: "Please Select Assistant Employee End Time");
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
return false;
|
|
|
|
msg: "Please select the $position assistant employee",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (employee.user?.userId != null) {
|
|
|
|
|
|
|
|
if (employee.startDate == null) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
|
|
|
msg: "Please select start time for assistant employee ${employee.user?.userName}",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (employee.endDate == null) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
|
|
|
msg: "Please select end time for assistant employee ${employee.user?.userName}",
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class AssistantEmployeeCard extends StatefulWidget {
|
|
|
|
class TaskRequestAssistantEmployeeList extends StatefulWidget {
|
|
|
|
const AssistantEmployeeCard({super.key});
|
|
|
|
final List<TaskJobAssistantEmployees>? assistantEmployeeList;
|
|
|
|
|
|
|
|
final ValueChanged<List<TaskJobAssistantEmployees>>? onListChanged;
|
|
|
|
|
|
|
|
final double? cardPadding;
|
|
|
|
|
|
|
|
final dynamic assetId;
|
|
|
|
|
|
|
|
final String createdDate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TaskRequestAssistantEmployeeList({
|
|
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
|
|
this.assistantEmployeeList,
|
|
|
|
|
|
|
|
this.onListChanged,
|
|
|
|
|
|
|
|
required this.assetId,
|
|
|
|
|
|
|
|
this.cardPadding,
|
|
|
|
|
|
|
|
required this.createdDate,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
State<AssistantEmployeeCard> createState() => _AssistantEmployeeCardState();
|
|
|
|
State<TaskRequestAssistantEmployeeList> createState() => _TaskRequestAssistantEmployeeListState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _AssistantEmployeeCardState extends State<AssistantEmployeeCard> {
|
|
|
|
class _TaskRequestAssistantEmployeeListState extends State<TaskRequestAssistantEmployeeList> {
|
|
|
|
bool status = false;
|
|
|
|
late List<TaskJobAssistantEmployees> _list;
|
|
|
|
final TextEditingController _workingHoursController = TextEditingController(text: '');
|
|
|
|
late List<TextEditingController> _controllers;
|
|
|
|
bool isExpanded = false;
|
|
|
|
|
|
|
|
TaskData? taskModel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
TaskRequestProvider taskRequestProvider = Provider.of<TaskRequestProvider>(context, listen: false);
|
|
|
|
|
|
|
|
taskModel = taskRequestProvider.taskRequestModel;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_list = List<TaskJobAssistantEmployees>.from(widget.assistantEmployeeList ?? []);
|
|
|
|
|
|
|
|
_controllers = _list.map((e) => TextEditingController(text: e.workingHours?.toString() ?? '')).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
void _addNewEntry() {
|
|
|
|
void dispose() {
|
|
|
|
setState(() {
|
|
|
|
// TODO: implement dispose
|
|
|
|
_list.add(TaskJobAssistantEmployees());
|
|
|
|
|
|
|
|
_controllers.add(TextEditingController());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.onListChanged?.call(_list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_workingHoursController.dispose();
|
|
|
|
void _removeEntry(int index) {
|
|
|
|
super.dispose();
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_list.removeAt(index);
|
|
|
|
|
|
|
|
_controllers.removeAt(index);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.onListChanged?.call(_list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _updateModel(int index, void Function(TaskJobAssistantEmployees model) updateList, {bool updateController = false}) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
updateList(_list[index]);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Consumer<TaskRequestProvider>(builder: (context, taskRequestProvider, child) {
|
|
|
|
return ListView.builder(
|
|
|
|
return Column(
|
|
|
|
itemCount: _list.length + 1,
|
|
|
|
children: [
|
|
|
|
shrinkWrap: true,
|
|
|
|
SizedBox(
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
height: 56.toScreenHeight,
|
|
|
|
padding: EdgeInsets.all(widget.cardPadding ?? 16),
|
|
|
|
child: Row(
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
if (index == _list.length) {
|
|
|
|
|
|
|
|
return AppFilledButton(
|
|
|
|
|
|
|
|
label: "Add Assistant Employee".addTranslation,
|
|
|
|
|
|
|
|
maxWidth: true,
|
|
|
|
|
|
|
|
textColor: AppColor.textColor(context),
|
|
|
|
|
|
|
|
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
|
|
|
|
|
|
|
|
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
|
|
|
|
|
|
|
|
showIcon: true,
|
|
|
|
|
|
|
|
onPressed: _addNewEntry,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return EmployeeCard(
|
|
|
|
|
|
|
|
model: _list[index],
|
|
|
|
|
|
|
|
assetId: widget.assetId,
|
|
|
|
|
|
|
|
index: index,
|
|
|
|
|
|
|
|
createdDate: widget.createdDate,
|
|
|
|
|
|
|
|
// selectedEmployee: selectedEmployee,
|
|
|
|
|
|
|
|
onUpdate: (updateList) => _updateModel(index, updateList),
|
|
|
|
|
|
|
|
onRemove: () => _removeEntry(index),
|
|
|
|
|
|
|
|
workingHoursController: _controllers[index],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EmployeeCard extends StatelessWidget {
|
|
|
|
|
|
|
|
final TaskJobAssistantEmployees model;
|
|
|
|
|
|
|
|
final int index;
|
|
|
|
|
|
|
|
final dynamic assetId;
|
|
|
|
|
|
|
|
final String? createdDate;
|
|
|
|
|
|
|
|
final void Function(void Function(TaskJobAssistantEmployees model)) onUpdate;
|
|
|
|
|
|
|
|
final VoidCallback onRemove;
|
|
|
|
|
|
|
|
final TextEditingController workingHoursController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EmployeeCard({
|
|
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
|
|
required this.model,
|
|
|
|
|
|
|
|
required this.assetId,
|
|
|
|
|
|
|
|
required this.index,
|
|
|
|
|
|
|
|
required this.onUpdate,
|
|
|
|
|
|
|
|
this.createdDate,
|
|
|
|
|
|
|
|
required this.onRemove,
|
|
|
|
|
|
|
|
required this.workingHoursController,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AssistantEmployees selectedEmployee = AssistantEmployees();
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
context.translation.assistantEmployee.bodyText(context).custom(color: AppColor.textColor(context)),
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
height: 32,
|
|
|
|
|
|
|
|
width: 32,
|
|
|
|
|
|
|
|
padding: const EdgeInsets.all(6),
|
|
|
|
|
|
|
|
child: "trash".toSvgAsset(height: 20, width: 20),
|
|
|
|
|
|
|
|
).onPress(onRemove),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
ServiceReportAssistantEmployeeMenu(
|
|
|
|
|
|
|
|
title: context.translation.select,
|
|
|
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
assetId: assetId,
|
|
|
|
|
|
|
|
initialValue: model.employee,
|
|
|
|
|
|
|
|
onSelect: (employee) {
|
|
|
|
|
|
|
|
if (employee != null) {
|
|
|
|
|
|
|
|
onUpdate((model) {
|
|
|
|
|
|
|
|
model.employee = employee.copyWith(id: 0);
|
|
|
|
|
|
|
|
model.user = AssignedEmployee(
|
|
|
|
|
|
|
|
userId: employee.user?.id,
|
|
|
|
|
|
|
|
userName: employee.user?.name,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
8.height,
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
context.translation.assistantEmployee.heading6(context).custom(color: AppColor.textColor(context)),
|
|
|
|
ADatePicker(
|
|
|
|
Icon(isExpanded ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded),
|
|
|
|
label: context.translation.startTime,
|
|
|
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
date: model.startDate,
|
|
|
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
|
|
|
from: DateTime.tryParse(createdDate ?? ''),
|
|
|
|
|
|
|
|
onDatePicker: (selectedDate) {
|
|
|
|
|
|
|
|
showTimePicker(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
initialTime: TimeOfDay.now(),
|
|
|
|
|
|
|
|
).then((selectedTime) {
|
|
|
|
|
|
|
|
if (selectedTime != null) {
|
|
|
|
|
|
|
|
final selectedDateTime = DateTime(
|
|
|
|
|
|
|
|
selectedDate.year,
|
|
|
|
|
|
|
|
selectedDate.month,
|
|
|
|
|
|
|
|
selectedDate.day,
|
|
|
|
|
|
|
|
selectedTime.hour,
|
|
|
|
|
|
|
|
selectedTime.minute,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (createdDate != null && selectedDateTime.isBefore(DateTime.tryParse(createdDate ?? '')!)) {
|
|
|
|
|
|
|
|
"Start time is before the request time.".showToast;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedDateTime.isAfter(DateTime.now())) {
|
|
|
|
|
|
|
|
"Start time is after the current time".showToast;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onUpdate((model) {
|
|
|
|
|
|
|
|
model.startDate = selectedDateTime;
|
|
|
|
|
|
|
|
ServiceRequestUtils.calculateAndAssignWorkingHours(
|
|
|
|
|
|
|
|
startTime: model.startDate,
|
|
|
|
|
|
|
|
endTime: model.endDate,
|
|
|
|
|
|
|
|
workingHoursController: workingHoursController,
|
|
|
|
|
|
|
|
updateModel: (hours) => model.workingHours = hours,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
).expanded,
|
|
|
|
|
|
|
|
8.width,
|
|
|
|
|
|
|
|
ADatePicker(
|
|
|
|
|
|
|
|
label: context.translation.endTime,
|
|
|
|
|
|
|
|
hideShadow: true,
|
|
|
|
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
|
|
|
|
date: model.endDate,
|
|
|
|
|
|
|
|
formatDateWithTime: true,
|
|
|
|
|
|
|
|
from: DateTime.tryParse(createdDate ?? ''),
|
|
|
|
|
|
|
|
onDatePicker: (selectedDate) {
|
|
|
|
|
|
|
|
showTimePicker(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
|
|
initialTime: TimeOfDay.now(),
|
|
|
|
|
|
|
|
).then((selectedTime) {
|
|
|
|
|
|
|
|
if (selectedTime != null) {
|
|
|
|
|
|
|
|
final endDateTime = DateTime(
|
|
|
|
|
|
|
|
selectedDate.year,
|
|
|
|
|
|
|
|
selectedDate.month,
|
|
|
|
|
|
|
|
selectedDate.day,
|
|
|
|
|
|
|
|
selectedTime.hour,
|
|
|
|
|
|
|
|
selectedTime.minute,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!endDateTime.isBefore(DateTime.now())) {
|
|
|
|
|
|
|
|
"Please select a time before the current time.".showToast;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.startDate == null || !endDateTime.isAfter(model.startDate!)) {
|
|
|
|
|
|
|
|
"End date must be after start date".showToast;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onUpdate((model) {
|
|
|
|
|
|
|
|
model.endDate = endDateTime;
|
|
|
|
|
|
|
|
ServiceRequestUtils.calculateAndAssignWorkingHours(
|
|
|
|
|
|
|
|
startTime: model.startDate,
|
|
|
|
|
|
|
|
endTime: model.endDate,
|
|
|
|
|
|
|
|
workingHoursController: workingHoursController,
|
|
|
|
|
|
|
|
updateModel: (hours) => model.workingHours = hours,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
).expanded,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).onPress(() {
|
|
|
|
8.height,
|
|
|
|
setState(() {
|
|
|
|
AppTextFormField(
|
|
|
|
isExpanded = !isExpanded;
|
|
|
|
labelText: context.translation.workingHours,
|
|
|
|
});
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
}),
|
|
|
|
controller: workingHoursController,
|
|
|
|
isExpanded
|
|
|
|
suffixIcon: "clock".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null).paddingOnly(end: 16),
|
|
|
|
? Column(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
enable: false,
|
|
|
|
children: [
|
|
|
|
showShadow: false,
|
|
|
|
ServiceReportAssistantEmployeeMenu(
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
title: context.translation.select,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
),
|
|
|
|
initialValue: (taskModel?.assistantEmployees?.isNotEmpty ?? false) ? taskModel?.assistantEmployees?.first : null,
|
|
|
|
8.height,
|
|
|
|
onSelect: (employee) {
|
|
|
|
AppTextFormField(
|
|
|
|
if (employee == null) {
|
|
|
|
initialValue: model.comment,
|
|
|
|
taskModel?.assistantEmployees = [];
|
|
|
|
labelText: context.translation.technicalComment,
|
|
|
|
} else {
|
|
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
|
|
taskModel?.assistantEmployees = [employee.copyWith(id: 0)];
|
|
|
|
showShadow: false,
|
|
|
|
taskModel?.modelAssistantEmployees?.user = AssignedEmployee(userId: employee.user?.id, userName: employee.user?.name);
|
|
|
|
labelStyle: AppTextStyles.textFieldLabelStyle.copyWith(color: context.isDark ? AppColor.white10 : AppColor.black10),
|
|
|
|
}
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
},
|
|
|
|
textInputType: TextInputType.multiline,
|
|
|
|
),
|
|
|
|
onChange: (value) => onUpdate((model) => model.comment = value),
|
|
|
|
8.height,
|
|
|
|
// onSaved: (value) => onUpdate((model) => model.technicalComment = value),
|
|
|
|
Row(
|
|
|
|
),
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
8.height,
|
|
|
|
children: [
|
|
|
|
],
|
|
|
|
ADatePicker(
|
|
|
|
)
|
|
|
|
label: context.translation.startTime,
|
|
|
|
],
|
|
|
|
hideShadow: true,
|
|
|
|
).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)).paddingOnly(bottom: 12);
|
|
|
|
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(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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(),
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|