From 696a6881c4ba38a61eff6398089eaf554a87b6cf Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 20 Dec 2022 15:23:03 +0300 Subject: [PATCH 1/4] date fixes & Items of sale updates --- lib/classes/date_uitl.dart | 26 +++++++++++++++++-- .../fragments/my_posted_ads_fragment.dart | 19 ++++++++++---- pubspec.yaml | 2 +- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/lib/classes/date_uitl.dart b/lib/classes/date_uitl.dart index 29edb2f..ec5358d 100644 --- a/lib/classes/date_uitl.dart +++ b/lib/classes/date_uitl.dart @@ -6,7 +6,6 @@ class DateUtil { /// /// - static DateTime convertStringToDateMarathon(String date) { // /Date(1585774800000+0300)/ if (date != null) { @@ -40,7 +39,30 @@ class DateUtil { } static DateTime convertSimpleStringDateToDate(String date) { - return DateFormat("MM/dd/yyyy hh:mm:ss a").parse(date.toUpperCase()); + // print(date.toUpperCase()); + return getDateTimeFromString(date.split(" ")[0], date.toUpperCase().split(" ")[1] + " " + date.toUpperCase().split(" ")[2]); + } + + static DateTime getDateTimeFromString(String date, String time) { + var hours = num.parse(time.split(":")[0]); + var mins = time.split(":")[1]; + var secs = time.split(":")[2].split(" ")[0]; + + String meridium = time.split(" ")[1]; + if (meridium == "PM") { + if (hours != 12) { + hours = hours + 12; + } + } + if (meridium == "AM") { + if (hours == 12) { + hours = 00; + } + } + date = date + " $hours:$mins:$secs"; + DateTime returnDate = DateFormat("MM/dd/yyyy HH:mm:ss").parse(date); + + return returnDate; } static DateTime convertSimpleStringDateToDateddMMyyyy(String date) { diff --git a/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart index 64b8bf9..02db148 100644 --- a/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart +++ b/lib/ui/screens/items_for_sale/fragments/my_posted_ads_fragment.dart @@ -141,7 +141,7 @@ class _MyPostedAdsFragmentState extends State { Row( children: [ LocaleKeys.remove.tr().toText12(color: MyColors.redColor).center.onPress(() { - updateItemForSale(employeePostedAdsList[index].itemSaleID!); + updateItemForSale(employeePostedAdsList[index]); }).expanded, Container(width: 1, height: 30, color: MyColors.lightGreyEFColor), LocaleKeys.edit.tr().toText12(color: MyColors.gradiantEndColor).center.onPress(() { @@ -172,7 +172,7 @@ class _MyPostedAdsFragmentState extends State { ); } - void updateItemForSale(int itemSaleID) async { + void updateItemForSale(EmployeePostedAds employeePostedAds) async { Utils.showLoading(context); String? empNum = AppState().memberInformationList?.eMPLOYEENUMBER; @@ -180,15 +180,24 @@ class _MyPostedAdsFragmentState extends State { String? loginTokenID = AppState().postParamsObject?.logInTokenID; String? tokenID = AppState().postParamsObject?.tokenID; - var request = http.MultipartRequest('POST', Uri.parse("${ApiConsts.cocRest}Mohemm_ITG_UpdateItemForSale")); - request.fields['itemSaleID'] = itemSaleID.toString(); + var request = http.MultipartRequest('POST', Uri.parse("${ApiConsts.cocRest}Mohemm_ITG_UpdateItemForSaleMobile")); + request.fields['ItgItemSaleID'] = employeePostedAds.itemSaleID.toString(); + request.fields['ItgCategoryID'] = employeePostedAds.categoryID.toString(); + request.fields['ItgTitle'] = employeePostedAds.title!; + request.fields['ItgDescription'] = employeePostedAds.description!; + request.fields['ItgQuotePrice'] = employeePostedAds.quotePrice.toString(); + request.fields['RegionID'] = employeePostedAds.regionID.toString(); + request.fields['Itg_EndDate'] = employeePostedAds.endDate.toString(); request.fields['Channel'] = "31"; - request.fields['isActive'] = "false"; + request.fields['ItgIsActive'] = "false"; request.fields['LogInToken'] = loginTokenID!; request.fields['Token'] = tokenID!; request.fields['MobileNo'] = empMobNum!; request.fields['EmployeeNumber'] = empNum!; request.fields['employeeNumber'] = empNum; + + // debugPrint(json.encode(request.fields.toString())); + var response = await request.send().catchError((e) { Utils.hideLoading(context); Utils.handleException(e, context, null); diff --git a/pubspec.yaml b/pubspec.yaml index c0b77bb..2f3fffa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -94,7 +94,7 @@ dependencies: camera: ^0.10.0+4 #Chat Voice Message Recoding & Play - record: ^4.4.3 +# record: ^4.4.3 audio_waveforms: ^0.1.5+1 # animated_text_kit: ^4.2.2 From fe02776a69223e0e55e83b69beca2de9d180ae7f Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 21 Dec 2022 12:29:29 +0300 Subject: [PATCH 2/4] leave balance issues fixed. --- lib/api/dashboard_api_client.dart | 10 +- lib/api/leave_balance_api_client.dart | 61 ++++----- lib/api/my_attendance_api_client.dart | 28 +--- lib/classes/consts.dart | 4 +- .../add_leave_balance_screen.dart | 121 +++++++++--------- .../leave_balance/leave_balance_screen.dart | 111 ++++++++-------- .../dynamic_screens/dynamic_input_screen.dart | 19 ++- .../dynamic_listview_screen.dart | 7 +- .../services_menu_list_screen.dart | 9 +- lib/ui/my_team/create_request.dart | 3 +- lib/widgets/balances_dashboard_widget.dart | 19 ++- 11 files changed, 171 insertions(+), 221 deletions(-) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 5f2ad7e..95631a9 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -1,12 +1,10 @@ import 'dart:async'; import 'dart:convert'; -import 'package:http/http.dart'; import 'package:mohem_flutter_app/api/api_client.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/date_uitl.dart'; -import 'package:mohem_flutter_app/models/chat/chat_count_conversation_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_accrual_balances_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; @@ -14,7 +12,6 @@ import 'package:mohem_flutter_app/models/dashboard/list_menu.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/itg/itg_main_response.dart'; import 'package:mohem_flutter_app/models/itg/itg_response_model.dart'; - import 'package:uuid/uuid.dart'; class DashboardApiClient { @@ -47,7 +44,6 @@ class DashboardApiClient { Future getCOCNotifications() async { String url = "${ApiConsts.cocRest}Mohemm_ITG_ReviewerAdmin_Pending_Tasks"; Map postParams = {"Date": DateUtil.getISODateFormat(DateTime.now()), "EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER}; - postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); @@ -69,9 +65,7 @@ class DashboardApiClient { String url = "${ApiConsts.erpRest}GET_ACCRUAL_BALANCES"; Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; postParams.addAll(AppState().postParamsJson); - if (empID != null && empID.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); return responseData.getAccrualBalancesList ?? []; @@ -205,8 +199,6 @@ class DashboardApiClient { }, url, postParams); } - - // Future setAdvertisementViewed(String masterID, int advertisementId) async { // String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; // diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index f9c5e21..ae855ee 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -17,13 +17,11 @@ class LeaveBalanceApiClient { factory LeaveBalanceApiClient() => _instance; - Future> getAbsenceTransactions(int pSelectedResopID, {String? empID}) 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; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getAbsenceTransactionList ?? []; @@ -34,16 +32,15 @@ class LeaveBalanceApiClient { String url = "${ApiConsts.erpRest}GET_ABSENCE_ATTENDANCE_TYPES"; Map postParams = {}; postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) 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, {String? empID}) 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, @@ -52,25 +49,26 @@ class LeaveBalanceApiClient { "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, - "P_TIME_START": null, + "P_TIME_START": null }; postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) 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, {String? empID}) 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}; + 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; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getAbsenceDffStructureList ?? []; @@ -79,7 +77,7 @@ class LeaveBalanceApiClient { Future validateAbsenceTransaction( String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, - {String comments = "", String? empID}) async { + {String comments = "", String? empID}) async { String url = "${ApiConsts.erpRest}VALIDATE_ABSENCE_TRANSACTION"; Map postParams = { "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, @@ -94,13 +92,11 @@ class LeaveBalanceApiClient { "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, - "P_TIME_START": null, + "P_TIME_START": null }; postParams.addAll(data); postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData; @@ -109,7 +105,7 @@ class LeaveBalanceApiClient { Future submitAbsenceTransaction( String pDescFlexContextCode, String pFunctionName, int pAbsenceAttendanceTypeID, String pReplacementUserName, String pDateStart, String pDateEnd, int pSelectedResopID, Map data, - {String comments = "", String? empID}) async { + {String comments = "", String? empID}) async { String url = "${ApiConsts.erpRest}SUBMIT_ABSENCE_TRANSACTION"; Map postParams = { "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, @@ -124,13 +120,11 @@ class LeaveBalanceApiClient { "P_SELECTED_RESP_ID": pSelectedResopID, "P_MENU_TYPE": "E", "P_TIME_END": null, - "P_TIME_START": null, + "P_TIME_START": null }; postParams.addAll(data); postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.sumbitAbsenceTransactionList!; @@ -147,18 +141,11 @@ class LeaveBalanceApiClient { }, url, postParams); } - Future startAbsenceApprovalProcess(int pTransactionID, String comments, int pSelectedResopID,{String? empID}) 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, - "P_SELECTED_RESP_ID": pSelectedResopID, - "P_COMMENTS": comments, - "P_MENU_TYPE": "E", - }; + Map postParams = {"P_TRANSACTION_ID": pTransactionID, "P_SELECTED_RESP_ID": pSelectedResopID, "P_COMMENTS": comments, "P_MENU_TYPE": "E", 'P_SELECTED_EMPLOYEE_NUMBER': empID}; 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/api/my_attendance_api_client.dart b/lib/api/my_attendance_api_client.dart index 0f078a2..78742a3 100644 --- a/lib/api/my_attendance_api_client.dart +++ b/lib/api/my_attendance_api_client.dart @@ -22,11 +22,7 @@ class MyAttendanceApiClient { String url = "${ApiConsts.erpRest}GET_EIT_TRANSACTIONS"; Map postParams = {"P_PAGE_LIMIT": 50, "P_PAGE_NUM": 1, "P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_FUNCTION_NAME": pFunctionName}; postParams.addAll(AppState().postParamsJson); - // postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - // AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getEITTransactionList ?? []; @@ -37,9 +33,7 @@ class MyAttendanceApiClient { String url = "${ApiConsts.erpRest}GET_EIT_DFF_STRUCTURE"; Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E", "P_FUNCTION_NAME": pFunctionName}; postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData; @@ -53,16 +47,14 @@ class MyAttendanceApiClient { "P_MENU_TYPE": "E", "P_PAGE_LIMIT": 1000, "P_PAGE_NUM": 1, - "P_PARENT_VALUE": empID!.isNotEmpty ? parentValue : null, + "P_PARENT_VALUE": empID != null ? parentValue : null, "P_SEGMENT_NAME": pSegmentName, "P_DESC_FLEX_CONTEXT_CODE": pDescFlexContextCode, "P_DESC_FLEX_NAME": pDescFlexName, "GetValueSetValuesTBL": list, }; postParams.addAll(AppState().postParamsJson); - if (empID.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.getValueSetValuesList ?? []; @@ -81,9 +73,7 @@ class MyAttendanceApiClient { "GetValueSetValuesTBL": list, }; postParams.addAll(AppState().postParamsJson); - if (empID != null && empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson()); @@ -100,9 +90,7 @@ class MyAttendanceApiClient { "EITTransactionTBL": list, }; postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson()); @@ -120,9 +108,7 @@ class MyAttendanceApiClient { "EITTransactionTBLModel": list, }; postParams.addAll(AppState().postParamsJson); - if (empID!.isNotEmpty) { - postParams['P_SELECTED_EMPLOYEE_NUMBER'] = empID; - } + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); return responseData.submitEITTransactionList!; //ESERVICESDV.fromJson(responseData.getDefaultValueList!.toJson()); diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index c147ea3..52d0407 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,8 +3,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://erptstapp.srca.org.sa"; // SRCA 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/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 5ef03f4..71404a9 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -4,7 +4,6 @@ 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'; @@ -25,8 +24,7 @@ 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 { - final String selectedEmp; - AddLeaveBalanceScreen({this.selectedEmp = '', Key? key}) : super(key: key); + AddLeaveBalanceScreen({Key? key}) : super(key: key); @override _AddLeaveBalanceScreenState createState() { @@ -44,15 +42,21 @@ class _AddLeaveBalanceScreenState extends State { int? totalDays; 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(); + + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + var dynamicParam = ModalRoute.of(context)!.settings.arguments; + if (dynamicParam != null) { + selectedEmp = dynamicParam.toString(); + } + getAbsenceAttendanceTypes(); + }); } void getAbsenceAttendanceTypes() async { @@ -85,7 +89,6 @@ class _AddLeaveBalanceScreenState extends State { Utils.showLoading(context); CalculateAbsenceDuration duration = await LeaveBalanceApiClient() .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999, empID: selectedEmp); - totalDays = duration.pABSENCEDAYS?.toInt(); Utils.hideLoading(context); setState(() {}); @@ -95,56 +98,56 @@ class _AddLeaveBalanceScreenState extends State { } } - void validateAbsenceTransaction(selectedID) async { + void validateAbsenceTransaction(String? 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; + 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; } - 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: selectedID); - 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: selectedID); - 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); + 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); @@ -158,16 +161,6 @@ class _AddLeaveBalanceScreenState extends State { @override Widget build(BuildContext context) { - if (dynamicParams == null) { - dynamicParams = ModalRoute.of(context)!.settings.arguments; - if (dynamicParams!= null && dynamicParams.isNotEmpty) { - AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; - selectedEmp = dynamicParams; - getAbsenceAttendanceTypes(); - } else { - getAbsenceAttendanceTypes(); - } - } return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( @@ -187,13 +180,13 @@ class _AddLeaveBalanceScreenState extends State { isPopup: true, ), itemBuilder: (_) => >[ - for (int i = 0; i < absenceList.length; i++) PopupMenuItem(value: i, child: Text(absenceList[i].aBSENCEATTENDANCETYPENAME!)), + for (int i = 0; i < (absenceList?.length ?? 0); i++) PopupMenuItem(value: i, child: Text(absenceList![i].aBSENCEATTENDANCETYPENAME!)), ], onSelected: (int popupIndex) { - if (selectedAbsenceType == absenceList[popupIndex]) { + if (selectedAbsenceType == absenceList![popupIndex]) { return; } - selectedAbsenceType = absenceList[popupIndex]; + selectedAbsenceType = absenceList![popupIndex]; setState(() {}); getAbsenceDffStructure(); }, @@ -285,7 +278,7 @@ class _AddLeaveBalanceScreenState extends State { validateFieldData() ? null : () { - validateAbsenceTransaction(selectedEmp); + validateAbsenceTransaction(selectedEmp!.isEmpty ? null : selectedEmp); }, ).insideContainer ], diff --git a/lib/ui/leave_balance/leave_balance_screen.dart b/lib/ui/leave_balance/leave_balance_screen.dart index 8c346bc..881828e 100644 --- a/lib/ui/leave_balance/leave_balance_screen.dart +++ b/lib/ui/leave_balance/leave_balance_screen.dart @@ -1,7 +1,6 @@ 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'; @@ -14,8 +13,7 @@ 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 { - final String selectedEmp; - LeaveBalance({this.selectedEmp = '', Key? key}) : super(key: key); + LeaveBalance({Key? key}) : super(key: key); @override _LeaveBalanceState createState() { @@ -27,13 +25,18 @@ class _LeaveBalanceState extends State { List? absenceTransList; DateTime accrualDateTime = DateTime.now(); - dynamic dynamicParams; - String selectedEmp = ""; + String? employeeId; @override void initState() { super.initState(); - absenceTransList = []; + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + var dynamicParam = ModalRoute.of(context)!.settings.arguments; + if (dynamicParam != null) { + employeeId = dynamicParam.toString(); + } + getAbsenceTransactions(); + }); } @override @@ -44,7 +47,7 @@ class _LeaveBalanceState extends State { void getAbsenceTransactions() async { try { Utils.showLoading(context); - absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999, empID: selectedEmp); + absenceTransList = await LeaveBalanceApiClient().getAbsenceTransactions(-999, employeeId); Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -55,63 +58,53 @@ class _LeaveBalanceState extends State { @override Widget build(BuildContext context) { - if (dynamicParams == null) { - dynamicParams = ModalRoute.of(context)!.settings.arguments; - if (dynamicParams!= null && dynamicParams.isNotEmpty) { - AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams; - selectedEmp = dynamicParams; - getAbsenceTransactions(); - } else { - getAbsenceTransactions(); - } - } return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( context, title: LocaleKeys.leaveBalance.tr(), ), - body: ListView( - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.all(21), - children: [ - BalancesDashboardWidget(LocaleKeys.currentLeaveBalance.tr(), true, selectedEmp), - 12.height, - absenceTransList == null - ? const SizedBox() - : (absenceTransList!.isEmpty - ? Utils.getNoDataWidget(context).paddingOnly(top: 50) - : ListView.separated( - physics: const NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.zero, - itemBuilder: (cxt, int index) => Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.startDateT.tr(), absenceTransList![index].sTARTDATE ?? ""), - ItemDetailViewCol(LocaleKeys.endDateT.tr(), absenceTransList![index].eNDDATE ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.absenceType.tr(), absenceTransList![index].aBSENCETYPE ?? ""), - ItemDetailViewCol(LocaleKeys.absenceCategory.tr(), absenceTransList![index].aBSENCECATEGORY ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.days.tr(), absenceTransList![index].aBSENCEDAYS?.toString() ?? ""), - ItemDetailViewCol(LocaleKeys.hours.tr(), absenceTransList![index].aBSENCEHOURS?.toString() ?? ""), - ), - ItemDetailGrid( - ItemDetailViewCol(LocaleKeys.approvalStatus.tr(), absenceTransList![index].aPPROVALSTATUS ?? ""), - ItemDetailViewCol(LocaleKeys.absenceStatus.tr(), absenceTransList![index].aBSENCESTATUS ?? ""), - isItLast: true, - ), - ], - ).objectContainerView(), - separatorBuilder: (cxt, index) => 12.height, - itemCount: absenceTransList!.length)), - ], - ), + body: absenceTransList == null + ? const SizedBox() + : (absenceTransList!.isEmpty + ? Utils.getNoDataWidget(context).paddingOnly(top: 50) + : ListView( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + children: [ + BalancesDashboardWidget(LocaleKeys.currentLeaveBalance.tr(), true, selectedEmp: employeeId), + 12.height, + ListView.separated( + physics: const NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (cxt, int index) => Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.startDateT.tr(), absenceTransList![index].sTARTDATE ?? ""), + ItemDetailViewCol(LocaleKeys.endDateT.tr(), absenceTransList![index].eNDDATE ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.absenceType.tr(), absenceTransList![index].aBSENCETYPE ?? ""), + ItemDetailViewCol(LocaleKeys.absenceCategory.tr(), absenceTransList![index].aBSENCECATEGORY ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.days.tr(), absenceTransList![index].aBSENCEDAYS?.toString() ?? ""), + ItemDetailViewCol(LocaleKeys.hours.tr(), absenceTransList![index].aBSENCEHOURS?.toString() ?? ""), + ), + ItemDetailGrid( + ItemDetailViewCol(LocaleKeys.approvalStatus.tr(), absenceTransList![index].aPPROVALSTATUS ?? ""), + ItemDetailViewCol(LocaleKeys.absenceStatus.tr(), absenceTransList![index].aBSENCESTATUS ?? ""), + isItLast: true, + ), + ], + ).objectContainerView(), + separatorBuilder: (cxt, index) => 12.height, + itemCount: absenceTransList!.length), + ], + )), floatingActionButton: Container( height: 54, width: 54, @@ -124,7 +117,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: employeeId); }), ); } 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 228f1d6..9c0c51b 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -5,7 +5,6 @@ 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/api/my_attendance_api_client.dart'; -import 'package:mohem_flutter_app/app_state/app_state.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'; @@ -431,9 +430,6 @@ class _DynamicInputScreenState extends State { Widget build(BuildContext context) { if (dynamicParams == null) { dynamicParams = ModalRoute.of(context)!.settings.arguments as DynamicListViewParams; - if (dynamicParams!.selectedEmp.isNotEmpty) { - AppState().postParamsJson['P_SELECTED_EMPLOYEE_NUMBER'] = dynamicParams!.selectedEmp; - } getTransactionsStructure(); } return Scaffold( @@ -627,12 +623,15 @@ class _DynamicInputScreenState extends State { ).paddingOnly(bottom: 12), itemBuilder: (_) => >[ if (model.rEADONLY != "Y") - for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(value: i, child: Column( - children: [ - Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), - const PopupMenuDivider(), - ], - )), + for (int i = 0; i < model.eSERVICESVS!.length; i++) + PopupMenuItem( + value: i, + child: Column( + children: [ + Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), + const PopupMenuDivider(), + ], + )), ], onSelected: (int popipIndex) async { ESERVICESDV eservicesdv = ESERVICESDV( 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 68727e5..a9c9694 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart @@ -21,10 +21,10 @@ class DynamicListViewParams { bool isUpdate; List? collectionNotificationList; - final String selectedEmp; + final String? selectedEmp; DynamicListViewParams(this.title, this.dynamicId, - {this.selectedEmp = '', this.uRL = 'GET_EIT_DFF_STRUCTURE', this.requestID = '', this.colsURL = '', this.isUpdate = false, this.collectionNotificationList}); + {this.selectedEmp, this.uRL = 'GET_EIT_DFF_STRUCTURE', this.requestID = '', this.colsURL = '', this.isUpdate = false, this.collectionNotificationList}); } class DynamicListViewScreen extends StatefulWidget { @@ -54,7 +54,6 @@ class _DynamicListViewScreenState extends State { getEITTransactionList?.forEach((element) { element.collectionTransaction = element.collectionTransaction?.where((elemen) => elemen.dISPLAYFLAG == "Y").toList() ?? []; }); - getEITTransactionList = getEITTransactionList?.where((element) => element.collectionTransaction?.isNotEmpty ?? false).toList() ?? []; Utils.hideLoading(context); setState(() {}); @@ -94,7 +93,7 @@ class _DynamicListViewScreenState extends State { padding: const EdgeInsets.all(21), children: [ // HMG_TKT_NEW_EIT_SS Id used for ticket balance dashboard - if (isTicketRequest) ...[const BalancesDashboardWidget("Current Ticket Balance", false, ""), 12.height], + if (isTicketRequest) ...[const BalancesDashboardWidget("Current Ticket Balance", false, showLoading: false), 12.height], getEITTransactionList == null ? const SizedBox() : (getEITTransactionList!.isEmpty diff --git a/lib/ui/my_attendance/services_menu_list_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart index 7a61029..097a63a 100644 --- a/lib/ui/my_attendance/services_menu_list_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -17,9 +17,9 @@ import 'package:provider/provider.dart'; class ServicesMenuListScreenParams { final String title; final List list; - final String selectedEmp; + final String? selectedEmp; GetEmployeeSubordinatesList? getEmployeeSubordinates; - ServicesMenuListScreenParams(this.title, this.list, {this.selectedEmp =''}); + ServicesMenuListScreenParams(this.title, this.list, {this.selectedEmp}); } class ServicesMenuListScreen extends StatelessWidget { @@ -54,11 +54,12 @@ class ServicesMenuListScreen extends StatelessWidget { } return; } else if (servicesMenuData.list[index].requestType == "ABSENCE") { - Navigator.pushNamed(context, AppRoutes.leaveBalance, arguments: servicesMenuData?.selectedEmp ??''); + Navigator.pushNamed(context, AppRoutes.leaveBalance, arguments: servicesMenuData.selectedEmp); return; } if (servicesMenuData.list[index].requestType == "EIT") { - Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!, selectedEmp: servicesMenuData.selectedEmp)); + Navigator.pushNamed(context, AppRoutes.dynamicScreen, + arguments: DynamicListViewParams(servicesMenuData.list[index].prompt!, servicesMenuData.list[index].functionName!, selectedEmp: servicesMenuData.selectedEmp)); } else { if (servicesMenuData.list[index].requestType == "TERMINATION") { Navigator.pushNamed(context, AppRoutes.endEmploymentScreen, diff --git a/lib/ui/my_team/create_request.dart b/lib/ui/my_team/create_request.dart index 2b3e063..94ac415 100644 --- a/lib/ui/my_team/create_request.dart +++ b/lib/ui/my_team/create_request.dart @@ -68,7 +68,8 @@ class _CreateRequestState extends State { void handleOnPress(context, Menus menu) { if (menu.menuEntry.menuEntryType == "FUNCTION") { if (menu.menuEntry.requestType == "EIT") { - Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(menu.menuEntry.prompt!, menu.menuEntry.functionName!, selectedEmp: getEmployeeSubordinates?.eMPLOYEENUMBER ?? '')); + Navigator.pushNamed(context, AppRoutes.dynamicScreen, + arguments: DynamicListViewParams(menu.menuEntry.prompt!, menu.menuEntry.functionName!, selectedEmp: getEmployeeSubordinates?.eMPLOYEENUMBER ?? '')); } else {} } else { Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, diff --git a/lib/widgets/balances_dashboard_widget.dart b/lib/widgets/balances_dashboard_widget.dart index 9689de4..aaac793 100644 --- a/lib/widgets/balances_dashboard_widget.dart +++ b/lib/widgets/balances_dashboard_widget.dart @@ -31,9 +31,10 @@ class BalancesDashboardWidget extends StatefulWidget { final String title; final List chartModelList; final bool isLeaveBalance; - final String selectedEmp; + final String? selectedEmp; + final bool showLoading; - const BalancesDashboardWidget(this.title, this.isLeaveBalance, this.selectedEmp, {Key? key, this.chartModelList = const []}) : super(key: key); + const BalancesDashboardWidget(this.title, this.isLeaveBalance, {Key? key, this.selectedEmp, this.showLoading = true, this.chartModelList = const []}) : super(key: key); @override _BalancesDashboardWidgetState createState() { @@ -46,14 +47,12 @@ class _BalancesDashboardWidgetState extends State { late DateTime accrualDateTime; GetAccrualBalancesList? leaveBalanceAccrual; List? ticketBalanceAccrualList; - dynamic dynamicParams; - String selectedEmp = ""; @override void initState() { super.initState(); accrualDateTime = DateTime.now(); - changeAccrualDate(); + changeAccrualDate(widget.showLoading); } @override @@ -61,9 +60,9 @@ class _BalancesDashboardWidgetState extends State { super.dispose(); } - void changeAccrualDate() async { + void changeAccrualDate(bool showLoading) async { try { - // Utils.showLoading(context); + if (showLoading) Utils.showLoading(context); List accrualList = await DashboardApiClient().getAccrualBalances(DateFormat("MM/dd/yyyy").format(accrualDateTime), empID: widget.selectedEmp); if (accrualList.isNotEmpty) { if (widget.isLeaveBalance) { @@ -80,10 +79,10 @@ class _BalancesDashboardWidgetState extends State { ]; } } - // Utils.hideLoading(context); + if (showLoading) Utils.hideLoading(context); setState(() {}); } catch (ex) { - Utils.hideLoading(context); + if (showLoading) Utils.hideLoading(context); Utils.handleException(ex, context, null); } } @@ -125,7 +124,7 @@ class _BalancesDashboardWidgetState extends State { DateTime selectedDate = await Utils.selectDate(context, accrualDateTime); if (selectedDate != accrualDateTime) { accrualDateTime = selectedDate; - changeAccrualDate(); + changeAccrualDate(true); } }), ], From 3a6d1c3273bb3c09b5ec25b64ae3db5865b1bec2 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 21 Dec 2022 15:28:45 +0300 Subject: [PATCH 3/4] leave balance issues fixed-2. --- lib/api/leave_balance_api_client.dart | 4 +- lib/api/worklist/worklist_api_client.dart | 2 +- .../add_leave_balance_screen.dart | 5 +- lib/ui/misc/request_submit_screen.dart | 16 ++-- .../dynamic_screens/dynamic_input_screen.dart | 8 +- lib/ui/my_team/employee_details.dart | 89 +++++++++---------- 6 files changed, 56 insertions(+), 68 deletions(-) diff --git a/lib/api/leave_balance_api_client.dart b/lib/api/leave_balance_api_client.dart index ae855ee..e0330fb 100644 --- a/lib/api/leave_balance_api_client.dart +++ b/lib/api/leave_balance_api_client.dart @@ -143,9 +143,9 @@ class LeaveBalanceApiClient { 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, "P_SELECTED_RESP_ID": pSelectedResopID, "P_COMMENTS": comments, "P_MENU_TYPE": "E", 'P_SELECTED_EMPLOYEE_NUMBER': empID}; + Map postParams = {"P_TRANSACTION_ID": pTransactionID, "P_SELECTED_RESP_ID": pSelectedResopID, "P_COMMENTS": comments, "P_MENU_TYPE": "E"}; postParams.addAll(AppState().postParamsJson); - + if (empID != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = empID; return await ApiClient().postJsonForObject((json) { GenericResponseModel? responseData = GenericResponseModel.fromJson(json); return responseData.startAbsenceApprovalProccess!; diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart index dcbb415..82b865c 100644 --- a/lib/api/worklist/worklist_api_client.dart +++ b/lib/api/worklist/worklist_api_client.dart @@ -157,7 +157,7 @@ class WorkListApiClient { "P_PAGE_NUM": 1, }; postParams.addAll(AppState().postParamsJson); - postParams["P_SELECTED_EMPLOYEE_NUMBER"] = selectedEmployeeNumber; + if (selectedEmployeeNumber != null) postParams["P_SELECTED_EMPLOYEE_NUMBER"] = selectedEmployeeNumber; return await ApiClient().postJsonForObject((json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); return responseData.memberInformationList![0]; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index 71404a9..9eefc62 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -142,7 +142,8 @@ class _AddLeaveBalanceScreenState extends State { Utils.hideLoading(context); - var res = await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance")); + var res = await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, + arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submit.pTRANSACTIONID!, "", "add_leave_balance", selectedEmployeeID: selectedID)); if (res != null && res == true) { Utils.showLoading(context); } @@ -278,7 +279,7 @@ class _AddLeaveBalanceScreenState extends State { validateFieldData() ? null : () { - validateAbsenceTransaction(selectedEmp!.isEmpty ? null : selectedEmp); + validateAbsenceTransaction(selectedEmp); }, ).insideContainer ], diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index 170e288..50096c7 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -31,13 +31,13 @@ class RequestSubmitScreenParams { int transactionId; String pItemId; String approvalFlag; + String? selectedEmployeeID; - RequestSubmitScreenParams(this.title, this.transactionId, this.pItemId, this.approvalFlag); + RequestSubmitScreenParams(this.title, this.transactionId, this.pItemId, this.approvalFlag, {this.selectedEmployeeID}); } class RequestSubmitScreen extends StatefulWidget { - final String selectedEmp; - RequestSubmitScreen({this.selectedEmp ='',Key? key}) : super(key: key); + RequestSubmitScreen({Key? key}) : super(key: key); @override _RequestSubmitScreenState createState() { @@ -53,7 +53,7 @@ class _RequestSubmitScreenState extends State { List attachmentFiles = []; List attachments = []; dynamic dynamicParams; - String selectedEmp =""; + String selectedEmp = ""; @override void initState() { @@ -64,7 +64,6 @@ class _RequestSubmitScreenState extends State { try { Utils.showLoading(context); approverList = await MyAttendanceApiClient().getApproversList("SSHRMS", params!.transactionId); - Utils.hideLoading(context); setState(() {}); } catch (ex) { @@ -123,12 +122,7 @@ class _RequestSubmitScreenState extends State { params!.transactionId, ); } else if (params!.approvalFlag == 'add_leave_balance') { - await LeaveBalanceApiClient().startAbsenceApprovalProcess( - params!.transactionId, - comments.text, - -999, - empID: widget.selectedEmp - ); + await LeaveBalanceApiClient().startAbsenceApprovalProcess(params!.transactionId, comments.text, -999, empID: params!.selectedEmployeeID); } else if (params!.approvalFlag == 'eit') { await MyAttendanceApiClient().startEitApprovalProcess( "SUBMIT", 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 9c0c51b..fe7a6f3 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -43,7 +43,6 @@ class _DynamicInputScreenState extends State { void getTransactionsStructure() async { try { Utils.showLoading(context); - genericResponseModel = await MyAttendanceApiClient().getEitDffStructure(dynamicParams!.dynamicId, dynamicParams!.selectedEmp); dESCFLEXCONTEXTCODE = genericResponseModel!.pDESCFLEXCONTEXTCODE ?? ""; descFlexConTextTitle = genericResponseModel!.pDESCFLEXCONTEXTNAME ?? ""; @@ -91,9 +90,8 @@ class _DynamicInputScreenState extends State { 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()); - genericResponseModel = await MyAttendanceApiClient().validateEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values, empID: dynamicParams!.selectedEmp ?? ''); - SubmitEITTransactionList submitEITTransactionList = - await MyAttendanceApiClient().submitEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values, empID: dynamicParams!.selectedEmp ?? ''); + genericResponseModel = await MyAttendanceApiClient().validateEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values, empID: dynamicParams!.selectedEmp); + SubmitEITTransactionList submitEITTransactionList = await MyAttendanceApiClient().submitEitTransaction(dESCFLEXCONTEXTCODE, dynamicParams!.dynamicId, values, empID: dynamicParams!.selectedEmp); Utils.hideLoading(context); await Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.submit.tr(), submitEITTransactionList.pTRANSACTIONID!, submitEITTransactionList.pITEMKEY!, 'eit')); @@ -130,7 +128,7 @@ class _DynamicInputScreenState extends State { .toList(); List eServicesResponseModel = await MyAttendanceApiClient().getValueSetValues(segmentId, structureList.dESCFLEXCONTEXTCODE!, structureList.dESCFLEXNAME!, values, - empID: dynamicParams!.selectedEmp ?? '', parentValue: structureList.eSERVICESDV!.pVALUECOLUMNNAME); + empID: dynamicParams!.selectedEmp, parentValue: structureList.eSERVICESDV!.pVALUECOLUMNNAME); List abc = genericResponseModel?.getEITDFFStructureList ?? []; getEitDffStructureList = abc; int index = getEitDffStructureList!.indexWhere((element) => element.sEGMENTNAME == segmentId); diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 9fc0070..1412641 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -67,23 +67,25 @@ class _EmployeeDetailsState extends State { } return Scaffold( - extendBody: true, - backgroundColor: MyColors.lightGreyEFColor, - body: Stack(children: [ - getEmployeeSubordinates!.eMPLOYEEIMAGE != null ? - Container( - height: 200, - margin: EdgeInsets.only(top: 30), - decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: new Container( - decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), - ), - ), - ) : Container( - decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), - ), + extendBody: true, + backgroundColor: MyColors.lightGreyEFColor, + body: Stack( + children: [ + getEmployeeSubordinates!.eMPLOYEEIMAGE != null + ? Container( + height: 200, + margin: EdgeInsets.only(top: 30), + decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), + child: new BackdropFilter( + filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: new Container( + decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), + ), + ), + ) + : Container( + decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), + ), SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( @@ -95,15 +97,13 @@ class _EmployeeDetailsState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - IconButton( - onPressed: () { - Navigator.pop(context); - }, - icon: Icon( - Icons.arrow_back_ios, - color: Colors.white, - ), - ), + CircleAvatar( + radius: 18, + backgroundColor: Colors.black.withOpacity(.21), + child: const Icon(Icons.arrow_back_ios_rounded, color: Colors.white, size: 18).paddingOnly(right: 4), + ).onPress(() { + Navigator.pop(context); + }), ], ), ), @@ -111,7 +111,9 @@ class _EmployeeDetailsState extends State { ], ), ) - ])); + ], + ), + ); } Widget myTeamInfo() { @@ -202,16 +204,8 @@ class _EmployeeDetailsState extends State { } Widget ProfileImage() => getEmployeeSubordinates?.eMPLOYEEIMAGE == null - ? SvgPicture.asset( - "assets/images/user.svg", - height: 68, - width: 68, - ) - : CircleAvatar( - radius: 68, - backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates?.eMPLOYEEIMAGE)), - backgroundColor: Colors.black, - ); + ? SvgPicture.asset("assets/images/user.svg", height: 68, width: 68) + : CircleAvatar(radius: 68, backgroundImage: MemoryImage(Utils.getPostBytes(getEmployeeSubordinates?.eMPLOYEEIMAGE)), backgroundColor: Colors.black); void setMenu() { menu = [ @@ -256,16 +250,17 @@ class _EmployeeDetailsState extends State { child: Column( children: [ Text(LocaleKeys.addFavoriteList).tr(namedArgs: {'name': '${getEmployeeSubordinates!.eMPLOYEENAME}'}), - getEmployeeSubordinates!.eMPLOYEEIMAGE == null - ? SvgPicture.asset( - "assets/images/user.svg", - height: 68, - width: 68,) - : CircleAvatar( - radius: 68, - backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), - backgroundColor: Colors.black, - ), + getEmployeeSubordinates!.eMPLOYEEIMAGE == null + ? SvgPicture.asset( + "assets/images/user.svg", + height: 68, + width: 68, + ) + : CircleAvatar( + radius: 68, + backgroundImage: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), + backgroundColor: Colors.black, + ), // Image.memory( // Utils.getPostBytes( // getEmployeeSubordinates!.eMPLOYEEIMAGE ?? "", From bcf67895b9928c5e1ca5227cbbfe7b48057dc22d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 21 Dec 2022 19:11:17 +0300 Subject: [PATCH 4/4] Dynamic forms & my team fixes --- assets/icons/chat/chat.svg | 26 +- assets/icons/create_req.svg | 10 +- assets/icons/home.svg | 8 +- assets/icons/item_for_sale.svg | 12 +- assets/icons/work_list.svg | 17 +- lib/classes/utils.dart | 13 +- lib/ui/marathon/widgets/marathon_banner.dart | 374 +++++++++--------- .../dynamic_screens/dynamic_input_screen.dart | 2 +- .../services_menu_list_screen.dart | 1 + lib/ui/my_team/create_request.dart | 10 +- lib/ui/my_team/employee_details.dart | 10 +- lib/ui/my_team/team_members.dart | 9 +- 12 files changed, 247 insertions(+), 245 deletions(-) diff --git a/assets/icons/chat/chat.svg b/assets/icons/chat/chat.svg index 29d4471..bf8977d 100644 --- a/assets/icons/chat/chat.svg +++ b/assets/icons/chat/chat.svg @@ -1,23 +1,13 @@ - - - - - + + + + + - - - - - - - - - - - - - + + + diff --git a/assets/icons/create_req.svg b/assets/icons/create_req.svg index a87e809..76f414f 100644 --- a/assets/icons/create_req.svg +++ b/assets/icons/create_req.svg @@ -1,7 +1,5 @@ - - - - - - + + + + diff --git a/assets/icons/home.svg b/assets/icons/home.svg index fb67997..91992ad 100644 --- a/assets/icons/home.svg +++ b/assets/icons/home.svg @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/assets/icons/item_for_sale.svg b/assets/icons/item_for_sale.svg index 0a87567..a908b3f 100644 --- a/assets/icons/item_for_sale.svg +++ b/assets/icons/item_for_sale.svg @@ -1,3 +1,11 @@ - - + + + + + + + + + + diff --git a/assets/icons/work_list.svg b/assets/icons/work_list.svg index a802c53..becb368 100644 --- a/assets/icons/work_list.svg +++ b/assets/icons/work_list.svg @@ -1,15 +1,6 @@ - - - - - - - - - - - - - + + + + diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 57bb888..572c09e 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -310,7 +310,18 @@ class Utils { } static String formatDateDefault(String date) { - return DateFormat('yyyy-MM-dd').format(DateFormat('dd-MMM-yyyy').parseLoose(date)); + if (date.toLowerCase().contains("t")) { + date = date.toLowerCase().split("t")[0]; + // return DateFormat('yyyy-MM-dd').format(DateFormat('dd-MM-yyyy').parseLoose(date)); + return DateFormat('dd-MM-yyyy').format(DateFormat('yyyy-MM-dd').parseLoose(date)); + } else { + if(date.toLowerCase().split("-")[1].length == 3) { + return DateFormat('dd-MM-yyyy').format(DateFormat('dd-MMM-yyyy').parseLoose(date)); + } else { + return DateFormat('dd-MM-yyyy').format(DateFormat('yyyy-MM-dd').parseLoose(date)); + } + // return DateFormat('yyyy-MM-dd').format(DateFormat('dd-MM-yyyy').parseLoose(date)); + } } static Future selectDate(BuildContext context, DateTime selectedDate) async { diff --git a/lib/ui/marathon/widgets/marathon_banner.dart b/lib/ui/marathon/widgets/marathon_banner.dart index 1b5533b..29c4fd3 100644 --- a/lib/ui/marathon/widgets/marathon_banner.dart +++ b/lib/ui/marathon/widgets/marathon_banner.dart @@ -184,202 +184,200 @@ class MarathonBanner extends StatelessWidget { Widget build(BuildContext context) { MarathonProvider provider = context.read(); - return - // !provider.isPrivilegedWithMarathon - // ? getUnPrivilegedMarathon(context) - // : provider.marathonDetailModel.startTime != null - // ? - Container( - decoration: MyDecorations.shadowDecoration, - height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11, - clipBehavior: Clip.antiAlias, - child: Stack( - children: [ - Transform( - alignment: Alignment.center, - transform: Matrix4.rotationY( - AppState().isArabic(context) ? math.pi : 0, - ), - child: SvgPicture.asset( - "assets/images/marathon_banner_bg.svg", - fit: BoxFit.fill, - width: double.infinity, - ), - ), - AppState().isArabic(context) - ? Positioned( - right: -15, - top: -10, - child: Transform.rotate( - angle: 10, - child: Container( - width: isTablet ? 70 : 65, - height: isTablet ? 40 : 32, - color: MyColors.darkDigitColor, - ), - ), - ) - : Positioned( - left: -20, - top: -10, - child: Transform.rotate( - angle: 15, - child: Container( - width: isTablet ? 70 : 65, - height: isTablet ? 40 : 32, - color: MyColors.darkDigitColor, + return provider.isPrivilegedWithMarathon + ? getUnPrivilegedMarathon(context) + : provider.marathonDetailModel.startTime != null + ? Container( + decoration: MyDecorations.shadowDecoration, + height: isTablet ? MediaQuery.of(context).size.height * 0.17 : MediaQuery.of(context).size.height * 0.11, + clipBehavior: Clip.antiAlias, + child: Stack( + children: [ + Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY( + AppState().isArabic(context) ? math.pi : 0, + ), + child: SvgPicture.asset( + "assets/images/marathon_banner_bg.svg", + fit: BoxFit.fill, + width: double.infinity, + ), ), - ), - ), - SizedBox( - width: double.infinity, - height: double.infinity, - child: Row( - children: [ - const Expanded( - flex: 3, - child: SizedBox( - width: double.infinity, - height: double.infinity, - ), - ), - Expanded( - flex: AppState().isArabic(context) ? 4 : 5, - child: SizedBox( - width: double.infinity, - height: double.infinity, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - AppState().isArabic(context) ? 0.height : 5.height, - Text( - LocaleKeys.getReadyForContest.tr(), - style: TextStyle( - fontSize: isTablet ? 20 : 11, - fontStyle: FontStyle.italic, - fontWeight: FontWeight.w600, - color: MyColors.white.withOpacity(0.83), - letterSpacing: -0.4, + AppState().isArabic(context) + ? Positioned( + right: -15, + top: -10, + child: Transform.rotate( + angle: 10, + child: Container( + width: isTablet ? 70 : 65, + height: isTablet ? 40 : 32, + color: MyColors.darkDigitColor, ), ), - Text( - AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "", - style: TextStyle( - fontStyle: FontStyle.italic, - fontSize: isTablet ? 30 : 19, - fontWeight: FontWeight.bold, - color: MyColors.white.withOpacity(0.83), - height: 32 / 22, + ) + : Positioned( + left: -20, + top: -10, + child: Transform.rotate( + angle: 15, + child: Container( + width: isTablet ? 70 : 65, + height: isTablet ? 40 : 32, + color: MyColors.darkDigitColor, ), ), - isTablet ? 10.height : 3.height, - BuildCountdownTimer( - timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch, - provider: provider, - screenFlag: 0, + ), + SizedBox( + width: double.infinity, + height: double.infinity, + child: Row( + children: [ + const Expanded( + flex: 3, + child: SizedBox( + width: double.infinity, + height: double.infinity, ), - ], - ).paddingOnly( - left: AppState().isArabic(context) ? 12 : 3, - right: AppState().isArabic(context) ? 3 : 12, - ) - ], - ), - ), - ), - ], - ), - ), - AppState().isArabic(context) - ? Align( - alignment: Alignment.topRight, - child: SizedBox( - height: isTablet ? 30 : 20, - width: isTablet ? 45 : 35, - child: Transform.rotate( - angle: math.pi / 4.5, - child: Text( - LocaleKeys.brainMarathon.tr(), - textAlign: TextAlign.center, - maxLines: 2, - style: TextStyle( - color: MyColors.white, - fontWeight: FontWeight.bold, - fontSize: isTablet ? 8 : 6, - height: 1.2, - ), - ), - ), - ), - ).paddingOnly(top: 5) - : Align( - alignment: Alignment.topLeft, - child: SizedBox( - height: isTablet ? 30 : 20, - width: isTablet ? 45 : 35, - child: Transform.rotate( - angle: -math.pi / 4.5, - child: Text( - LocaleKeys.brainMarathon.tr(), - textAlign: TextAlign.center, - maxLines: 2, - style: TextStyle( - color: MyColors.kWhiteColor, - fontWeight: FontWeight.bold, - fontSize: isTablet ? 8 : 6, - height: 1.2, - ), + ), + Expanded( + flex: AppState().isArabic(context) ? 4 : 5, + child: SizedBox( + width: double.infinity, + height: double.infinity, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + AppState().isArabic(context) ? 0.height : 5.height, + Text( + LocaleKeys.getReadyForContest.tr(), + style: TextStyle( + fontSize: isTablet ? 20 : 11, + fontStyle: FontStyle.italic, + fontWeight: FontWeight.w600, + color: MyColors.white.withOpacity(0.83), + letterSpacing: -0.4, + ), + ), + Text( + AppState().isArabic(context) ? provider.marathonDetailModel.titleAr ?? "" : provider.marathonDetailModel.titleEn ?? "", + style: TextStyle( + fontStyle: FontStyle.italic, + fontSize: isTablet ? 30 : 19, + fontWeight: FontWeight.bold, + color: MyColors.white.withOpacity(0.83), + height: 32 / 22, + ), + ), + isTablet ? 10.height : 3.height, + BuildCountdownTimer( + timeToMarathon: DateTime.parse(provider.marathonDetailModel.startTime!).millisecondsSinceEpoch, + provider: provider, + screenFlag: 0, + ), + ], + ).paddingOnly( + left: AppState().isArabic(context) ? 12 : 3, + right: AppState().isArabic(context) ? 3 : 12, + ) + ], + ), + ), + ), + ], ), ), - ), - ).paddingOnly(top: 5), - !AppState().isArabic(context) - ? Positioned( - right: 0, - bottom: 0, - child: RotatedBox( - quarterTurns: 4, - child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor), - ).paddingAll(isTablet ? 20 : 15), - ) - : Positioned( - bottom: 0, - left: 0, - child: RotatedBox( - quarterTurns: 2, - child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor), - ).paddingAll(isTablet ? 20 : 15), - ), - ], - ).onPress(() async { - int remainingTimeInMinutes = DateTime.parse(provider.marathonDetailModel.startTime!).difference(DateTime.now()).inMinutes; + AppState().isArabic(context) + ? Align( + alignment: Alignment.topRight, + child: SizedBox( + height: isTablet ? 30 : 20, + width: isTablet ? 45 : 35, + child: Transform.rotate( + angle: math.pi / 4.5, + child: Text( + LocaleKeys.brainMarathon.tr(), + textAlign: TextAlign.center, + maxLines: 2, + style: TextStyle( + color: MyColors.white, + fontWeight: FontWeight.bold, + fontSize: isTablet ? 8 : 6, + height: 1.2, + ), + ), + ), + ), + ).paddingOnly(top: 5) + : Align( + alignment: Alignment.topLeft, + child: SizedBox( + height: isTablet ? 30 : 20, + width: isTablet ? 45 : 35, + child: Transform.rotate( + angle: -math.pi / 4.5, + child: Text( + LocaleKeys.brainMarathon.tr(), + textAlign: TextAlign.center, + maxLines: 2, + style: TextStyle( + color: MyColors.kWhiteColor, + fontWeight: FontWeight.bold, + fontSize: isTablet ? 8 : 6, + height: 1.2, + ), + ), + ), + ), + ).paddingOnly(top: 5), + !AppState().isArabic(context) + ? Positioned( + right: 0, + bottom: 0, + child: RotatedBox( + quarterTurns: 4, + child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor), + ).paddingAll(isTablet ? 20 : 15), + ) + : Positioned( + bottom: 0, + left: 0, + child: RotatedBox( + quarterTurns: 2, + child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.whiteColor), + ).paddingAll(isTablet ? 20 : 15), + ), + ], + ).onPress(() async { + int remainingTimeInMinutes = DateTime.parse(provider.marathonDetailModel.startTime!).difference(DateTime.now()).inMinutes; - if (remainingTimeInMinutes > 2) { - Utils.showLoading(context); - try { - await provider.initializeVideoPlayer().then((_) { - Utils.hideLoading(context); - provider.startTimerForSponsorVideo(); - Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen); - }); - } catch (e) { - if (kDebugMode) { - print("Error in VideoPlayer: ${e.toString()}"); - } - Utils.hideLoading(context); - Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); - } - } else { - Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); - } - }), - ); - // ) - // : const SizedBox(); + if (remainingTimeInMinutes > 2) { + Utils.showLoading(context); + try { + await provider.initializeVideoPlayer().then((_) { + Utils.hideLoading(context); + provider.startTimerForSponsorVideo(); + Navigator.pushNamed(context, AppRoutes.marathonSponsorVideoScreen); + }); + } catch (e) { + if (kDebugMode) { + print("Error in VideoPlayer: ${e.toString()}"); + } + Utils.hideLoading(context); + Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); + } + } else { + Navigator.pushNamed(context, AppRoutes.marathonIntroScreen); + } + }), + // ); + ) + : const SizedBox(); } } 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 fe7a6f3..a94a6e2 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -188,7 +188,7 @@ class _DynamicInputScreenState extends State { // Utils.hideLoading(context); } } else if (values.isNotEmpty) { - ESERVICESDV defaultValue = await MyAttendanceApiClient().getDefaultValue(segmentId, structureList.dESCFLEXCONTEXTCODE!, structureList.dESCFLEXNAME!, values); + ESERVICESDV defaultValue = await MyAttendanceApiClient().getDefaultValue(segmentId, structureList.dESCFLEXCONTEXTCODE!, structureList.dESCFLEXNAME!, values, empID: dynamicParams!.selectedEmp); int index = getEitDffStructureList!.indexWhere((element) => element.sEGMENTNAME == segmentId); getEitDffStructureList![index].eSERVICESDV = defaultValue; } diff --git a/lib/ui/my_attendance/services_menu_list_screen.dart b/lib/ui/my_attendance/services_menu_list_screen.dart index 097a63a..8e44324 100644 --- a/lib/ui/my_attendance/services_menu_list_screen.dart +++ b/lib/ui/my_attendance/services_menu_list_screen.dart @@ -19,6 +19,7 @@ class ServicesMenuListScreenParams { final List list; final String? selectedEmp; GetEmployeeSubordinatesList? getEmployeeSubordinates; + ServicesMenuListScreenParams(this.title, this.list, {this.selectedEmp}); } diff --git a/lib/ui/my_team/create_request.dart b/lib/ui/my_team/create_request.dart index 94ac415..b77ac30 100644 --- a/lib/ui/my_team/create_request.dart +++ b/lib/ui/my_team/create_request.dart @@ -38,13 +38,13 @@ class _CreateRequestState extends State { @override void initState() { super.initState(); - employeeSubRequest(); + // employeeSubRequest(); } void employeeSubRequest() async { try { Utils.showLoading(context); - getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + // getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); getMenuEntriesList = await MyTeamApiClient().employeeSubordinatesRequest(getEmployeeSubordinates?.eMPLOYEENUMBER); homeMenus = parseMenus(getMenuEntriesList); Utils.hideLoading(context); @@ -80,8 +80,10 @@ class _CreateRequestState extends State { @override Widget build(BuildContext context) { - getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; - + if (getEmployeeSubordinates == null) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + employeeSubRequest(); + } return Scaffold( backgroundColor: Colors.white, appBar: AppBarWidget( diff --git a/lib/ui/my_team/employee_details.dart b/lib/ui/my_team/employee_details.dart index 1412641..e78c304 100644 --- a/lib/ui/my_team/employee_details.dart +++ b/lib/ui/my_team/employee_details.dart @@ -74,12 +74,12 @@ class _EmployeeDetailsState extends State { getEmployeeSubordinates!.eMPLOYEEIMAGE != null ? Container( height: 200, - margin: EdgeInsets.only(top: 30), + margin: const EdgeInsets.only(top: 30), decoration: BoxDecoration(image: DecorationImage(image: MemoryImage(Utils.dataFromBase64String(getEmployeeSubordinates!.eMPLOYEEIMAGE!)), fit: BoxFit.cover)), - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: new Container( - decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)), + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: Container( + decoration: BoxDecoration(color: Colors.white.withOpacity(0.0)), ), ), ) diff --git a/lib/ui/my_team/team_members.dart b/lib/ui/my_team/team_members.dart index c4defc4..8847c36 100644 --- a/lib/ui/my_team/team_members.dart +++ b/lib/ui/my_team/team_members.dart @@ -33,13 +33,13 @@ class _TeamMembersState extends State { void initState() { super.initState(); - employeeSubordinates(); + // employeeSubordinates(); } void employeeSubordinates() async { try { Utils.showLoading(context); - getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); + // getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString()); getEmployeeSubordinatesList = await MyTeamApiClient().employeeSubordinates(searchEmpEmail.toString(), searchEmpName.toString(), searchEmpNo.toString(), getEmployeeSubordinates?.eMPLOYEENUMBER); Utils.hideLoading(context); setState(() {}); @@ -51,7 +51,10 @@ class _TeamMembersState extends State { @override Widget build(BuildContext context) { - getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + if (getEmployeeSubordinates == null) { + getEmployeeSubordinates ??= ModalRoute.of(context)?.settings.arguments as GetEmployeeSubordinatesList; + employeeSubordinates(); + } return Scaffold( appBar: AppBarWidget( context,