diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index ae5fda8..f04080c 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -14,11 +14,11 @@ import 'package:mohem_flutter_app/models/dashboard/get_accural_ticket_balance_mo import 'package:mohem_flutter_app/models/dashboard/get_attendance_tracking_list_model.dart'; import 'package:mohem_flutter_app/models/dashboard/itg_forms_model.dart'; import 'package:mohem_flutter_app/models/dashboard/list_menu.dart'; +import 'package:mohem_flutter_app/models/eit_attachment_ticket_model.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:mohem_flutter_app/models/sso_auth_model.dart'; -import 'package:platform_device_id_plus/platform_device_id.dart'; // import 'package:platform_device_id/platform_device_id.dart'; // import 'package:platform_device_id/platform_device_id.dart'; @@ -33,7 +33,7 @@ class DashboardApiClient { Future getAttendanceTracking() async { String url = "${ApiConsts.erpRest}GET_Attendance_Tracking"; - Map postParams = {}; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -47,7 +47,7 @@ class DashboardApiClient { Future getOpenNotifications() async { String url = "${ApiConsts.erpRest}GET_OPEN_NOTIFICATIONS"; - Map postParams = {}; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -61,7 +61,7 @@ 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}; + Map postParams = {"Date": DateUtil.getISODateFormat(DateTime.now()), "EmployeeNumber": AppState().memberInformationList?.eMPLOYEENUMBER}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -75,7 +75,7 @@ class DashboardApiClient { Future getItgFormsPendingTask() async { String url = "${ApiConsts.cocRest}ITGFormsPendingTasks"; - Map postParams = {}; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -89,13 +89,13 @@ class DashboardApiClient { Future> getAccrualBalances(String effectiveDate, {String? empID}) async { String url = "${ApiConsts.erpRest}GET_ACCRUAL_BALANCES"; - Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; + Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; 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.getAccrualBalancesList ?? []; + return responseData.getAccrualBalancesList ?? []; }, url, postParams, @@ -104,13 +104,13 @@ class DashboardApiClient { Future> getTicketAccuralBalance(String effectiveDate, {String? empID}) async { String url = "${ApiConsts.erpRest}GET_TICKET_ACCRUAL_BALANCES"; - Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; + Map postParams = {"P_EFFECTIVE_DATE": effectiveDate}; 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.getAccrualBalancesTicketList ?? []; + return responseData.getAccrualBalancesTicketList ?? []; }, url, postParams, @@ -119,7 +119,7 @@ class DashboardApiClient { Future getOpenMissingSwipes() async { String url = "${ApiConsts.erpRest}GET_OPEN_MISSING_SWIPES"; - Map postParams = {}; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -134,12 +134,12 @@ class DashboardApiClient { //Menus List Future> getListMenu() async { String url = "${ApiConsts.erpRest}GET_MENU"; - Map postParams = {}; + Map postParams = {}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { GenericResponseModel responseData = GenericResponseModel.fromJson(json); - return responseData.listMenu ?? []; + return responseData.listMenu ?? []; }, url, postParams, @@ -149,7 +149,7 @@ class DashboardApiClient { //GET_MENU_ENTRIES Future getGetMenuEntries() async { String url = "${ApiConsts.erpRest}GET_MENU_ENTRIES"; - Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; + Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -163,7 +163,7 @@ class DashboardApiClient { Future getEventActivity() async { String url = "${ApiConsts.erpRest}Get_EventActivity"; - Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; + Map postParams = {"P_SELECTED_RESP_ID": -999, "P_MENU_TYPE": "E"}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -177,7 +177,7 @@ class DashboardApiClient { Future getTicketBookingRedirection() async { String url = "${ApiConsts.erpRest}GET_PORTAL_REDIRECTION"; - Map postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER}; + Map postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( (json) { @@ -191,7 +191,7 @@ class DashboardApiClient { Future getTicketBalance() async { String url = "${ApiConsts.erpRest}GET_TICKET_BALANCE"; - Map postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER}; + Map postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER}; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject( @@ -208,7 +208,7 @@ class DashboardApiClient { String url = "${ApiConsts.ssoAuthRedirection}?grantType=mohemm"; //https://sso-uat.hmg.com/api/auth/connect?grantType=mohemm' // Map postParams = {"P_USER_NAME": AppState().memberInformationList?.eMPLOYEENUMBER}; - Map postParams = { + Map postParams = { "ClientId": clientID, // "ClientId": "a9f4d1a0596d4aea8f830992ec4bdac1", "PersonId": AppState().memberInformationList?.eMPLOYEENUMBER, @@ -227,18 +227,34 @@ class DashboardApiClient { ); } - Future getBookingSSOFinalRedirection({required String token}) async { - token = - "eyJhbGciOiJSUzI1NiIsImtpZCI6IjhjZTE2OWM0YjIwYjQ2ZWM5YTQyOTU3Y2ZhODUzNzQ1IiwidHlwIjoiSldUIn0.eyJ0ZW5hbnRfaWQiOiJhOWY0ZDFhMDU5NmQ0YWVhOGY4MzA5OTJlYzRiZGFjMSIsImVpZCI6IjExNzkzMCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL3NpZCI6Ijk2MDI0OGM1NzA3YzQ3MmFhYTEzM2I1N2ZhODE1ZmVhIiwibGFuZ3VhZ2UiOiJVUyIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6IjExNzkzMEBobWcuY29tIiwiZXhwIjoxNzgyNDc1NzY5LCJpc3MiOiJodHRwczovL3Nzby11YXQuaG1nLmNvbSIsImF1ZCI6ImE5ZjRkMWEwNTk2ZDRhZWE4ZjgzMDk5MmVjNGJkYWMxIn0.rJcLVsG8D0XECyLERCTD2uqGeWyvp-OBVGE9uL2qKrX4etFUHgdFt_5kYF6edFTtGy-0PIZadHDmv7e-IOhVWHm5HVMClaukiXoRXR8cDN8XA1wfme3Kd-U5PXN-IRh49AyRTzLO0rYNPvH81ScosWGlsFSkOvA-0hJNa2adHdtvgNvB8wJshSU5p7sAmF8mjdDY6aInG19etu2iEuUDwHHA4ZY_ts4hboHo8fE392hFaYGonExoD7bpW5RMx5xKWeRCmWpG_PK8Aw_z1jGzdB9PANus4pteRGuln1J-kmo2lQC9pVrSyZATAKp1HfgfyZ_vUhaHEfM69cMWaCslJQ"; - var request = http.MultipartRequest('POST', Uri.parse('https://ek.techmaster.in/SSO/HMG')); - request.fields.addAll({'JWTToken': token}); - - // request.headers.addAll(headers); + Future getTicketEitPDFDownload({required String peiExtraInfoId}) async { + String url = "${ApiConsts.erpRest}GET_EIT_ATTACHMENTS"; + Map postParams = { + "P_PERSON_EXTRA_INFO_ID": peiExtraInfoId, + "PersonId": AppState().memberInformationList?.eMPLOYEENUMBER, + "Username": AppState().memberInformationList?.eMPLOYEENUMBER, + "Language": "US", + "SessionId": AppState().postParamsObject?.pSessionId, + }; + postParams.addAll(AppState().postParamsJson); + return await ApiClient().postJsonForObject( + (json) { + GetEitAttachmentTicket responseData = GetEitAttachmentTicket.fromJson(json); + return responseData; + }, + url, + postParams, + ); + } + Future getBookingSSOFinalRedirection({required String token}) async { + // token = + // "eyJhbGciOiJSUzI1NiIsImtpZCI6IjhjZTE2OWM0YjIwYjQ2ZWM5YTQyOTU3Y2ZhODUzNzQ1IiwidHlwIjoiSldUIn0.eyJ0ZW5hbnRfaWQiOiJhOWY0ZDFhMDU5NmQ0YWVhOGY4MzA5OTJlYzRiZGFjMSIsImVpZCI6IjExNzkzMCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL3NpZCI6Ijk2MDI0OGM1NzA3YzQ3MmFhYTEzM2I1N2ZhODE1ZmVhIiwibGFuZ3VhZ2UiOiJVUyIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL2VtYWlsYWRkcmVzcyI6IjExNzkzMEBobWcuY29tIiwiZXhwIjoxNzgyNDc1NzY5LCJpc3MiOiJodHRwczovL3Nzby11YXQuaG1nLmNvbSIsImF1ZCI6ImE5ZjRkMWEwNTk2ZDRhZWE4ZjgzMDk5MmVjNGJkYWMxIn0.rJcLVsG8D0XECyLERCTD2uqGeWyvp-OBVGE9uL2qKrX4etFUHgdFt_5kYF6edFTtGy-0PIZadHDmv7e-IOhVWHm5HVMClaukiXoRXR8cDN8XA1wfme3Kd-U5PXN-IRh49AyRTzLO0rYNPvH81ScosWGlsFSkOvA-0hJNa2adHdtvgNvB8wJshSU5p7sAmF8mjdDY6aInG19etu2iEuUDwHHA4ZY_ts4hboHo8fE392hFaYGonExoD7bpW5RMx5xKWeRCmWpG_PK8Aw_z1jGzdB9PANus4pteRGuln1J-kmo2lQC9pVrSyZATAKp1HfgfyZ_vUhaHEfM69cMWaCslJQ"; + http.MultipartRequest request = http.MultipartRequest('POST', Uri.parse('https://ek.techmaster.in/SSO/HMG')); + request.fields.addAll({'JWTToken': token}); http.StreamedResponse response = await request.send(); if (response.statusCode == 302) { - print("================== post =========="); - var res = await response.stream.bytesToString(); + String res = await response.stream.bytesToString(); return response.headers["location"]; } else { print(response.reasonPhrase); @@ -256,7 +272,7 @@ class DashboardApiClient { String payrollCode = "", }) async { String url = "${ApiConsts.swpRest}AuthenticateAndSwipeUserSupportNFC"; - var uuid = Uuid(); + Uuid uuid = Uuid(); String? deviceId = ""; // Generate a v4 (random) id if (Platform.isAndroid) { @@ -266,7 +282,7 @@ class DashboardApiClient { IosDeviceInfo iosInfo = await DeviceInfoPlugin().iosInfo; deviceId = iosInfo.identifierForVendor; } - Map postParams = { + Map postParams = { "UID": deviceId, //uuid.v4(), //Mobile Id // "UID": uuid.v4(), //Mobile Id "Latitude": lat, @@ -292,10 +308,10 @@ class DashboardApiClient { //Mark Fake Location Future markFakeLocation({String lat = "0", String? long = "0", required String sourceName}) async { String url = "${ApiConsts.swpRest}CreateIssueInfo"; - var uuid = Uuid(); + Uuid uuid = Uuid(); // Generate a v4 (random) id - Map postParams = { + Map postParams = { "UID": uuid.v4(), //Mobile Id "Latitude": lat, "Longitude": long, @@ -319,7 +335,7 @@ class DashboardApiClient { Future getITGPageNotification() async { String url = "${ApiConsts.cocRest}Mohemm_ITG_GetPageNotification"; - Map postParams = { + Map postParams = { "EmployeeNumber": AppState().getUserName, "ItgEnableAt": "After Service Submission", //Mobile Id "ItgServiceName": "Login", @@ -341,7 +357,7 @@ class DashboardApiClient { Future submitItgForm({required String comment, required String masterId, required List> itgList, required int serviceId}) async { String url = "${ApiConsts.cocRest}Mohemm_ITG_Survey_Response"; - Map postParams = { + Map postParams = { "EmployeeNumber": AppState().getUserName, "ItgComments": comment, "ItgNotificationMasterId": masterId, @@ -362,7 +378,7 @@ class DashboardApiClient { Future getAdvertisementDetail(String masterID) async { String url = "${ApiConsts.cocRest}Mohemm_ITG_GetPageNotificationDetails"; - Map postParams = { + Map postParams = { "EmployeeNumber": AppState().getUserName, "ItgNotificationMasterId": masterID, //Mobile Id }; @@ -380,7 +396,7 @@ class DashboardApiClient { Future setAdvertisementViewed(String masterID, int advertisementId, String? ackValue) async { String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed"; - Map postParams = { + Map postParams = { "ItgNotificationMasterId": masterID, "EmployeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(), "ItgAdvertisementId": advertisementId, diff --git a/lib/models/eit/get_eit_transaction_model.dart b/lib/models/eit/get_eit_transaction_model.dart index dffe320..eec3d98 100644 --- a/lib/models/eit/get_eit_transaction_model.dart +++ b/lib/models/eit/get_eit_transaction_model.dart @@ -30,7 +30,7 @@ class CollectionTransaction { String? dISPLAYFLAG; int? fROMROWNUM; int? nOOFROWS; - dynamic? nUMBERVALUE; + dynamic nUMBERVALUE; int? rOWNUM; String? sEGMENTNAME; String? sEGMENTPROMPT; @@ -80,7 +80,7 @@ class CollectionTransaction { } Map toJson() { - Map data = new Map(); + Map data = Map(); data['APPLICATION_COLUMN_NAME'] = this.aPPLICATIONCOLUMNNAME; data['DATATYPE'] = this.dATATYPE; data['DATE_VALUE'] = this.dATEVALUE; diff --git a/lib/models/eit_attachment_ticket_model.dart b/lib/models/eit_attachment_ticket_model.dart new file mode 100644 index 0000000..fe88831 --- /dev/null +++ b/lib/models/eit_attachment_ticket_model.dart @@ -0,0 +1,97 @@ +import 'dart:convert'; + +class GetEitAttachmentTicket { + List? getEitAttachmentList; + + GetEitAttachmentTicket({ + this.getEitAttachmentList, + }); + + factory GetEitAttachmentTicket.fromRawJson(String str) => GetEitAttachmentTicket.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory GetEitAttachmentTicket.fromJson(Map json) => GetEitAttachmentTicket( + getEitAttachmentList: json["GetEITAttachmentList"] == null ? [] : List.from(json["GetEITAttachmentList"]!.map((x) => GetEitAttachmentList.fromJson(x))), + ); + + Map toJson() => { + "GetEITAttachmentList": getEitAttachmentList == null ? [] : List.from(getEitAttachmentList!.map((x) => x.toJson())), + }; +} + +class GetEitAttachmentList { + int? attachedDocumentId; + int? categoryId; + int? datatypeId; + int? documentId; + String? entityName; + String? fileContentType; + String? fileData; + int? fileId; + String? fileName; + String? pk1Value; + String? pk2Value; + String? pk3Value; + String? pk4Value; + String? pk5Value; + int? seqNum; + + GetEitAttachmentList({ + this.attachedDocumentId, + this.categoryId, + this.datatypeId, + this.documentId, + this.entityName, + this.fileContentType, + this.fileData, + this.fileId, + this.fileName, + this.pk1Value, + this.pk2Value, + this.pk3Value, + this.pk4Value, + this.pk5Value, + this.seqNum, + }); + + factory GetEitAttachmentList.fromRawJson(String str) => GetEitAttachmentList.fromJson(json.decode(str)); + + String toRawJson() => json.encode(toJson()); + + factory GetEitAttachmentList.fromJson(Map json) => GetEitAttachmentList( + attachedDocumentId: json["ATTACHED_DOCUMENT_ID"], + categoryId: json["CATEGORY_ID"], + datatypeId: json["DATATYPE_ID"], + documentId: json["DOCUMENT_ID"], + entityName: json["ENTITY_NAME"], + fileContentType: json["FILE_CONTENT_TYPE"], + fileData: json["FILE_DATA"], + fileId: json["FILE_ID"], + fileName: json["FILE_NAME"], + pk1Value: json["PK1_VALUE"], + pk2Value: json["PK2_VALUE"], + pk3Value: json["PK3_VALUE"], + pk4Value: json["PK4_VALUE"], + pk5Value: json["PK5_VALUE"], + seqNum: json["SEQ_NUM"], + ); + + Map toJson() => { + "ATTACHED_DOCUMENT_ID": attachedDocumentId, + "CATEGORY_ID": categoryId, + "DATATYPE_ID": datatypeId, + "DOCUMENT_ID": documentId, + "ENTITY_NAME": entityName, + "FILE_CONTENT_TYPE": fileContentType, + "FILE_DATA": fileData, + "FILE_ID": fileId, + "FILE_NAME": fileName, + "PK1_VALUE": pk1Value, + "PK2_VALUE": pk2Value, + "PK3_VALUE": pk3Value, + "PK4_VALUE": pk4Value, + "PK5_VALUE": pk5Value, + "SEQ_NUM": seqNum, + }; +} diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index 05c9ebb..bdd60c7 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -20,6 +20,7 @@ import 'package:mohem_flutter_app/models/dashboard/menu_entries.dart'; import 'package:mohem_flutter_app/models/dashboard/menus.dart'; import 'package:mohem_flutter_app/models/dashboard/mohemm_itg_pending_task_responseitem.dart'; import 'package:mohem_flutter_app/models/eit/get_eit_transaction_model.dart'; +import 'package:mohem_flutter_app/models/eit_attachment_ticket_model.dart'; import 'package:mohem_flutter_app/models/generic_response_model.dart'; import 'package:mohem_flutter_app/models/itg/itg_response_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart'; @@ -376,6 +377,23 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } + Future getTicketEitPDFDownload({String? peiExtraInfoId}) async { + try { + GetEitAttachmentTicket? res = await DashboardApiClient().getTicketEitPDFDownload(peiExtraInfoId: peiExtraInfoId!); + if (res?.getEitAttachmentList != null && res?.getEitAttachmentList!.length! != 0 && res!.getEitAttachmentList!.first.fileData != null) { + return res; + } else { + return null; + } + } catch (ex) { + logger.wtf(ex); + isEventLoadingLoading = false; + notifyListeners(); + Utils.handleException(ex, null, null); + return null; // Ensure a return value in case of an exception + } + } + List parseMenus(List getMenuEntriesList) { List menus = []; for (int i = 0; i < getMenuEntriesList.length; i++) { diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart index be04937..72df91c 100644 --- a/lib/ui/landing/widget/menus_widget.dart +++ b/lib/ui/landing/widget/menus_widget.dart @@ -8,6 +8,7 @@ import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/models/eit/get_eit_transaction_model.dart'; import 'package:mohem_flutter_app/models/sso_auth_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart'; diff --git a/lib/ui/screens/ticket/ticket_detailed_screen.dart b/lib/ui/screens/ticket/ticket_detailed_screen.dart index d406153..3e8d0b1 100644 --- a/lib/ui/screens/ticket/ticket_detailed_screen.dart +++ b/lib/ui/screens/ticket/ticket_detailed_screen.dart @@ -5,11 +5,14 @@ import 'package:flutter/material.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/date_uitl.dart'; +import 'package:mohem_flutter_app/classes/file_process.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/models/dashboard/get_accural_ticket_balance_model.dart'; +import 'package:mohem_flutter_app/models/eit/get_eit_transaction_model.dart'; +import 'package:mohem_flutter_app/models/eit_attachment_ticket_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/balances_dashboard_widget.dart'; @@ -125,8 +128,8 @@ class _TicketDetailedScreenState extends State { shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (BuildContext cxt, int cardIndex) { - var transactionDetails = dashboardProviderModel!.ticketHistoryTransactionList![cardIndex]; - const allowedSegmentNames = { + List transactionDetails = dashboardProviderModel!.ticketHistoryTransactionList![cardIndex]; + const Set allowedSegmentNames = { "TICKETS_ROUTE", "TRAVELER_NAME", "TICKETS_EFFECTIVE_DATE", @@ -135,11 +138,22 @@ class _TicketDetailedScreenState extends State { "TICKET_COMP_SHARE", "TICKET_EMP_SHARE", }; - var uniqueDetails = + // Get items for display + List uniqueDetails = transactionDetails - .where((item) => item.dISPLAYFLAG != 'N' && item.sEGMENTPROMPT != null && item.sEGMENTPROMPT!.isNotEmpty && allowedSegmentNames.contains(item.sEGMENTNAME)) + .where( + (CollectionTransaction item) => + item.dISPLAYFLAG != 'N' && item.sEGMENTPROMPT != null && item.sEGMENTPROMPT!.isNotEmpty && allowedSegmentNames.contains(item.sEGMENTNAME), + ) .toList(); + // Get PEI_EXTRA_INFO_ID value for View PDF + CollectionTransaction? peiExtraInfoItem = transactionDetails.firstWhere( + (CollectionTransaction item) => item.aPPLICATIONCOLUMNNAME == "PEI_EXTRA_INFO_ID", + orElse: () => CollectionTransaction(), + ); + num? peiExtraInfoId = peiExtraInfoItem.nUMBERVALUE; + return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -148,15 +162,15 @@ class _TicketDetailedScreenState extends State { physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: (uniqueDetails.length / 2).ceil(), - itemBuilder: (context, rowIndex) { + itemBuilder: (BuildContext context, int rowIndex) { int firstIndex = rowIndex * 2; int? secondIndex = (firstIndex + 1 < uniqueDetails.length) ? firstIndex + 1 : null; bool isLastRow = (rowIndex == (uniqueDetails.length / 2).ceil() - 1); - var item1 = uniqueDetails[firstIndex]; - var child1 = ItemDetailViewCol(item1.sEGMENTPROMPT!, item1.vARCHAR2VALUE ?? item1.nUMBERVALUE?.toString() ?? ""); + CollectionTransaction item1 = uniqueDetails[firstIndex]; + ItemDetailViewCol child1 = ItemDetailViewCol(item1.sEGMENTPROMPT!, item1.vARCHAR2VALUE ?? item1.nUMBERVALUE?.toString() ?? ""); Widget child2; if (secondIndex != null) { - var item2 = uniqueDetails[secondIndex]; + CollectionTransaction item2 = uniqueDetails[secondIndex]; child2 = ItemDetailViewCol(item2.sEGMENTPROMPT!, item2.vARCHAR2VALUE ?? item2.nUMBERVALUE?.toString() ?? ""); } else { child2 = const SizedBox(); // Empty widget if there is no second item @@ -164,6 +178,40 @@ class _TicketDetailedScreenState extends State { return ItemDetailGrid(child1, child2, isItLast: isLastRow); }, ), + // View PDF link at the bottom + if (peiExtraInfoId != null) ...[ + const SizedBox(height: 5), + Align( + alignment: Alignment.centerRight, + child: GestureDetector( + onTap: () async { + Utils.showLoading(context); + try { + GetEitAttachmentTicket? result = await dashboardProviderModel!.getTicketEitPDFDownload(peiExtraInfoId: peiExtraInfoId.toString()); + if (result != null && result.getEitAttachmentList != null && result.getEitAttachmentList!.isNotEmpty) { + String? base64Data = result.getEitAttachmentList!.first.fileData; + if (base64Data != null && base64Data.isNotEmpty) { + String fileName = result.getEitAttachmentList!.first.fileName!; + await FileProcess.downloadFile(base64Data, fileName); + Utils.hideLoading(context); + FileProcess.openFile(fileName); + } else { + Utils.hideLoading(context); + Utils.showToast("PDF data not available"); + } + } else { + Utils.hideLoading(context); + Utils.showToast("No attachment found"); + } + } catch (e) { + Utils.hideLoading(context); + Utils.showToast("Something Went Wrong"); + } + }, + child: Padding(padding: const EdgeInsets.only(top: 8.0, left: 0.0, bottom: 8.0), child: "View PDF".toText14(isUnderLine: true, isBold: true)), + ), + ), + ], ], ).objectContainerView(); },