Mowadhafhi request completed

merge-requests/1/merge
haroon amjad 3 years ago
parent cf523566cd
commit 9e8bc47f7e

@ -2,8 +2,13 @@ import 'package:mohem_flutter_app/api/api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_department_sections.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_project_departments.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_projects.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_section_topics.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart';
import '../../models/mowadhafhi/get_tickets_list.dart'; import '../../models/mowadhafhi/get_tickets_list.dart';
@ -47,4 +52,85 @@ class MowadhafhiApiClient {
}, url, postParams); }, url, postParams);
} }
Future<List<GetTicketTypes>> getTicketTypes() async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_GetTicketTypes";
Map<String, dynamic> postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.getTicketTypes ?? [];
}, url, postParams);
}
Future<List<GetMowadhafhiProjects>> getProjects() async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_GetProjects";
Map<String, dynamic> postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgProjectCode": AppState().memberInformationList?.pAYROLLCODE};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.getMowadhafhiProjects ?? [];
}, url, postParams);
}
Future<List<GetProjectDepartments>> getProjectDepartments(int projectID) async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_GetProjectDepartments";
Map<String, dynamic> postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgProjectId": projectID};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.getProjectDepartments ?? [];
}, url, postParams);
}
Future<List<GetDepartmentSections>> getDepartmentSections(int? projectDepartmentID) async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_GetDepartmentSections";
Map<String, dynamic> postParams = {
"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER,
"ItgDepartmentSectionId": projectDepartmentID,
"ItgProjectDepartmentId": projectDepartmentID
};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.getDepartmentSections ?? [];
}, url, postParams);
}
Future<List<GetSectionTopics>> getSectionTopics(int? departmentSectionID) async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_GetSectionTopics";
Map<String, dynamic> postParams = {"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER, "ItgDepartmentSectionId": departmentSectionID};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.getSectionTopics ?? [];
}, url, postParams);
}
Future<int?> submitRequest(int? departmentID, String description, int? projectID, String? sectionID, String? sectionTopicID, int? ticketTypeID, List<Map<String, dynamic>> attachmentList) async {
String url = "${ApiConsts.cocRest}Mohemm_ITG_CreateTicketMobile";
Map<String, dynamic> postParams = {
"EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER,
"ItgImageCollList" : attachmentList,
"channelId": 3,
"departmentId": departmentID,
"description": description,
"employeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER,
"projectId": projectID,
"sectionId": sectionID,
"sectionTopicId": sectionTopicID,
"ticketStatus": "new",
"ticketTypeId": ticketTypeID
};
postParams.addAll(AppState().postParamsJson);
return await ApiClient().postJsonForObject((json) {
GenericResponseModel? responseData = GenericResponseModel.fromJson(json);
return responseData.messageStatus;
}, url, postParams);
}
} }

@ -21,6 +21,7 @@ import 'package:mohem_flutter_app/ui/profile/personal_info.dart';
// import 'package:mohem_flutter_app/ui/my_attendance/work_from_home_screen.dart'; // import 'package:mohem_flutter_app/ui/my_attendance/work_from_home_screen.dart';
import 'package:mohem_flutter_app/ui/screens/eit/add_eit.dart'; import 'package:mohem_flutter_app/ui/screens/eit/add_eit.dart';
import 'package:mohem_flutter_app/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart';
import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart'; import 'package:mohem_flutter_app/ui/screens/mowadhafhi/request_details.dart';
import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart'; import 'package:mohem_flutter_app/ui/screens/profile/profile_screen.dart';
import 'package:mohem_flutter_app/ui/screens/submenu_screen.dart'; import 'package:mohem_flutter_app/ui/screens/submenu_screen.dart';
@ -80,6 +81,7 @@ class AppRoutes {
// Mowadhafhi // Mowadhafhi
static const String mowadhafhi = "/mowadhafhi"; static const String mowadhafhi = "/mowadhafhi";
static const String mowadhafhiDetails = "/mowadhafhiDetails"; static const String mowadhafhiDetails = "/mowadhafhiDetails";
static const String mowadhafhiHRRequest = "/mowadhafhiHRRequest";
static final Map<String, WidgetBuilder> routes = { static final Map<String, WidgetBuilder> routes = {
login: (context) => LoginScreen(), login: (context) => LoginScreen(),
@ -127,5 +129,6 @@ class AppRoutes {
//mowadhafhi //mowadhafhi
mowadhafhi: (context) => MowadhafhiHome(), mowadhafhi: (context) => MowadhafhiHome(),
mowadhafhiDetails: (context) => MowadhafhiRequestDetails(), mowadhafhiDetails: (context) => MowadhafhiRequestDetails(),
mowadhafhiHRRequest: (context) => MowadhafhiHRRequest(),
}; };
} }

@ -24,8 +24,13 @@ import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_mod
import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart'; import 'package:mohem_flutter_app/models/get_stamp_ns_notification_body_list_model.dart';
import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart'; import 'package:mohem_flutter_app/models/get_time_card_summary_list_model.dart';
import 'package:mohem_flutter_app/models/member_login_list_model.dart'; import 'package:mohem_flutter_app/models/member_login_list_model.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_department_sections.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_project_departments.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_projects.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_section_topics.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_details.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_transactions.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart';
import 'package:mohem_flutter_app/models/notification_action_model.dart'; import 'package:mohem_flutter_app/models/notification_action_model.dart';
import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart'; import 'package:mohem_flutter_app/models/notification_get_respond_attributes_list_model.dart';
@ -192,6 +197,11 @@ class GenericResponseModel {
List<GetTicketsByEmployeeList>? getTicketsByEmployeeList; List<GetTicketsByEmployeeList>? getTicketsByEmployeeList;
List<GetTicketDetailsByEmployee>? getTicketDetailsByEmployee; List<GetTicketDetailsByEmployee>? getTicketDetailsByEmployee;
List<GetTicketTransactions>? getTicketTransactions; List<GetTicketTransactions>? getTicketTransactions;
List<GetTicketTypes>? getTicketTypes;
List<GetSectionTopics>? getSectionTopics;
List<GetMowadhafhiProjects>? getMowadhafhiProjects;
List<GetProjectDepartments>? getProjectDepartments;
List<GetDepartmentSections>? getDepartmentSections;
List<String>? getUserItemTypesList; List<String>? getUserItemTypesList;
List<String>? getVacationRulesList; List<String>? getVacationRulesList;
List<String>? getVaccinationOnHandList; List<String>? getVaccinationOnHandList;
@ -448,6 +458,11 @@ class GenericResponseModel {
this.getTicketsByEmployeeList, this.getTicketsByEmployeeList,
this.getTicketDetailsByEmployee, this.getTicketDetailsByEmployee,
this.getTicketTransactions, this.getTicketTransactions,
this.getTicketTypes,
this.getSectionTopics,
this.getMowadhafhiProjects,
this.getProjectDepartments,
this.getDepartmentSections,
this.getUserItemTypesList, this.getUserItemTypesList,
this.getVacationRulesList, this.getVacationRulesList,
this.getVaccinationOnHandList, this.getVaccinationOnHandList,
@ -874,6 +889,41 @@ class GenericResponseModel {
}); });
} }
if (json['Mohemm_Itg_TicketTypesList'] != null) {
getTicketTypes = <GetTicketTypes>[];
json['Mohemm_Itg_TicketTypesList'].forEach((v) {
getTicketTypes!.add(new GetTicketTypes.fromJson(v));
});
}
if (json['Mohemm_Itg_ProjectsList'] != null) {
getMowadhafhiProjects = <GetMowadhafhiProjects>[];
json['Mohemm_Itg_ProjectsList'].forEach((v) {
getMowadhafhiProjects!.add(new GetMowadhafhiProjects.fromJson(v));
});
}
if (json['Mohemm_ITG_ProjectDepartmentsList'] != null) {
getProjectDepartments = <GetProjectDepartments>[];
json['Mohemm_ITG_ProjectDepartmentsList'].forEach((v) {
getProjectDepartments!.add(new GetProjectDepartments.fromJson(v));
});
}
if (json['Mohemm_ITG_DepartmentSectionsList'] != null) {
getDepartmentSections = <GetDepartmentSections>[];
json['Mohemm_ITG_DepartmentSectionsList'].forEach((v) {
getDepartmentSections!.add(new GetDepartmentSections.fromJson(v));
});
}
if (json['Mohemm_ITG_SectionTopicsList'] != null) {
getSectionTopics = <GetSectionTopics>[];
json['Mohemm_ITG_SectionTopicsList'].forEach((v) {
getSectionTopics!.add(new GetSectionTopics.fromJson(v));
});
}
getUserItemTypesList = json['GetUserItemTypesList']; getUserItemTypesList = json['GetUserItemTypesList'];
getVacationRulesList = json['GetVacationRulesList']; getVacationRulesList = json['GetVacationRulesList'];
getVaccinationOnHandList = json['GetVaccinationOnHandList']; getVaccinationOnHandList = json['GetVaccinationOnHandList'];

@ -0,0 +1,44 @@
class GetDepartmentSections {
int? departmentId;
String? departmentName;
int? departmentSectionId;
String? projectCode;
int? projectId;
String? projectName;
int? sectionId;
String? sectionName;
GetDepartmentSections(
{this.departmentId,
this.departmentName,
this.departmentSectionId,
this.projectCode,
this.projectId,
this.projectName,
this.sectionId,
this.sectionName});
GetDepartmentSections.fromJson(Map<String, dynamic> json) {
departmentId = json['departmentId'];
departmentName = json['departmentName'];
departmentSectionId = json['departmentSectionId'];
projectCode = json['projectCode'];
projectId = json['projectId'];
projectName = json['projectName'];
sectionId = json['sectionId'];
sectionName = json['sectionName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['departmentId'] = this.departmentId;
data['departmentName'] = this.departmentName;
data['departmentSectionId'] = this.departmentSectionId;
data['projectCode'] = this.projectCode;
data['projectId'] = this.projectId;
data['projectName'] = this.projectName;
data['sectionId'] = this.sectionId;
data['sectionName'] = this.sectionName;
return data;
}
}

@ -0,0 +1,32 @@
class GetProjectDepartments {
int? departmentId;
String? departmentName;
String? projectCode;
int? projectDepartmentId;
String? projectName;
GetProjectDepartments(
{this.departmentId,
this.departmentName,
this.projectCode,
this.projectDepartmentId,
this.projectName});
GetProjectDepartments.fromJson(Map<String, dynamic> json) {
departmentId = json['departmentId'];
departmentName = json['departmentName'];
projectCode = json['projectCode'];
projectDepartmentId = json['projectDepartmentId'];
projectName = json['projectName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['departmentId'] = this.departmentId;
data['departmentName'] = this.departmentName;
data['projectCode'] = this.projectCode;
data['projectDepartmentId'] = this.projectDepartmentId;
data['projectName'] = this.projectName;
return data;
}
}

@ -0,0 +1,18 @@
class GetMowadhafhiProjects {
int? projectId;
String? projectName;
GetMowadhafhiProjects({this.projectId, this.projectName});
GetMowadhafhiProjects.fromJson(Map<String, dynamic> json) {
projectId = json['projectId'];
projectName = json['projectName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['projectId'] = this.projectId;
data['projectName'] = this.projectName;
return data;
}
}

@ -0,0 +1,60 @@
class GetSectionTopics {
int? departmentId;
String? departmentName;
String? projectCode;
int? projectDepartmentId;
int? projectId;
String? projectName;
int? sectionId;
String? sectionName;
int? sectionTopicId;
int? tatInHours;
int? topicId;
String? topicName;
GetSectionTopics(
{this.departmentId,
this.departmentName,
this.projectCode,
this.projectDepartmentId,
this.projectId,
this.projectName,
this.sectionId,
this.sectionName,
this.sectionTopicId,
this.tatInHours,
this.topicId,
this.topicName});
GetSectionTopics.fromJson(Map<String, dynamic> json) {
departmentId = json['departmentId'];
departmentName = json['departmentName'];
projectCode = json['projectCode'];
projectDepartmentId = json['projectDepartmentId'];
projectId = json['projectId'];
projectName = json['projectName'];
sectionId = json['sectionId'];
sectionName = json['sectionName'];
sectionTopicId = json['sectionTopicId'];
tatInHours = json['tatInHours'];
topicId = json['topicId'];
topicName = json['topicName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['departmentId'] = this.departmentId;
data['departmentName'] = this.departmentName;
data['projectCode'] = this.projectCode;
data['projectDepartmentId'] = this.projectDepartmentId;
data['projectId'] = this.projectId;
data['projectName'] = this.projectName;
data['sectionId'] = this.sectionId;
data['sectionName'] = this.sectionName;
data['sectionTopicId'] = this.sectionTopicId;
data['tatInHours'] = this.tatInHours;
data['topicId'] = this.topicId;
data['topicName'] = this.topicName;
return data;
}
}

@ -0,0 +1,21 @@
class GetTicketTypes {
String? ticketIdPrefix;
int? ticketTypeId;
String? typeName;
GetTicketTypes({this.ticketIdPrefix, this.ticketTypeId, this.typeName});
GetTicketTypes.fromJson(Map<String, dynamic> json) {
ticketIdPrefix = json['ticketIdPrefix'];
ticketTypeId = json['ticketTypeId'];
typeName = json['typeName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ticketIdPrefix'] = this.ticketIdPrefix;
data['ticketTypeId'] = this.ticketTypeId;
data['typeName'] = this.typeName;
return data;
}
}

@ -0,0 +1,22 @@
class MowadhafhiRequestAttachment {
String? base64Data;
String? fileName;
String? contentType;
MowadhafhiRequestAttachment(
{this.base64Data, this.fileName, this.contentType});
MowadhafhiRequestAttachment.fromJson(Map<String, dynamic> json) {
base64Data = json['Base64Data'];
fileName = json['FileName'];
contentType = json['ContentType'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['Base64Data'] = this.base64Data;
data['FileName'] = this.fileName;
data['ContentType'] = this.contentType;
return data;
}
}

@ -1,3 +1,4 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:mohem_flutter_app/api/mowadhafhi/mowadhafhi_api_client.dart'; import 'package:mohem_flutter_app/api/mowadhafhi/mowadhafhi_api_client.dart';
@ -6,7 +7,9 @@ import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart'; import 'package:mohem_flutter_app/models/mowadhafhi/get_tickets_list.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import '../../../widgets/app_bar_widget.dart'; import '../../../widgets/app_bar_widget.dart';
@ -99,10 +102,22 @@ class _MowadhafhiHomeState extends State<MowadhafhiHome> {
); );
}, },
separatorBuilder: (BuildContext context, int index) => 12.height, separatorBuilder: (BuildContext context, int index) => 12.height,
itemCount: getTicketsByEmployeeList.length ?? 0)) itemCount: getTicketsByEmployeeList.length ?? 0)),
80.height
], ],
), ),
), ),
bottomSheet: Container(
decoration: const BoxDecoration(
color: MyColors.white,
boxShadow: [
BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3),
],
),
child: DefaultButton(LocaleKeys.createRequest.tr(), () async {
openHRRequest();
}).insideContainer,
)
); );
} }
@ -110,9 +125,16 @@ class _MowadhafhiHomeState extends State<MowadhafhiHome> {
await Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: itgTicketID); await Navigator.pushNamed(context, AppRoutes.mowadhafhiDetails, arguments: itgTicketID);
} }
void openHRRequest() async {
await Navigator.pushNamed(context, AppRoutes.mowadhafhiHRRequest).then((value) {
getOpenTickets();
});
}
void getOpenTickets() async { void getOpenTickets() async {
try { try {
Utils.showLoading(context); Utils.showLoading(context);
getTicketsByEmployeeList.clear();
getTicketsByEmployeeList = await MowadhafhiApiClient().getTicketsByEmployee(); getTicketsByEmployeeList = await MowadhafhiApiClient().getTicketsByEmployee();
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});

@ -0,0 +1,387 @@
import 'dart:convert';
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/api/mowadhafhi/mowadhafhi_api_client.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_department_sections.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_project_departments.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_projects.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_section_topics.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/get_ticket_types.dart';
import 'package:mohem_flutter_app/models/mowadhafhi/mowadhafhi_attachement_request.dart';
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);
@override
_MowadhafhiHRRequestState createState() => _MowadhafhiHRRequestState();
}
class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
List<GetTicketTypes> getTicketTypesList = [];
List<GetMowadhafhiProjects> getMowadhafhiProjectsList = [];
List<GetProjectDepartments> getProjectDepartmentsList = [];
List<GetDepartmentSections> getDepartmentSectionsList = [];
List<GetSectionTopics> getSectionTopicsList = [];
GetProjectDepartments? selectedDepartment;
GetDepartmentSections? selectedSection;
GetSectionTopics? selectedTopic;
List<File> attachmentFiles = [];
String selectedServiceType = "";
String description = "";
int? projectID;
@override
void initState() {
getTicketTypes();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBarWidget(
context,
title: "Mowadhafhi Request",
),
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,
children: [
"Service Type: ".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(() {
debugPrint(getTicketTypesList[index].typeName!);
selectedServiceType = getTicketTypesList[index].ticketTypeId!.toString();
setState(() {});
});
},
separatorBuilder: (context, index) => 1.width,
shrinkWrap: true,
itemCount: getTicketTypesList.length ?? 0,
scrollDirection: Axis.horizontal,
),
),
],
),
12.height,
"Department Name: ".toText16(),
12.height,
PopupMenuButton(
child: DynamicTextFieldWidget(
"Select Department",
selectedDepartment?.departmentName ?? "",
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),
],
onSelected: (int popupIndex) {
selectedDepartment = getProjectDepartmentsList![popupIndex];
getDepartmentSections(selectedDepartment?.projectDepartmentId);
setState(() {});
}),
12.height,
"Related Section: ".toText16(),
12.height,
PopupMenuButton(
child: DynamicTextFieldWidget(
"Select Section",
selectedSection?.sectionName ?? "",
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),
],
onSelected: (int popupIndex) {
selectedSection = getDepartmentSectionsList![popupIndex];
getSectionTopics(selectedSection?.departmentSectionId);
setState(() {});
}),
12.height,
"Related Topic: ".toText16(),
12.height,
PopupMenuButton(
child: DynamicTextFieldWidget(
"Select Topic",
selectedTopic?.topicName ?? "",
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),
],
onSelected: (int popupIndex) {
selectedTopic = getSectionTopicsList![popupIndex];
// getDepartmentSections(selectedSection?.departmentSectionId);
setState(() {});
}),
12.height,
"Supporting Document: ".toText16(),
12.height,
attachmentView("Attachments"),
12.height,
"Description: ".toText16(),
12.height,
DynamicTextFieldWidget(
"",
"",
isEnable: true,
isPopup: false,
lines: 4,
isInputTypeNum: false,
isReadOnly: false,
onChange: (String value) {
debugPrint(value);
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(
"Submit",
!checkValidation()
? null
: () {
submitHRRequest();
},
color: const Color(0xFFD02127),
),
),
12.width,
],
),
),
);
}
bool checkValidation() {
if (selectedServiceType == "" || selectedDepartment == null || selectedSection == null || selectedTopic == null) {
return false;
} else {
return true;
}
}
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("Add", () 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),
],
),
);
}
void getTicketTypes() async {
try {
Utils.showLoading(context);
getTicketTypesList = await MowadhafhiApiClient().getTicketTypes();
Utils.hideLoading(context);
getMowadhafhiProjects();
// setState(() {});
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getMowadhafhiProjects() async {
try {
Utils.showLoading(context);
getMowadhafhiProjectsList = await MowadhafhiApiClient().getProjects();
Utils.hideLoading(context);
getProjectDepartments(getMowadhafhiProjectsList[0].projectId!);
projectID = getMowadhafhiProjectsList[0].projectId!;
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getProjectDepartments(int projectID) async {
try {
Utils.showLoading(context);
getProjectDepartmentsList = await MowadhafhiApiClient().getProjectDepartments(projectID);
Utils.hideLoading(context);
setState(() {});
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getDepartmentSections(int? projectDepartmentID) async {
try {
Utils.showLoading(context);
getDepartmentSectionsList = await MowadhafhiApiClient().getDepartmentSections(projectDepartmentID);
Utils.hideLoading(context);
setState(() {});
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getSectionTopics(int? departmentSectionID) async {
try {
Utils.showLoading(context);
getSectionTopicsList = await MowadhafhiApiClient().getSectionTopics(departmentSectionID);
Utils.hideLoading(context);
setState(() {});
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void submitHRRequest() async {
try {
Utils.showLoading(context);
List<Map<String, dynamic>> list = [];
if (attachmentFiles.isNotEmpty) {
for (int i = 0; i < attachmentFiles.length; i++) {
String type = attachmentFiles[i].path.split('.').last;
String name = attachmentFiles[i].path.split('/').last;
List<int> fileContent = await attachmentFiles[i].readAsBytes();
String encodedFile = base64Encode(fileContent);
list.add(MowadhafhiRequestAttachment(
contentType: "image/" + type,
fileName: name,
base64Data: encodedFile,
).toJson());
}
}
int? messageStatus = await MowadhafhiApiClient().submitRequest(selectedDepartment?.projectDepartmentId, description, projectID, selectedSection?.departmentSectionId.toString(),
selectedTopic?.sectionTopicId.toString(), int.parse(selectedServiceType), list);
Utils.showToast("Request created successfully");
Utils.hideLoading(context);
Navigator.pop(context);
} catch (ex) {
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
}
Loading…
Cancel
Save