|
|
|
|
@ -21,7 +21,6 @@ import 'package:mohem_flutter_app/widgets/app_bar_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/button/simple_button.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/widgets/radio/show_radio.dart';
|
|
|
|
|
|
|
|
|
|
class MowadhafhiHRRequest extends StatefulWidget {
|
|
|
|
|
const MowadhafhiHRRequest({Key? key}) : super(key: key);
|
|
|
|
|
@ -42,7 +41,9 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
GetSectionTopics? selectedTopic;
|
|
|
|
|
List<File> attachmentFiles = [];
|
|
|
|
|
|
|
|
|
|
String selectedServiceType = "";
|
|
|
|
|
GetTicketTypes? selectedServiceType;
|
|
|
|
|
|
|
|
|
|
// String selectedServiceType = "";
|
|
|
|
|
String description = "";
|
|
|
|
|
int? projectID;
|
|
|
|
|
|
|
|
|
|
@ -58,69 +59,40 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
appBar: AppBarWidget(
|
|
|
|
|
context,
|
|
|
|
|
title: LocaleKeys.mowadhafhiRequest.tr(),
|
|
|
|
|
title: LocaleKeys.createRequest.tr(),
|
|
|
|
|
),
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: getTicketTypesList.isNotEmpty
|
|
|
|
|
? Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
|
|
|
|
margin: const EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: const Color(0xff000000).withOpacity(.05),
|
|
|
|
|
blurRadius: 26,
|
|
|
|
|
offset: const Offset(0, -3),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
body: getTicketTypesList.isNotEmpty
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView(
|
|
|
|
|
padding: const EdgeInsets.all(21),
|
|
|
|
|
children: [
|
|
|
|
|
LocaleKeys.serviceType.tr().toText16(),
|
|
|
|
|
12.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 40,
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.only(right: 6, top: 8, bottom: 8),
|
|
|
|
|
child: ShowRadio(
|
|
|
|
|
title: getTicketTypesList[index].typeName!,
|
|
|
|
|
value: getTicketTypesList[index].ticketTypeId!.toString(),
|
|
|
|
|
groupValue: selectedServiceType,
|
|
|
|
|
selectedColor: MyColors.gradiantStartColor),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
selectedServiceType = getTicketTypesList[index].ticketTypeId!.toString();
|
|
|
|
|
setState(() {});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) => 1.width,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: getTicketTypesList.length ?? 0,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
),
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.serviceType.tr(),
|
|
|
|
|
selectedServiceType?.typeName ?? LocaleKeys.selectTypeT.tr(),
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
LocaleKeys.departmentName.tr().toText16(),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getTicketTypesList.length; i++) PopupMenuItem<int>(child: Text(getTicketTypesList[i].typeName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
selectedServiceType = getTicketTypesList[popupIndex]; //.ticketTypeId!.toString();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.height,
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.selectDepartment.tr(),
|
|
|
|
|
selectedDepartment?.departmentName ?? "",
|
|
|
|
|
LocaleKeys.departmentName.tr(),
|
|
|
|
|
selectedDepartment?.departmentName ?? LocaleKeys.selectDepartment.tr(),
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getProjectDepartmentsList!.length; i++) PopupMenuItem<int>(child: Text(getProjectDepartmentsList![i].departmentName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
@ -130,17 +102,15 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.height,
|
|
|
|
|
LocaleKeys.relatedSection.tr().toText16(),
|
|
|
|
|
12.height,
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.selectSection.tr(),
|
|
|
|
|
selectedSection?.sectionName ?? "",
|
|
|
|
|
LocaleKeys.relatedSection.tr(),
|
|
|
|
|
selectedSection?.sectionName ?? LocaleKeys.selectSection.tr(),
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getDepartmentSectionsList!.length; i++) PopupMenuItem<int>(child: Text(getDepartmentSectionsList![i].sectionName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
@ -150,35 +120,29 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.height,
|
|
|
|
|
LocaleKeys.relatedTopic.tr().toText16(),
|
|
|
|
|
12.height,
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.selectTopic.tr(),
|
|
|
|
|
selectedTopic?.topicName ?? "",
|
|
|
|
|
LocaleKeys.relatedTopic.tr(),
|
|
|
|
|
selectedTopic?.topicName ?? LocaleKeys.selectTopic.tr(),
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
).paddingOnly(bottom: 12),
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getSectionTopicsList!.length; i++) PopupMenuItem<int>(child: Text(getSectionTopicsList![i].topicName!), value: i),
|
|
|
|
|
for (int i = 0; i < getSectionTopicsList.length; i++) PopupMenuItem<int>(child: Text(getSectionTopicsList[i].topicName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
selectedTopic = getSectionTopicsList![popupIndex];
|
|
|
|
|
selectedTopic = getSectionTopicsList[popupIndex];
|
|
|
|
|
// getDepartmentSections(selectedSection?.departmentSectionId);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.height,
|
|
|
|
|
LocaleKeys.supportingDocument.tr().toText16(),
|
|
|
|
|
12.height,
|
|
|
|
|
attachmentView("Attachments"),
|
|
|
|
|
12.height,
|
|
|
|
|
LocaleKeys.description.tr().toText16(),
|
|
|
|
|
attachmentView("Attachments").objectContainerView(title: LocaleKeys.supportingDocument.tr()),
|
|
|
|
|
12.height,
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
LocaleKeys.description.tr(),
|
|
|
|
|
LocaleKeys.writeAMessage.tr(),
|
|
|
|
|
isEnable: true,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 4,
|
|
|
|
|
@ -189,40 +153,25 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
description = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
50.height
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
),
|
|
|
|
|
bottomSheet: Container(
|
|
|
|
|
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
|
color: MyColors.white,
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
12.width,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: DefaultButton(
|
|
|
|
|
LocaleKeys.submit.tr(),
|
|
|
|
|
!checkValidation()
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
submitHRRequest();
|
|
|
|
|
},
|
|
|
|
|
color: const Color(0xFFD02127),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
12.width,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.submit.tr(),
|
|
|
|
|
!checkValidation()
|
|
|
|
|
? null
|
|
|
|
|
: () {
|
|
|
|
|
submitHRRequest();
|
|
|
|
|
},
|
|
|
|
|
color: const Color(0xFFD02127),
|
|
|
|
|
).insideContainer
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool checkValidation() {
|
|
|
|
|
if (selectedServiceType == "" || selectedDepartment == null || selectedSection == null || selectedTopic == null) {
|
|
|
|
|
if (selectedServiceType == null || selectedDepartment == null || selectedSection == null || selectedTopic == null) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
@ -230,69 +179,55 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget attachmentView(String title) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: const Color(0xff000000).withOpacity(.05),
|
|
|
|
|
blurRadius: 26,
|
|
|
|
|
offset: const Offset(0, -3),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText16().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
SimpleButton(LocaleKeys.add.tr(), () async {
|
|
|
|
|
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList();
|
|
|
|
|
attachmentFiles = attachmentFiles.toSet().toList();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}, fontSize: 14),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (attachmentFiles.isNotEmpty) 12.height,
|
|
|
|
|
if (attachmentFiles.isNotEmpty)
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
String fileName = attachmentFiles[index].path.split('/').last;
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText16().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
SimpleButton(LocaleKeys.add.tr(), () async {
|
|
|
|
|
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList();
|
|
|
|
|
attachmentFiles = attachmentFiles.toSet().toList();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}, fontSize: 14),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (attachmentFiles.isNotEmpty) 12.height,
|
|
|
|
|
if (attachmentFiles.isNotEmpty)
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
String fileName = attachmentFiles[index].path.split('/').last;
|
|
|
|
|
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
fileName.toText13().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
IconButton(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
iconSize: 20,
|
|
|
|
|
icon: const Icon(Icons.cancel_rounded),
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
attachmentFiles.removeAt(index);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 6.height,
|
|
|
|
|
itemCount: attachmentFiles.length),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
fileName.toText13().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
IconButton(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
iconSize: 20,
|
|
|
|
|
icon: const Icon(Icons.cancel_rounded),
|
|
|
|
|
color: MyColors.redColor,
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
attachmentFiles.removeAt(index);
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 6.height,
|
|
|
|
|
itemCount: attachmentFiles.length),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -376,7 +311,7 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int? messageStatus = await MowadhafhiApiClient().submitRequest(selectedDepartment?.projectDepartmentId, description, projectID, selectedSection?.departmentSectionId.toString(),
|
|
|
|
|
selectedTopic?.sectionTopicId.toString(), int.parse(selectedServiceType), list);
|
|
|
|
|
selectedTopic?.sectionTopicId.toString(), selectedServiceType!.ticketTypeId, list);
|
|
|
|
|
Utils.showToast(LocaleKeys.requestCreatedSuccessfully.tr());
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|