UI_TRIPTYPE_SERVICE_HANDLING

This commit is contained in:
venbaittech 2025-07-31 18:15:37 +05:30
parent 8d6b62f0fa
commit a32fb0d0c3
10 changed files with 2309 additions and 1914 deletions

File diff suppressed because it is too large Load Diff

View File

@ -373,7 +373,15 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
// color: Colors.amber, // color: Colors.amber,
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(1.0), padding:
isDesktop
? const EdgeInsets.only(
top: 15,
bottom: 15,
left: 20,
right: 20,
)
: const EdgeInsets.only(top: 15, bottom: 15, left: 5, right: 5),
child: Container( child: Container(
// padding: const EdgeInsets.all(10.0), // padding: const EdgeInsets.all(10.0),
color: isDesktop ? Colors.white : Color(0xFFFCFCFC), color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
@ -473,6 +481,7 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
if (!isDesktop) const SizedBox(height: 10), if (!isDesktop) const SizedBox(height: 10),
if (!isDesktop) if (!isDesktop)
Row( Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.85, width: MediaQuery.of(context).size.width * 0.85,
@ -694,14 +703,18 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
), ),
DataCell( DataCell(
Text( SizedBox(
plan.tripTitle, width: 130,
style: TextStyle( child: Text(
fontSize: 13, plan.tripTitle,
fontFamily: "Inter", style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
),
softWrap: true,
maxLines: 2,
// overflow: TextOverflow.ellipsis,
), ),
softWrap: true,
overflow: TextOverflow.ellipsis,
), ),
), ),
@ -870,6 +883,34 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
); );
}, },
), ),
if (plan.statusValue ==
"Approved" &&
plan.forexId !=
null &&
plan.forexId !=
'')
IconButton(
icon: Icon(
Icons
.monetization_on_outlined,
color: Color(
0xFF475569,
),
size: 18,
),
tooltip:
'Download Forex PDF',
onPressed: () {
Navigator.pop(
context,
);
apiService
.getPdfDownload(
plan.forexId,
);
},
),
IconButton( IconButton(
icon: const Icon( icon: const Icon(
Icons.comment, Icons.comment,
@ -1003,6 +1044,7 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
PlanPopupMenu( PlanPopupMenu(
plan: plan, plan: plan,
deletePlan: deletePlan, deletePlan: deletePlan,
apiService: apiService, apiService: apiService,
layoutColor: layoutColor, layoutColor: layoutColor,
), ),

File diff suppressed because it is too large Load Diff

View File

@ -254,8 +254,8 @@ class _FlightListWidgetState extends State<FlightListWidget> {
"No Data Found", "No Data Found",
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 20, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w500,
color: Colors.grey, color: Colors.grey,
), ),
), ),

View File

@ -448,8 +448,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
String? selectedPurpose; String? selectedPurpose;
Map<String, String?> validationErrors = {}; Map<String, String?> validationErrors = {};
List<Map<String, dynamic>> miscellaneousList = [];
// List<Map<String, dynamic>> miscellaneousList = [{"special_request": 1, "comments": "posta", "indx": 1}]; // List<Map<String, dynamic>> miscellaneousList = [{"special_request": 1, "comments": "posta", "indx": 1}];
List<Map<String, dynamic>> miscellaneousList = [];
List<Map<String, dynamic>> visaList = []; List<Map<String, dynamic>> visaList = [];
List<Map<String, dynamic>> insuranceList = []; List<Map<String, dynamic>> insuranceList = [];
List<Map<String, dynamic>> accommodationList = []; List<Map<String, dynamic>> accommodationList = [];
@ -1316,6 +1317,56 @@ class CreateNewPlansState extends State<CreateNewPlan> {
} }
} }
Future<bool> serviceHasData() async {
return miscellaneousList.isNotEmpty ||
visaList.isNotEmpty ||
insuranceList.isNotEmpty ||
accommodationList.isNotEmpty ||
trainList.isNotEmpty ||
flightList.isNotEmpty ||
busList.isNotEmpty ||
taxiList.isNotEmpty ||
forexList.isNotEmpty;
}
void clearAllServiceLists() async {
setState(() {
miscellaneousList = [];
visaList = [];
insuranceList = [];
accommodationList = [];
trainList = [];
flightList = [];
busList = [];
taxiList = [];
forexList = [];
planData['miscellaneous'] = [];
planData['visa'] = [];
planData['insurance'] = [];
planData['accommodation'] = [];
planData['train'] = [];
planData['flight'] = [];
planData['bus'] = [];
planData['taxi'] = [];
planData['forex'] = [];
});
// Debugging output
print("After clearing:");
print("After clearing: $planData");
print("miscellaneousList: ${miscellaneousList.length}");
print("visaList: ${visaList.length}");
print("insuranceList: ${insuranceList.length}");
print("accommodationList: ${accommodationList.length}");
print("trainList: ${trainList.length}");
print("flightList: ${flightList.length}");
print("busList: ${busList.length}");
print("taxiList: ${taxiList.length}");
print("forexList: ${forexList.length}");
}
Future<void> checkExceptionalClass() async { Future<void> checkExceptionalClass() async {
// pretend we fetch something // pretend we fetch something
await Future.delayed(Duration(seconds: 1)); // Example async operation await Future.delayed(Duration(seconds: 1)); // Example async operation
@ -1850,6 +1901,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
onItineraryUpdate: handleItineraryUpdate, onItineraryUpdate: handleItineraryUpdate,
onExeptionalClass: handleExcentionalClass, onExeptionalClass: handleExcentionalClass,
loginUser: selfId, loginUser: selfId,
selectedPlanData: planData, selectedPlanData: planData,
isViewMode: widget.isViewMode, isViewMode: widget.isViewMode,
), ),
@ -1948,10 +2000,45 @@ class CreateNewPlansState extends State<CreateNewPlan> {
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
print("TRIP CLICKESS1");
// Request focus when user taps // Request focus when user taps
focusNodes["trip_typeFocusNode"]?.requestFocus(); focusNodes["trip_typeFocusNode"]?.requestFocus();
print("TRIP CLICKESS15");
}, },
child: DropdownSearch<Map<String, dynamic>>( child: DropdownSearch<Map<String, dynamic>>(
onBeforePopupOpening: (selectedItem) async {
bool hasData = await serviceHasData();
if (hasData) {
bool? shouldProceed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(
"Changing trip type will remove added services",
),
content: Text("Do you wish to proceed?"),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(false); // Cancel
},
child: Text("Cancel"),
),
TextButton(
onPressed: () {
Navigator.of(context).pop(true); // Continue
},
child: Text("Continue"),
),
],
);
},
);
return shouldProceed ?? false;
}
return true;
},
popupProps: PopupProps.menu( popupProps: PopupProps.menu(
showSearchBox: false, // Optionally enable search showSearchBox: false, // Optionally enable search
fit: FlexFit.loose, fit: FlexFit.loose,
@ -2046,6 +2133,16 @@ class CreateNewPlansState extends State<CreateNewPlan> {
widget.isViewMode widget.isViewMode
? null ? null
: (Map<String, dynamic>? newItem) { : (Map<String, dynamic>? newItem) {
final newTripType =
newItem?['dropdown_key'].toString();
print("newTripType - $newTripType");
print("_selectedTripType- $_selectedTripType");
if (newTripType != _selectedTripType) {
print("Type changed");
clearAllServiceLists();
dynamicItineraryKey.currentState
?.clearAllServiceLists();
}
if (newItem != null) { if (newItem != null) {
setState(() { setState(() {
_selectedTripType = _selectedTripType =
@ -2059,6 +2156,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
fetchTrainFlightClass( fetchTrainFlightClass(
int.parse(_selectedTripType!), int.parse(_selectedTripType!),
); );
dynamicItineraryKey.currentState dynamicItineraryKey.currentState
?.updateSelectedServices(); ?.updateSelectedServices();
}); });

View File

@ -104,6 +104,7 @@ class DynamicItineraryState extends State<DynamicItinerary> {
@override @override
void initState() { void initState() {
print("DynamicItinerary");
super.initState(); super.initState();
handleSelectedPlan(); handleSelectedPlan();
updateSelectedServices(); updateSelectedServices();
@ -128,7 +129,7 @@ class DynamicItineraryState extends State<DynamicItinerary> {
// selectedIndex = null; // selectedIndex = null;
// selectedItem = null; // selectedItem = null;
// }); // });
print("updateTripType - $_tripType");
updateTripType(widget.tripType); updateTripType(widget.tripType);
} }
} }
@ -187,6 +188,9 @@ class DynamicItineraryState extends State<DynamicItinerary> {
_tripType = newTripType; _tripType = newTripType;
}); });
updateSelectedServices(); // Refresh services based on new tripType updateSelectedServices(); // Refresh services based on new tripType
print("updateTripType2 - $newTripType");
handleSelectedPlan();
} }
} }
@ -268,6 +272,13 @@ class DynamicItineraryState extends State<DynamicItinerary> {
} }
} }
void clearAllServiceLists() async {
print("clearAllServiceLists");
setState(() {
itineraryData.updateAll((key, value) => []);
});
}
// Future<void> updateSelectedServices() async { // Future<void> updateSelectedServices() async {
// await loadAllServices(); // await loadAllServices();
// await loadOrgSelectedAlServices(); // await loadOrgSelectedAlServices();
@ -389,6 +400,7 @@ class DynamicItineraryState extends State<DynamicItinerary> {
} }
void handleSelectedPlan() { void handleSelectedPlan() {
print("handleSelectedPlan");
// Check if selectedPlanData has itinerary data // Check if selectedPlanData has itinerary data
if (hasAnyItineraryData()) { if (hasAnyItineraryData()) {
print("selectedPlanData HAS DATA"); print("selectedPlanData HAS DATA");

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ import 'dart:convert';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; // import 'package:flutter/rendering.dart';
import 'dart:html' as html; import 'dart:html' as html;
import 'package:frontend/config/apiUrl.dart'; // 1 newly added import 'package:frontend/config/apiUrl.dart'; // 1 newly added
import 'package:frontend/services/apiService.dart'; import 'package:frontend/services/apiService.dart';
@ -34,8 +34,8 @@ class _MyAppState extends State<MyApp> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SemanticsBinding.instance // SemanticsBinding.instance
.ensureSemantics(); // Safe here -only for testing uncomment, Otherwise Email Template wont allow to type // .ensureSemantics(); // Safe here -only for testing uncomment, Otherwise Email Template wont allow to type
if (kIsWeb) { if (kIsWeb) {
final uri = Uri.parse(html.window.location.href); final uri = Uri.parse(html.window.location.href);
print("URI - $uri"); print("URI - $uri");
@ -76,7 +76,7 @@ class _MyAppState extends State<MyApp> {
}); });
html.window.console.log("Auth code detected: $authCode"); html.window.console.log("Auth code detected: $authCode");
}else { } else {
html.window.console.log("No auth code found or wrong path."); html.window.console.log("No auth code found or wrong path.");
} }
} }
@ -110,32 +110,34 @@ class _MyAppState extends State<MyApp> {
setState(() { setState(() {
_isloading = false; _isloading = false;
}); });
if(_isloading){ const CircularProgressIndicator(); } if (_isloading) {
const CircularProgressIndicator();
}
final userData = prefs.getString('user_data'); final userData = prefs.getString('user_data');
print("MS Userdata - $userData"); print("MS Userdata - $userData");
final orgDataString = prefs.getString('org_data'); final orgDataString = prefs.getString('org_data');
print("MS orgdata - $orgDataString"); print("MS orgdata - $orgDataString");
if (orgDataString != null && userData != null){ if (orgDataString != null && userData != null) {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: "You're in!", msg: "You're in!",
toastLength: Toast.LENGTH_SHORT, toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER, gravity: ToastGravity.CENTER,
backgroundColor: Colors.green, backgroundColor: Colors.green,
textColor: Colors.white, textColor: Colors.white,
fontSize: 16, fontSize: 16,
webBgColor: "linear-gradient(to right, #28a745, #28a745)", webBgColor: "linear-gradient(to right, #28a745, #28a745)",
); );
print("Microsoft User Logged In Refer the Role - $userRole"); print("Microsoft User Logged In Refer the Role - $userRole");
// Navigate based on role // Navigate based on role
if (userRole == "Travel Agent") { if (userRole == "Travel Agent") {
router.go('/listTravelAgentPlan'); router.go('/listTravelAgentPlan');
} else if (userRole == "Org Admin" || userRole == "Travel Admin") { } else if (userRole == "Org Admin" || userRole == "Travel Admin") {
router.go('/StatusDashboard'); router.go('/StatusDashboard');
} else { } else {
router.go('/listPlan'); router.go('/listPlan');
} }
} }
} else { } else {
throw Exception('Token missing in response.'); throw Exception('Token missing in response.');
@ -172,7 +174,10 @@ class _MyAppState extends State<MyApp> {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
await prefs.setString('auth_token', token); await prefs.setString('auth_token', token);
await prefs.setString('user_data', jsonEncode(userData)); // Store full user data await prefs.setString(
'user_data',
jsonEncode(userData),
); // Store full user data
if (userData != null) { if (userData != null) {
final pref = await SharedPreferences.getInstance(); final pref = await SharedPreferences.getInstance();
@ -188,7 +193,6 @@ class _MyAppState extends State<MyApp> {
print("MicroSoft Started"); print("MicroSoft Started");
await apiService.getOrganizationData(); await apiService.getOrganizationData();
print("MicroSoft end"); print("MicroSoft end");
} catch (e) { } catch (e) {
print('Error decoding token MS: $e'); print('Error decoding token MS: $e');
router.go('/'); router.go('/');
@ -197,12 +201,9 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_isAuthRedirect) { if (_isAuthRedirect) {
return const MaterialApp( return const MaterialApp(
home: Scaffold( home: Scaffold(body: Center(child: CircularProgressIndicator())),
body: Center(child: CircularProgressIndicator()),
),
); );
} }

View File

@ -20,6 +20,7 @@ class Plan {
final String createdOn; final String createdOn;
final String? approverId; final String? approverId;
final String? delegaterId; final String? delegaterId;
final String? forexId;
Plan({ Plan({
required this.planId, required this.planId,
@ -41,6 +42,7 @@ class Plan {
required this.createdOn, required this.createdOn,
this.approverId, this.approverId,
this.delegaterId, this.delegaterId,
this.forexId,
}); });
factory Plan.fromJson(Map<String, dynamic> json) { factory Plan.fromJson(Map<String, dynamic> json) {
@ -55,8 +57,9 @@ class Plan {
? '' ? ''
: json['approver_status']?.toString() ?? "", : json['approver_status']?.toString() ?? "",
status: json['status'] == "0" ? "Inactive" : "Active", status: json['status'] == "0" ? "Inactive" : "Active",
costCenter: json['cost_center_value']?.toString() ?? "" , costCenter: json['cost_center_value']?.toString() ?? "",
functionalDepartment: json['functional_department_value']?.toString() ?? "", functionalDepartment:
json['functional_department_value']?.toString() ?? "",
purposeOfTravel: json['purpose_of_travel_value']?.toString() ?? "", purposeOfTravel: json['purpose_of_travel_value']?.toString() ?? "",
soNumber: json['so_number']?.toString() ?? "", soNumber: json['so_number']?.toString() ?? "",
description: json['description']?.toString() ?? "", description: json['description']?.toString() ?? "",
@ -73,9 +76,15 @@ class Plan {
statusValue: json["status_value"]?.toString() ?? "", statusValue: json["status_value"]?.toString() ?? "",
createdOn: json["created_on"]?.toString() ?? "", createdOn: json["created_on"]?.toString() ?? "",
approverId: approverId:
json["approver_id"] == null ? '' : json['approver_id']?.toString() ?? "", json["approver_id"] == null
? ''
: json['approver_id']?.toString() ?? "",
delegaterId: delegaterId:
json["delegater_id"] == null ? '' : json['delegater_id']?.toString() ?? "", json["delegater_id"] == null
? ''
: json['delegater_id']?.toString() ?? "",
forexId:
json["forex_id"] == null ? '' : json['forex_id']?.toString() ?? "",
); );
} }
} }

View File

@ -71,7 +71,7 @@ class PlanPopupMenu extends StatelessWidget {
IconButton( IconButton(
icon: Icon( icon: Icon(
Icons.download, Icons.download,
color: Color(0xFF114D8B), color: Color(0xFF475569),
size: 18, size: 18,
), ),
onPressed: () { onPressed: () {
@ -79,6 +79,22 @@ class PlanPopupMenu extends StatelessWidget {
apiService.getPdfDownload(plan.planId); apiService.getPdfDownload(plan.planId);
}, },
), ),
if (plan.statusValue == "Approved" &&
plan.forexId != null &&
plan.forexId != '')
IconButton(
icon: Icon(
Icons.monetization_on_outlined,
color: Color(0xFF475569),
size: 18,
),
tooltip: 'Download Forex PDF',
onPressed: () {
Navigator.pop(context);
apiService.getPdfDownload(plan.forexId);
},
),
IconButton( IconButton(
icon: const Icon( icon: const Icon(
Icons.comment, Icons.comment,