From ea5178fe207cebf21bc4be29e04671def92a4d89 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Tue, 21 Jun 2022 11:34:42 +0300 Subject: [PATCH] profle dynamic forms --- lib/api/profile_api_client.dart | 30 +++++++++- lib/models/generic_response_model.dart | 2 +- lib/ui/misc/request_submit_screen.dart | 28 +++++++--- .../dynamic_screens/dynamic_input_screen.dart | 2 +- .../my_attendance/my_attendance_screen.dart | 15 ++--- lib/ui/profile/basic_details.dart | 18 +----- lib/ui/profile/contact_details.dart | 52 ++--------------- .../dynamic_input_profile_screen.dart | 56 ++++++++++++++++--- lib/ui/profile/phone_numbers.dart | 14 +++-- lib/ui/screens/profile/profile_screen.dart | 3 + 10 files changed, 126 insertions(+), 94 deletions(-) diff --git a/lib/api/profile_api_client.dart b/lib/api/profile_api_client.dart index 676a8ed..5993a59 100644 --- a/lib/api/profile_api_client.dart +++ b/lib/api/profile_api_client.dart @@ -11,6 +11,7 @@ import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; import 'package:mohem_flutter_app/models/profile/phone_number_types_modek.dart'; import 'package:mohem_flutter_app/models/profile/submit_phone_transactions.dart'; +import 'package:mohem_flutter_app/models/start_eit_approval_process_model.dart'; import 'api_client.dart'; class ProfileApiClient { @@ -135,11 +136,36 @@ class ProfileApiClient { Future submitPhoneNumbers(List empList) async { String url = "${ApiConsts.erpRest}SUBMIT_PHONES_TRANSACTION"; - Map postParams = {"P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": -999, "P_FUNCTION_NAME": "HR_PERINFO_SS", "P_MBL_PHONES_TBL": empList}; + Map postParams = { + "P_MENU_TYPE": "E", + "P_SELECTED_RESP_ID": -999, + "P_FUNCTION_NAME": "HR_PERINFO_SS", + "P_MBL_PHONES_TBL": empList.map((element) { + return element.toJson(); + }).toList() + }; + + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject((json) { + GenericResponseModel? responseData = GenericResponseModel.fromJson(json); + return SubmitPhonesTransactionList.fromJson(responseData.submitPhonesTransactionList ?? {}); + }, url, postParams); + } + + Future startPhoneApprovalProcess(String action, String comments, String itemKey, int transactionId) async { + String url = "${ApiConsts.erpRest}START_PHONES_APPROVAL_PROCESS"; + Map postParams = { + "P_SELECTED_RESP_ID": -999, + "P_MENU_TYPE": "E", + "P_ACTION_MODE": action, + "P_COMMENTS": comments, + "P_ITEM_KEY": itemKey, + "P_TRANSACTION_ID": transactionId, + }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); - return responseData.submitPhonesTransactionList ?? SubmitPhonesTransactionList(); + return responseData.startEitApprovalProcess; }, url, postParams); } } diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart index 68d8bbb..1b91839 100644 --- a/lib/models/generic_response_model.dart +++ b/lib/models/generic_response_model.dart @@ -277,7 +277,7 @@ class GenericResponseModel { String? submitContactTransactionList; SubmitEITTransactionList? submitEITTransactionList; String? submitHrTransactionList; - SubmitPhonesTransactionList? submitPhonesTransactionList; + Map? submitPhonesTransactionList; String? submitSITTransactionList; String? submitTermTransactionList; List? subordinatesOnLeavesList; diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index a0722da..a4d0052 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -5,6 +5,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/my_attendance_api_client.dart'; +import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -25,8 +26,8 @@ class RequestSubmitScreenParams { String title; int transactionId; String pItemId; - - RequestSubmitScreenParams(this.title, this.transactionId, this.pItemId); + String approvalFlag; + RequestSubmitScreenParams(this.title, this.transactionId, this.pItemId, this.approvalFlag); } class RequestSubmitScreen extends StatefulWidget { @@ -83,12 +84,23 @@ class _RequestSubmitScreenState extends State { }); } await MyAttendanceApiClient().addAttachment(list); - await MyAttendanceApiClient().startEitApprovalProcess( - "SUBMIT", - comments.text, - params!.pItemId, - params!.transactionId, - ); + + if (params!.approvalFlag == 'phone_numbers') { + await ProfileApiClient().startPhoneApprovalProcess( + "SUBMIT", + comments.text, + params!.pItemId, + params!.transactionId, + ); + } else { + await MyAttendanceApiClient().startEitApprovalProcess( + "SUBMIT", + comments.text, + params!.pItemId, + params!.transactionId, + ); + } + Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourRequestHasBeenSubmittedForApprovals.tr(), longDuration: true); Navigator.of(context).popUntil((route) { diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index ec129c8..7ab59c9 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -79,7 +79,7 @@ class _DynamicInputScreenState extends State { genericResponseModel = await MyAttendanceApiClient().validateEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values); SubmitEITTransactionList submitEITTransactionList = await MyAttendanceApiClient().submitEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values); Utils.hideLoading(context); - Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams("title", submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!)); + Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams("title", submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!, 'eit')); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/my_attendance/my_attendance_screen.dart b/lib/ui/my_attendance/my_attendance_screen.dart index cb347a1..e1db55c 100644 --- a/lib/ui/my_attendance/my_attendance_screen.dart +++ b/lib/ui/my_attendance/my_attendance_screen.dart @@ -32,13 +32,14 @@ class MyAttendanceScreen extends StatelessWidget { ? LocaleKeys.noDataAvailable.tr().toText16().center : Column( children: [ - itemView( - "assets/images/pdf.svg", - LocaleKeys.missingSwipes.tr(), - ).onPress(() { - Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS")); - }), - 12.height, + //commenting this because missing wipe coming as duplicate in the screen + // itemView( + // "assets/images/pdf.svg", + // LocaleKeys.missingSwipes.tr(), + // ).onPress(() { + // Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS")); + // }), + // 12.height, ListView.separated( padding: const EdgeInsets.all(21), itemBuilder: (cxt, index) => itemView( diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index e74d21d..795563e 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -74,29 +74,13 @@ class _BasicDetailsState extends State { context, title: LocaleKeys.profile_basicDetails.tr(), ), - // appBar: AppBar( - // backgroundColor: MyColors.white, - // leading: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // IconButton( - // icon: const Icon( - // Icons.arrow_back_ios, - // color: MyColors.backgroundBlackColor, - // ), - // onPressed: () => Navigator.pop(context), - // ), - // "Basic Details".toText24(isBold: true, color: MyColors.blackColor), - // ], - // ), - // ), backgroundColor: MyColors.backgroundColor, bottomSheet: footer(), body: Column( children: [ Container( width: double.infinity, - margin: EdgeInsets.only(top: 20, left: 21, right: 21,bottom: 20), + margin: EdgeInsets.only(top: 20, left: 21, right: 21, bottom: 20), padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 5), height: 280, decoration: BoxDecoration( diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index d4927cf..9dbc462 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -84,7 +84,7 @@ class _ContactDetailsState extends State { left: 26, right: 26, ), - padding: EdgeInsets.only(left: 14, right: 14, top: 5, bottom: 20), + padding: EdgeInsets.all(15), ///height: 200, decoration: BoxDecoration( @@ -99,7 +99,7 @@ class _ContactDetailsState extends State { color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + child: Stack(children: [ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -122,17 +122,7 @@ class _ContactDetailsState extends State { "${e.pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), ])) .toList()) - ]) - - // [ - // "${getEmployeePhonesList[0].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeePhonesList[0].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20,), - // "${getEmployeePhonesList[1].pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeePhonesList[1].pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - // ] - ), + ])), Container( width: double.infinity, margin: EdgeInsets.only( @@ -140,8 +130,8 @@ class _ContactDetailsState extends State { left: 26, right: 26, ), - padding: EdgeInsets.only(left: 14, right: 14, top: 5, bottom: 20), - height: 400, + padding: EdgeInsets.all(15), + // height: 400, decoration: BoxDecoration( boxShadow: [ BoxShadow( @@ -154,7 +144,7 @@ class _ContactDetailsState extends State { color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + child: Stack(children: [ Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -179,36 +169,6 @@ class _ContactDetailsState extends State { ])) .toList()) ])) - // "${getEmployeeAddressList[0].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[0].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20, - // ), - // "${getEmployeeAddressList[2].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[2].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20, - // ), - // "${getEmployeeAddressList[3].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[3].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20, - // ), - // "${getEmployeeAddressList[4].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[4].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20, - // ), - // "${getEmployeeAddressList[5].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[5].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // SizedBox( - // height: 20, - // ), - // "${getEmployeeAddressList[6].sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${getEmployeeAddressList[6].sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - //]), - //), - //], ]))); } diff --git a/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart b/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart index 3e25917..95d80a9 100644 --- a/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart +++ b/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart @@ -1,23 +1,25 @@ import 'dart:io'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/my_attendance_api_client.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/dyanmic_forms/get_set_values_request_model.dart'; +import 'package:mohem_flutter_app/models/dyanmic_forms/validate_eit_transaction_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/get_eit_dff_structure_list_model.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/get_employee_contacts.model.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_cols_structions.dart'; import 'package:mohem_flutter_app/models/profile/basic_details_dff_structure.dart'; +import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -31,7 +33,6 @@ class DynamicProfileParams { String colsURL; List? getEmployeeBasicDetailsList; - DynamicProfileParams(this.title, this.dynamicId, {this.uRL = 'GET_EIT_DFF_STRUCTURE', this.requestID = '', this.colsURL = '', this.getEmployeeBasicDetailsList = const []}); } @@ -51,6 +52,7 @@ class _DynamicInputScreenState extends State { List? getBasicDetColsStructureList; DynamicProfileParams? dynamicParams; + String dESCFLEXCONTEXTCODE = ""; @override void initState() { super.initState(); @@ -153,11 +155,7 @@ class _DynamicInputScreenState extends State { // 12.height, DefaultButton( LocaleKeys.next.tr(), - (getBasicDetDffStructureList ?? []).isEmpty - ? null - : () => { - //Navigator.of(context).pushNamed(LOGIN_TYPE) - }, + (getBasicDetDffStructureList ?? []).isEmpty ? null : () => {validateTransaction()}, ).insideContainer, ], ), @@ -194,7 +192,6 @@ class _DynamicInputScreenState extends State { isReadOnly: model.rEADONLY == "Y", onChange: (text) { getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = text; - }, ).paddingOnly(bottom: 12); } else if (model.fORMATTYPE == "X") { @@ -326,4 +323,47 @@ class _DynamicInputScreenState extends State { } return time; } + + void validateTransaction() async { + try { + Utils.showLoading(context); + List> values = getBasicDetDffStructureList!.map((e) { + String tempVar = e.eSERVICESDV?.pIDCOLUMNNAME ?? ""; + if (e.fORMATTYPE == "X") { + // for date format type, date format is changed + tempVar = e.eSERVICESDV?.pVALUECOLUMNNAME ?? ""; + if (tempVar.isNotEmpty) { + DateTime date = DateFormat('yyyy-MM-dd').parse(tempVar); + tempVar = DateFormat('yyyy/MM/dd HH:mm:ss').format(date); + } + } + return ValidateEitTransactionModel(dATEVALUE: null, nAME: e.aPPLICATIONCOLUMNNAME, nUMBERVALUE: null, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: tempVar.toString()).toJson(); + }).toList(); + + values.add(ValidateEitTransactionModel(dATEVALUE: null, nAME: "PEI_ACTION", nUMBERVALUE: null, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: "NEW_ROW").toJson()); + values.add(ValidateEitTransactionModel(dATEVALUE: null, nAME: "PEI_EXTRA_INFO_ID", nUMBERVALUE: -1, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: null).toJson()); + values.add(ValidateEitTransactionModel(dATEVALUE: null, nAME: "PEI_OBJECT_VERSION_NUMBER", nUMBERVALUE: 0, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: null).toJson()); + List> valuesCols = getBasicDetColsStructureList!.map((e) { + String tempVar = e.userBasicDetail!.vARCHAR2VALUE ?? ""; + if (e.dATATYPE == "DATE") { + // for date format type, date format is changed + tempVar = e.userBasicDetail!.dATEVALUE ?? ""; + if (tempVar.isNotEmpty) { + DateTime date = DateFormat('yyyy-MM-dd').parse(tempVar); + tempVar = DateFormat('yyyy/MM/dd HH:mm:ss').format(date); + } + } + return ValidateEitTransactionModel(dATEVALUE: tempVar, nAME: e.aPPLICATIONCOLUMNNAME, nUMBERVALUE: null, tRANSACTIONNUMBER: 1, vARCHAR2VALUE: tempVar.toString()).toJson(); + }).toList(); + List> transactionValues = new List.from(values)..addAll(valuesCols); + print(transactionValues); + //genericResponseModel = await MyAttendanceApiClient().validateEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values); + // SubmitEITTransactionList submitEITTransactionList = await MyAttendanceApiClient().submitEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values); + Utils.hideLoading(context); + // Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams("title", submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!, 'eit')); + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } + } } diff --git a/lib/ui/profile/phone_numbers.dart b/lib/ui/profile/phone_numbers.dart index 9136c0f..14ce3ff 100644 --- a/lib/ui/profile/phone_numbers.dart +++ b/lib/ui/profile/phone_numbers.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.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'; @@ -14,6 +15,7 @@ import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/models/get_employee_phones_model.dart'; import 'package:mohem_flutter_app/models/profile/phone_number_types_modek.dart'; import 'package:mohem_flutter_app/models/profile/submit_phone_transactions.dart'; +import 'package:mohem_flutter_app/ui/misc/request_submit_screen.dart'; import 'package:mohem_flutter_app/ui/profile/profile.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; @@ -174,15 +176,19 @@ class _PhoneNumbersState extends State { Utils.showLoading(context); setUpdateStatus(); submitPhoneNumbers = await ProfileApiClient().submitPhoneNumbers(widget.getEmployeePhonesList); - setState(() {}); - Utils.hideLoading(context); - print(widget.getEmployeePhonesList); + Utils.hideLoading(context); + Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, + arguments: RequestSubmitScreenParams(LocaleKeys.profile_contactDetails.tr(), submitPhoneNumbers.pTRANSACTIONID!, submitPhoneNumbers.pITEMKEY!, 'phone_numbers')); } void setUpdateStatus() { widget.getEmployeePhonesList.forEach((element) { - if (element.aCTION == null) element.aCTION = 'UPDATE_ROW'; + if (element.aCTION == null) { + element.aCTION = 'UPDATE_ROW'; + element.dATEFROM = ''; + element.dATETO = ''; + } }); } diff --git a/lib/ui/screens/profile/profile_screen.dart b/lib/ui/screens/profile/profile_screen.dart index 76f8a20..8b015b0 100644 --- a/lib/ui/screens/profile/profile_screen.dart +++ b/lib/ui/screens/profile/profile_screen.dart @@ -27,7 +27,10 @@ class _ProfileScreenState extends State { @override void initState() { super.initState(); + memberInformationList = AppState().memberInformationList!; + + setState(() {}); //getEmployeeBasicDetails(); }