From c51af6522cc2707f05f3a799005a197a756ebf6c Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 7 Dec 2022 10:55:42 +0300 Subject: [PATCH 1/3] fix issues --- assets/langs/ar-SA.json | 3 +++ assets/langs/en-US.json | 3 +++ lib/classes/consts.dart | 4 ++-- lib/generated/codegen_loader.g.dart | 16 ++++++++++++-- lib/generated/locale_keys.g.dart | 3 +++ .../add_leave_balance_screen.dart | 10 ++++----- lib/ui/misc/request_submit_screen.dart | 22 +++++++++---------- lib/ui/profile/contact_details.dart | 12 +++++----- 8 files changed, 47 insertions(+), 26 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 59c0814..65f81ea 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -424,6 +424,9 @@ "typeCurrentPasswordBelow": "اكتب كلمة المرور الحاليه", "currentPassword": "كلمة المرور الحاليه", "concurrentReports": "التقارير المتزامنه", + "EnterNewAddressMoved" : "أدخل عنوان جديد إذا كنت قد انتقلت", + "CorrectAddress": "تصحيح أو تعديل هذا العنوان", + "SelectChangeWantToMake": " حدد نوع التغيير الذي تريد القيام به.", "profile": { "reset_password": { "label": "Reset Password", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index b0ab50e..647a956 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -424,6 +424,9 @@ "typeCurrentPasswordBelow": "Type Your Current password below", "currentPassword": "Current password", "concurrentReports": "Concurrent Reports", + "EnterNewAddressMoved" : "Enter a new address if you have moved", + "CorrectAddress": "Correct or amend this address", + "SelectChangeWantToMake": "Select the type of change you want to make", "profile": { "reset_password": { "label": "Reset Password", diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 944a29b..45bfcf9 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -2,8 +2,8 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - static String baseUrl = "https://hmgwebservices.com"; // Live server + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index a54ff37..95f1d94 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -440,6 +440,9 @@ class CodegenLoader extends AssetLoader{ "typeCurrentPasswordBelow": "اكتب كلمة المرور الحاليه", "currentPassword": "كلمة المرور الحاليه", "concurrentReports": "التقارير المتزامنه", + "EnterNewAddressMoved": "أدخل عنوان جديد إذا كنت قد انتقلت", + "CorrectAddress": "تصحيح أو تعديل هذا العنوان", + "SelectChangeWantToMake": " حدد نوع التغيير الذي تريد القيام به.", "profile": { "reset_password": { "label": "Reset Password", @@ -516,7 +519,10 @@ class CodegenLoader extends AssetLoader{ "codeExpire": "انتهت صلاحية رمز التحقق", "typeheretoreply": "اكتب هنا للرد", "favorite": "مفضلتي", - "searchfromchat": "البحث من الدردشة" + "searchfromchat": "البحث من الدردشة", + "yourAnswerCorrect": "إجابتك صحيحة", + "youMissedTheQuestion": "فاتك !! أنت خارج اللعبة. لكن يمكنك المتابعة.", + "wrongAnswer": "إجابة خاطئة! أنت خارج اللعبة. لكن يمكنك المتابعة." }; static const Map en_US = { "mohemm": "Mohemm", @@ -944,6 +950,9 @@ static const Map en_US = { "typeCurrentPasswordBelow": "Type Your Current password below", "currentPassword": "Current password", "concurrentReports": "Concurrent Reports", + "EnterNewAddressMoved": "Enter a new address if you have moved", + "CorrectAddress": "Correct or amend this address", + "SelectChangeWantToMake": "Select the type of change you want to make", "profile": { "reset_password": { "label": "Reset Password", @@ -1020,7 +1029,10 @@ static const Map en_US = { "allQuestionsCorrect": "You have answered all questions correct", "typeheretoreply": "Type here to reply", "favorite": "My Favorites", - "searchfromchat": "Search from chat" + "searchfromchat": "Search from chat", + "yourAnswerCorrect": "Your answer is correct", + "youMissedTheQuestion": "You Missed !! You are out of the game. But you can follow up.", + "wrongAnswer": "Wrong Answer! You are out of the game. But you can follow up." }; static const Map> mapLocales = {"ar_SA": ar_SA, "en_US": en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 2f7efcc..9b9d1c3 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -425,6 +425,9 @@ abstract class LocaleKeys { static const typeCurrentPasswordBelow = 'typeCurrentPasswordBelow'; static const currentPassword = 'currentPassword'; static const concurrentReports = 'concurrentReports'; + static const EnterNewAddressMoved = 'EnterNewAddressMoved'; + static const CorrectAddress = 'CorrectAddress'; + static const SelectChangeWantToMake = 'SelectChangeWantToMake'; static const profile_reset_password_label = 'profile.reset_password.label'; static const profile_reset_password_username = 'profile.reset_password.username'; static const profile_reset_password_password = 'profile.reset_password.password'; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index c879f9c..4b4d73f 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -96,7 +96,7 @@ class _AddLeaveBalanceScreenState extends State { } void validateAbsenceTransaction() async { - try { + // try { Utils.showLoading(context); Map dffDataMap = {}; for (int i = 1; i <= 20; i++) { @@ -145,10 +145,10 @@ class _AddLeaveBalanceScreenState extends State { } await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); Utils.hideLoading(context); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); - } + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // } } @override diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index 84adf9f..51a2440 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -164,17 +164,17 @@ class _RequestSubmitScreenState extends State { @override Widget build(BuildContext context) { - if (dynamicParams == null) { - dynamicParams = ModalRoute - .of(context)! - .settings - .arguments; - if (dynamicParams.isNotEmpty) { - AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; - selectedEmp =dynamicParams; - submitRequest(); - } - } + // if (dynamicParams == null) { + // dynamicParams = ModalRoute + // .of(context)! + // .settings + // .arguments; + // if (dynamicParams.isNotEmpty) { + // AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; + // selectedEmp =dynamicParams; + // submitRequest(); + // } + // } if (params == null) { params = ModalRoute.of(context)!.settings.arguments as RequestSubmitScreenParams; getApproverList(); diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index 95c867a..8bfe7f6 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -155,13 +155,13 @@ class _ContactDetailsState extends State { void addUpdateAddress() { Widget cancelButton = TextButton( - child: Text("Cancel"), + child: Text(LocaleKeys.cancel.tr()), onPressed: () { Navigator.pop(context); }, ); Widget continueButton = TextButton( - child: Text("Next"), + child: Text(LocaleKeys.next.tr()), onPressed: () { continueDynamicForms(); }, @@ -169,7 +169,7 @@ class _ContactDetailsState extends State { StatefulBuilder alert = StatefulBuilder(builder: (context, setState) { return AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))), - title: Text("Confirm"), + title: Text(LocaleKeys.confirm.tr()), content: Builder(builder: (context) { // Get available height and width of the build area of this widget. Make a choice depending on the size. var height = MediaQuery.of(context).size.height * .5; @@ -177,14 +177,14 @@ class _ContactDetailsState extends State { height: height, child: Column(children: [ Text( - "Select the type of change you want to make.", + LocaleKeys.SelectChangeWantToMake.tr(), style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), Divider(), Column( children: [ ListTile( - title: Text("Correct or amend this address"), + title: Text(LocaleKeys.CorrectAddress.tr()), leading: Radio( value: 1, groupValue: correctOrNew, @@ -197,7 +197,7 @@ class _ContactDetailsState extends State { ), ), ListTile( - title: Text("Enter a new address if you have moved"), + title: Text(LocaleKeys.EnterNewAddressMoved.tr()), leading: Radio( value: 2, groupValue: correctOrNew, From cd813a163fff0f4f392eb2ac68dd9db25d0cbe30 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 11 Dec 2022 15:37:42 +0300 Subject: [PATCH 2/3] fix issues --- lib/api/dashboard_api_client.dart | 5 +- lib/api/leave_balance_api_client.dart | 35 +++++++++++--- .../add_leave_balance_screen.dart | 47 +++++++++++++------ .../leave_balance/leave_balance_screen.dart | 31 +++++++++--- lib/ui/misc/request_submit_screen.dart | 7 ++- .../dynamic_listview_screen.dart | 4 +- .../services_menu_list_screen.dart | 2 +- lib/widgets/balances_dashboard_widget.dart | 4 +- 8 files changed, 102 insertions(+), 33 deletions(-) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index e30af91..3eab65b 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -65,10 +65,13 @@ class DashboardApiClient { }, url, postParams); } - Future> getAccrualBalances(String effectiveDate) async { + Future> getAccrualBalances(String effectiveDate, {String? empID}) async { String url = "${ApiConsts.erpRest}GET_ACCRUAL_BALANCES"; Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); return responseData.getAccrualBalancesList ?? []; diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index cd577ba..f9c5e21 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -17,27 +17,33 @@ class LeaveBalanceApiClient { factory LeaveBalanceApiClient() => _instance; - Future> getAbsenceTransactions(int pSelectedResopID) async { + Future> getAbsenceTransactions(int pSelectedResopID, {String? empID}) async { String url = "${ApiConsts.erpRest}GET_ABSENCE_TRANSACTIONS"; Map postParams = {"P_PAGE_LIMIT": 50, "P_PAGE_NUM": 1, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getAbsenceTransactionList ?? []; }, url, postParams); } - Future> getAbsenceAttendanceTypes() async { + Future> getAbsenceAttendanceTypes({String? empID}) async { String url = "${ApiConsts.erpRest}GET_ABSENCE_ATTENDANCE_TYPES"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getAbsenceAttendanceTypesList ?? []; }, url, postParams); } - Future calculateAbsenceDuration(int pAbsenceAttendanceTypeID, String pDateStart, String pDateEnd, int pSelectedResopID) async { + Future calculateAbsenceDuration(int pAbsenceAttendanceTypeID, String pDateStart, String pDateEnd, int pSelectedResopID, {String? empID}) async { String url = "${ApiConsts.erpRest}CALCULATE_ABSENCE_DURATION"; Map postParams = { "P_ABSENCE_ATTENDANCE_TYPE_ID": pAbsenceAttendanceTypeID, @@ -49,16 +55,22 @@ class LeaveBalanceApiClient { "P_TIME_START": null, }; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.calculateAbsenceDuration!; }, url, postParams); } - Future> getAbsenceDffStructure(String pDescFlexContextCode, String pFunctionName, int pSelectedResopID) async { + Future> getAbsenceDffStructure(String pDescFlexContextCode, String pFunctionName, int pSelectedResopID, {String? empID}) async { String url = "${ApiConsts.erpRest}GET_ABSENCE_DFF_STRUCTURE"; Map postParams = {"P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, "P_FUNCTION_NAME": pFunctionName, "P_MENU_TYPE": "E", "P_SELECTED_RESP_ID": pSelectedResopID}; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getAbsenceDffStructureList ?? []; @@ -67,7 +79,7 @@ class LeaveBalanceApiClient { Future validateAbsenceTransaction( String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, - {String comments = ""}) async { + {String comments = "", String? empID}) async { String url = "${ApiConsts.erpRest}VALIDATE_ABSENCE_TRANSACTION"; Map postParams = { "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, @@ -86,6 +98,9 @@ class LeaveBalanceApiClient { }; postParams.addAll(data); postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData; @@ -94,7 +109,7 @@ class LeaveBalanceApiClient { Future submitAbsenceTransaction( String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, - {String comments = ""}) async { + {String comments = "", String? empID}) async { String url = "${ApiConsts.erpRest}SUBMIT_ABSENCE_TRANSACTION"; Map postParams = { "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, @@ -113,6 +128,9 @@ class LeaveBalanceApiClient { }; postParams.addAll(data); postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.sumbitAbsenceTransactionList!; @@ -129,7 +147,7 @@ class LeaveBalanceApiClient { }, url, postParams); } - Future startAbsenceApprovalProcess(int pTransactionID, String comments, int pSelectedResopID) async { + Future startAbsenceApprovalProcess(int pTransactionID, String comments, int pSelectedResopID,{String? empID}) async { String url = "${ApiConsts.erpRest}START_ABSENCE_APPROVAL_PROCESS"; Map postParams = { "P_TRANSACTION_ID": pTransactionID, @@ -138,6 +156,9 @@ class LeaveBalanceApiClient { "P_MENU_TYPE": "E", }; postParams.addAll(AppState().postParamsJson); + if (empID!.isNotEmpty) { + postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; + } return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.startAbsenceApprovalProccess!; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 1a4958e..dde2f02 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -4,6 +4,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/date_uitl.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; @@ -24,7 +25,8 @@ import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; class AddLeaveBalanceScreen extends StatefulWidget { - AddLeaveBalanceScreen({Key? key}) : super(key: key); + final String selectedEmp; + AddLeaveBalanceScreen({this.selectedEmp ='', Key? key}) : super(key: key); @override _AddLeaveBalanceScreenState createState() { @@ -42,19 +44,21 @@ class _AddLeaveBalanceScreenState extends State { int? totalDays; String comment = ""; ReplacementList? selectedReplacementEmployee; + dynamic dynamicParams; + String selectedEmp =""; DateTime selectedDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); @override void initState() { super.initState(); - getAbsenceAttendanceTypes(); + //getAbsenceAttendanceTypes(); } void getAbsenceAttendanceTypes() async { try { Utils.showLoading(context); - absenceList = await LeaveBalanceApiClient().getAbsenceAttendanceTypes(); + absenceList = await LeaveBalanceApiClient().getAbsenceAttendanceTypes(empID: selectedEmp); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -67,7 +71,7 @@ class _AddLeaveBalanceScreenState extends State { try { Utils.showLoading(context); getabsenceDffStructureList.clear(); - getabsenceDffStructureList = await LeaveBalanceApiClient().getAbsenceDffStructure(selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", -999); + getabsenceDffStructureList = await LeaveBalanceApiClient().getAbsenceDffStructure(selectedAbsenceType!.dESCFLEXCONTEXTCODE!, "HR_LOA_SS", -999, empID: selectedEmp); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -80,7 +84,7 @@ class _AddLeaveBalanceScreenState extends State { try { Utils.showLoading(context); CalculateAbsenceDuration duration = await LeaveBalanceApiClient() - .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999); + .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999, empID: selectedEmp); totalDays = duration.pABSENCEDAYS?.toInt(); Utils.hideLoading(context); @@ -91,8 +95,8 @@ class _AddLeaveBalanceScreenState extends State { } } - void validateAbsenceTransaction() async { - // try { + void validateAbsenceTransaction(selectedID) async { + try { Utils.showLoading(context); Map dffDataMap = {}; for (int i = 1; i <= 20; i++) { @@ -118,7 +122,8 @@ class _AddLeaveBalanceScreenState extends State { DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, dffDataMap, - comments: comment); + comments: comment, + empID: selectedEmp); SumbitAbsenceTransactionList submit = await LeaveBalanceApiClient().submitAbsenceTransaction( selectedAbsenceType!.dESCFLEXCONTEXTCODE!, @@ -129,7 +134,8 @@ class _AddLeaveBalanceScreenState extends State { DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), -999, dffDataMap, - comments: comment); + comments: comment, + empID: selectedEmp); Utils.hideLoading(context); @@ -139,10 +145,10 @@ class _AddLeaveBalanceScreenState extends State { } await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); Utils.hideLoading(context); - // } catch (ex) { - // Utils.hideLoading(context); - // Utils.handleException(ex, context, null); - // } + } catch (ex) { + Utils.hideLoading(context); + Utils.handleException(ex, context, null); + } } @override @@ -152,6 +158,19 @@ class _AddLeaveBalanceScreenState extends State { @override Widget build(BuildContext context) { + if (dynamicParams == null) { + dynamicParams = ModalRoute + .of(context)! + .settings + .arguments; + if (dynamicParams.isNotEmpty) { + AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; + selectedEmp =dynamicParams; + getAbsenceAttendanceTypes(); + }else{ + getAbsenceAttendanceTypes(); + } + } return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( @@ -269,7 +288,7 @@ class _AddLeaveBalanceScreenState extends State { validateFieldData() ? null : () { - validateAbsenceTransaction(); + validateAbsenceTransaction(selectedEmp); }, ).insideContainer ], diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index 548ca99..a397c11 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/leave_balance_api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.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'; @@ -13,7 +14,8 @@ import 'package:mohem_flutter_app/widgets/balances_dashboard_widget.dart'; import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class LeaveBalance extends StatefulWidget { - LeaveBalance({Key? key}) : super(key: key); + final String selectedEmp; + LeaveBalance({this.selectedEmp ='', Key? key}) : super(key: key); @override _LeaveBalanceState createState() { @@ -25,12 +27,16 @@ class _LeaveBalanceState extends State { List? absenceTransList; DateTime accrualDateTime = DateTime.now(); + dynamic dynamicParams; + String selectedEmp =""; @override void initState() { super.initState(); - - getAbsenceTransactions(); + // if (selectedEmp.isNotEmpty) {} + // else { + // getAbsenceTransactions(); + // } } @override @@ -39,9 +45,9 @@ class _LeaveBalanceState extends State { } void getAbsenceTransactions() async { - try { + try { Utils.showLoading(context); - absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999); + absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999, empID: selectedEmp); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -52,6 +58,19 @@ class _LeaveBalanceState extends State { @override Widget build(BuildContext context) { + if (dynamicParams == null) { + dynamicParams = ModalRoute + .of(context)! + .settings + .arguments; + if (dynamicParams.isNotEmpty) { + AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; + selectedEmp =dynamicParams; + getAbsenceTransactions(); + }else{ + getAbsenceTransactions(); + } + } return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( @@ -111,7 +130,7 @@ class _LeaveBalanceState extends State { ), child: const Icon(Icons.add, color: Colors.white, size: 30), ).onPress(() { - Navigator.pushNamed(context, AppRoutes.addLeaveBalance); + Navigator.pushNamed(context, AppRoutes.addLeaveBalance, arguments: selectedEmp ??''); }), ); } diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index f05bacb..170e288 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -8,6 +8,7 @@ import 'package:mohem_flutter_app/api/leave_balance_api_client.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/api/termination_dff_api_client.dart'; +import 'package:mohem_flutter_app/app_state/app_state.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'; @@ -35,7 +36,8 @@ class RequestSubmitScreenParams { } class RequestSubmitScreen extends StatefulWidget { - RequestSubmitScreen({Key? key}) : super(key: key); + final String selectedEmp; + RequestSubmitScreen({this.selectedEmp ='',Key? key}) : super(key: key); @override _RequestSubmitScreenState createState() { @@ -50,6 +52,8 @@ class _RequestSubmitScreenState extends State { List approverList = []; List attachmentFiles = []; List attachments = []; + dynamic dynamicParams; + String selectedEmp =""; @override void initState() { @@ -123,6 +127,7 @@ class _RequestSubmitScreenState extends State { params!.transactionId, comments.text, -999, + empID: widget.selectedEmp ); } else if (params!.approvalFlag == 'eit') { await MyAttendanceApiClient().startEitApprovalProcess( diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart index 5c4053c..a670cbb 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart @@ -102,8 +102,8 @@ class _DynamicListViewScreenState extends State { itemBuilder: (cxt, int parentIndex) => getEITTransactionList![parentIndex].collectionTransaction!.isEmpty ? const SizedBox() : GridView( - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 1.9 / 0.75), - padding: const EdgeInsets.all(12.0), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 1.0 / 0.75), + padding: const EdgeInsets.only(left: 12,right: 21,top: 12), shrinkWrap: true, primary: false, physics: const ScrollPhysics(), diff --git a/lib/ui/my_attendance/services_menu_list_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart index cd76132..7a61029 100644 --- a/lib/ui/my_attendance/services_menu_list_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -54,7 +54,7 @@ class ServicesMenuListScreen extends StatelessWidget { } return; } else if (servicesMenuData.list[index].requestType == "ABSENCE") { - Navigator.pushNamed(context, AppRoutes.leaveBalance); + Navigator.pushNamed(context, AppRoutes.leaveBalance, arguments: servicesMenuData?.selectedEmp ??''); return; } if (servicesMenuData.list[index].requestType == "EIT") { diff --git a/lib/widgets/balances_dashboard_widget.dart b/lib/widgets/balances_dashboard_widget.dart index e546acf..510137a 100644 --- a/lib/widgets/balances_dashboard_widget.dart +++ b/lib/widgets/balances_dashboard_widget.dart @@ -45,6 +45,8 @@ class _BalancesDashboardWidgetState extends State { late DateTime accrualDateTime; GetAccrualBalancesList? leaveBalanceAccrual; List? ticketBalanceAccrualList; + dynamic dynamicParams; + String selectedEmp =""; @override void initState() { @@ -60,7 +62,7 @@ class _BalancesDashboardWidgetState extends State { void changeAccrualDate() async { try { Utils.showLoading(context); - List accrualList = await DashboardApiClient().getAccrualBalances(DateFormat("MM/dd/yyyy").format(accrualDateTime)); + List accrualList = await DashboardApiClient().getAccrualBalances(DateFormat("MM/dd/yyyy").format(accrualDateTime),empID: selectedEmp); if (accrualList.isNotEmpty) { if (widget.isLeaveBalance) { leaveBalanceAccrual = accrualList[0]; From f1b7b897cc7cfca0022c6f8139184eaa051e7ac1 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Sun, 11 Dec 2022 16:12:34 +0300 Subject: [PATCH 3/3] leave balance page updated --- .../add_leave_balance_screen.dart | 107 +++++++++--------- .../leave_balance/leave_balance_screen.dart | 26 ++--- lib/widgets/balances_dashboard_widget.dart | 5 +- 3 files changed, 65 insertions(+), 73 deletions(-) diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index dde2f02..4df7233 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -26,7 +26,7 @@ import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget class AddLeaveBalanceScreen extends StatefulWidget { final String selectedEmp; - AddLeaveBalanceScreen({this.selectedEmp ='', Key? key}) : super(key: key); + AddLeaveBalanceScreen({this.selectedEmp = '', Key? key}) : super(key: key); @override _AddLeaveBalanceScreenState createState() { @@ -45,14 +45,14 @@ class _AddLeaveBalanceScreenState extends State { String comment = ""; ReplacementList? selectedReplacementEmployee; dynamic dynamicParams; - String selectedEmp =""; + String selectedEmp = ""; DateTime selectedDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day); @override void initState() { super.initState(); - //getAbsenceAttendanceTypes(); + //getAbsenceAttendanceTypes(); } void getAbsenceAttendanceTypes() async { @@ -96,59 +96,59 @@ class _AddLeaveBalanceScreenState extends State { } void validateAbsenceTransaction(selectedID) async { - try { - Utils.showLoading(context); - Map dffDataMap = {}; - for (int i = 1; i <= 20; i++) { - dffDataMap["P_ATTRIBUTE$i"] = null; - for (int dffIndex = 0; dffIndex < getabsenceDffStructureList.length; dffIndex++) { - if ("ATTRIBUTE$i" == getabsenceDffStructureList[dffIndex].aPPLICATIONCOLUMNNAME) { - if (getabsenceDffStructureList[dffIndex].fORMATTYPE == "X") { - dffDataMap["P_ATTRIBUTE$i"] = - getabsenceDffStructureList[dffIndex].eSERVICESDV!.pIDCOLUMNNAME != null ? Utils.formatDate(getabsenceDffStructureList[dffIndex].eSERVICESDV!.pIDCOLUMNNAME!) : ""; - } else { - dffDataMap["P_ATTRIBUTE$i"] = getabsenceDffStructureList[dffIndex].eSERVICESDV?.pIDCOLUMNNAME; - } - break; + //try { + Utils.showLoading(context); + Map dffDataMap = {}; + for (int i = 1; i <= 20; i++) { + dffDataMap["P_ATTRIBUTE$i"] = null; + for (int dffIndex = 0; dffIndex < getabsenceDffStructureList.length; dffIndex++) { + if ("ATTRIBUTE$i" == getabsenceDffStructureList[dffIndex].aPPLICATIONCOLUMNNAME) { + if (getabsenceDffStructureList[dffIndex].fORMATTYPE == "X") { + dffDataMap["P_ATTRIBUTE$i"] = + getabsenceDffStructureList[dffIndex].eSERVICESDV!.pIDCOLUMNNAME != null ? Utils.formatDate(getabsenceDffStructureList[dffIndex].eSERVICESDV!.pIDCOLUMNNAME!) : ""; + } else { + dffDataMap["P_ATTRIBUTE$i"] = getabsenceDffStructureList[dffIndex].eSERVICESDV?.pIDCOLUMNNAME; } + break; } } - await LeaveBalanceApiClient().validateAbsenceTransaction( - selectedAbsenceType!.dESCFLEXCONTEXTCODE!, - "HR_LOA_SS", - selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, - selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", - DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), - DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), - -999, - dffDataMap, - comments: comment, - empID: selectedEmp); + } + await LeaveBalanceApiClient().validateAbsenceTransaction( + selectedAbsenceType!.dESCFLEXCONTEXTCODE!, + "HR_LOA_SS", + selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, + selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", + DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), + DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), + -999, + dffDataMap, + comments: comment, + empID: selectedEmp); - SumbitAbsenceTransactionList submit = await LeaveBalanceApiClient().submitAbsenceTransaction( - selectedAbsenceType!.dESCFLEXCONTEXTCODE!, - "HR_LOA_SS", - selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, - selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", - DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), - DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), - -999, - dffDataMap, - comments: comment, - empID: selectedEmp); + SumbitAbsenceTransactionList submit = await LeaveBalanceApiClient().submitAbsenceTransaction( + selectedAbsenceType!.dESCFLEXCONTEXTCODE!, + "HR_LOA_SS", + selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, + selectedReplacementEmployee != null ? selectedReplacementEmployee!.userName! : "", + DateUtil.getFormattedDate(startDateTime!, "MM/dd/yyyy"), + DateUtil.getFormattedDate(endDateTime!, "MM/dd/yyyy"), + -999, + dffDataMap, + comments: comment, + empID: selectedEmp); - Utils.hideLoading(context); + Utils.hideLoading(context); - var res = await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); - if (res != null && res == true) { - Utils.showLoading(context); - } - await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); - Utils.hideLoading(context); - } catch (ex) { - Utils.hideLoading(context); - Utils.handleException(ex, context, null); + var res = await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); + if (res != null && res == true) { + Utils.showLoading(context); } + await LeaveBalanceApiClient().cancelHrTransaction(submit.pTRANSACTIONID!); + Utils.hideLoading(context); + // } catch (ex) { + // Utils.hideLoading(context); + // Utils.handleException(ex, context, null); + // } } @override @@ -159,15 +159,12 @@ class _AddLeaveBalanceScreenState extends State { @override Widget build(BuildContext context) { if (dynamicParams == null) { - dynamicParams = ModalRoute - .of(context)! - .settings - .arguments; + dynamicParams = ModalRoute.of(context)!.settings.arguments; if (dynamicParams.isNotEmpty) { AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; - selectedEmp =dynamicParams; + selectedEmp = dynamicParams; getAbsenceAttendanceTypes(); - }else{ + } else { getAbsenceAttendanceTypes(); } } diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index a397c11..07d6a7c 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -15,7 +15,7 @@ import 'package:mohem_flutter_app/widgets/item_detail_view_widget.dart'; class LeaveBalance extends StatefulWidget { final String selectedEmp; - LeaveBalance({this.selectedEmp ='', Key? key}) : super(key: key); + LeaveBalance({this.selectedEmp = '', Key? key}) : super(key: key); @override _LeaveBalanceState createState() { @@ -28,15 +28,12 @@ class _LeaveBalanceState extends State { DateTime accrualDateTime = DateTime.now(); dynamic dynamicParams; - String selectedEmp =""; + String selectedEmp = ""; @override void initState() { super.initState(); - // if (selectedEmp.isNotEmpty) {} - // else { - // getAbsenceTransactions(); - // } + absenceTransList = []; } @override @@ -45,10 +42,10 @@ class _LeaveBalanceState extends State { } void getAbsenceTransactions() async { - try { - Utils.showLoading(context); + try { + // Utils.showLoading(context); absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999, empID: selectedEmp); - Utils.hideLoading(context); + //Utils.hideLoading(context); setState(() {}); } catch (ex) { Utils.hideLoading(context); @@ -59,15 +56,12 @@ class _LeaveBalanceState extends State { @override Widget build(BuildContext context) { if (dynamicParams == null) { - dynamicParams = ModalRoute - .of(context)! - .settings - .arguments; + dynamicParams = ModalRoute.of(context)!.settings.arguments; if (dynamicParams.isNotEmpty) { AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; - selectedEmp =dynamicParams; + selectedEmp = dynamicParams; getAbsenceTransactions(); - }else{ + } else { getAbsenceTransactions(); } } @@ -130,7 +124,7 @@ class _LeaveBalanceState extends State { ), child: const Icon(Icons.add, color: Colors.white, size: 30), ).onPress(() { - Navigator.pushNamed(context, AppRoutes.addLeaveBalance, arguments: selectedEmp ??''); + Navigator.pushNamed(context, AppRoutes.addLeaveBalance, arguments: selectedEmp ?? ''); }), ); } diff --git a/lib/widgets/balances_dashboard_widget.dart b/lib/widgets/balances_dashboard_widget.dart index 510137a..2c56c7e 100644 --- a/lib/widgets/balances_dashboard_widget.dart +++ b/lib/widgets/balances_dashboard_widget.dart @@ -46,12 +46,13 @@ class _BalancesDashboardWidgetState extends State { GetAccrualBalancesList? leaveBalanceAccrual; List? ticketBalanceAccrualList; dynamic dynamicParams; - String selectedEmp =""; + String selectedEmp = ""; @override void initState() { super.initState(); accrualDateTime = DateTime.now(); + changeAccrualDate(); } @override @@ -62,7 +63,7 @@ class _BalancesDashboardWidgetState extends State { void changeAccrualDate() async { try { Utils.showLoading(context); - List accrualList = await DashboardApiClient().getAccrualBalances(DateFormat("MM/dd/yyyy").format(accrualDateTime),empID: selectedEmp); + List accrualList = await DashboardApiClient().getAccrualBalances(DateFormat("MM/dd/yyyy").format(accrualDateTime), empID: selectedEmp); if (accrualList.isNotEmpty) { if (widget.isLeaveBalance) { leaveBalanceAccrual = accrualList[0];