merge with old code

This commit is contained in:
venba-Inspriron-3558 2025-06-11 17:52:15 +05:30
commit 128b0ea9e6
12 changed files with 1214 additions and 1018 deletions

View File

@ -898,6 +898,7 @@ class _ApprovalListState extends State<ApprovalList> {
plan.planId, plan.planId,
plan.approverId, plan.approverId,
plan.delegaterId, plan.delegaterId,
plan.approver_status,
isViewMode: isViewMode:
false, false,
isApprover: isApprover:
@ -1144,6 +1145,7 @@ class _ApprovalListState extends State<ApprovalList> {
plan.planId, plan.planId,
plan.approverId, plan.approverId,
plan.delegaterId, plan.delegaterId,
plan.approver_status,
isViewMode: false, isViewMode: false,
isApprover: true, isApprover: true,
); );

View File

@ -125,6 +125,7 @@ class _LoginWidgetState extends State<LoginWidget> {
final token = data['token']; // Assuming the token is in response final token = data['token']; // Assuming the token is in response
// final userId = data['user_id'].toString(); // final userId = data['user_id'].toString();
print("Token - $token");
await storeUserDetails(token); await storeUserDetails(token);
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(

View File

@ -568,7 +568,7 @@ class FlightScreenState extends State<FlightScreen> {
} }
bool validateFields() { bool validateFields() {
// errorMessages.clear(); // Reset errors errorMessages.clear(); // Reset errors
rowCount = 1; // Default row count for One-way rowCount = 1; // Default row count for One-way
if (selectedTripType == "Roundtrip") { if (selectedTripType == "Roundtrip") {
@ -636,6 +636,8 @@ class FlightScreenState extends State<FlightScreen> {
print("Error: from_place_$i duplicates a previous departure"); print("Error: from_place_$i duplicates a previous departure");
} else { } else {
seenFrom.add(fromValue); seenFrom.add(fromValue);
// errorMessages.remove("from_place_$i");
} }
} }
@ -644,6 +646,7 @@ class FlightScreenState extends State<FlightScreen> {
errorMessages["to_place_$i"] = "Duplicate Destination "; errorMessages["to_place_$i"] = "Duplicate Destination ";
print("Error: to_place_$i duplicates a previous departure"); print("Error: to_place_$i duplicates a previous departure");
} else { } else {
// errorMessages.remove("to_place_$i");
seenTo.add(toValue); seenTo.add(toValue);
} }
} }
@ -663,7 +666,7 @@ class FlightScreenState extends State<FlightScreen> {
try { try {
DateTime date = format.parseStrict(dateStr); DateTime date = format.parseStrict(dateStr);
date = DateTime( date = DateTime(
now.year, date.year,
date.month, date.month,
date.day, date.day,
); // Assume current year ); // Assume current year
@ -709,6 +712,8 @@ class FlightScreenState extends State<FlightScreen> {
} else if (!parsedDates[i].isAfter(parsedDates[i - 1])) { } else if (!parsedDates[i].isAfter(parsedDates[i - 1])) {
errorMessages["date_${i + 1}"] = "Must be after date_${i}"; errorMessages["date_${i + 1}"] = "Must be after date_${i}";
print("Error: date_${i + 1} is not after date_${i}"); print("Error: date_${i + 1} is not after date_${i}");
} else {
errorMessages.remove("date_${i + 1}");
} }
} }

View File

@ -297,6 +297,11 @@ class _ForexScreenState extends State<ForexScreen> {
errorMessages["end_date"] = errorMessages["end_date"] =
"End date cannot be earlier than start date"; "End date cannot be earlier than start date";
; ;
} else if (checkEndDate.isAtSameMomentAs(checkStartDate)) {
setState(() {
errorMessages["end_date"] =
"Start and end dates cannot be the same";
});
} }
} catch (e) { } catch (e) {
errorMessages["end_date"] = "Invalid date format"; errorMessages["end_date"] = "Invalid date format";
@ -350,16 +355,6 @@ class _ForexScreenState extends State<ForexScreen> {
final cash = data["deposit_on_cash"]; final cash = data["deposit_on_cash"];
print("card - $card"); print("card - $card");
print("cash - $cash"); print("cash - $cash");
// Call validations first (they populate errorMessages)
_validateCardAmount(card);
_validateCashAmount(cash);
// Now check if any errors exist
if (errorMessages.isNotEmpty) {
print("Validation Failed: ${errorMessages}");
setState(() {}); // Refresh UI with error messages
return;
}
if (!isValidForexData(data)) { if (!isValidForexData(data)) {
// && errorMessages.isNotEmpty) { // && errorMessages.isNotEmpty) {
@ -416,6 +411,7 @@ class _ForexScreenState extends State<ForexScreen> {
textControllers["_forexStartDate"]?.addListener(_onFieldChanged); textControllers["_forexStartDate"]?.addListener(_onFieldChanged);
textControllers["_forexEndDate"]?.addListener(_onFieldChanged); textControllers["_forexEndDate"]?.addListener(_onFieldChanged);
flightFirstTripDateNotifier = ValueNotifier<String?>(null); flightFirstTripDateNotifier = ValueNotifier<String?>(null);
flightLastTripDateNotifier = ValueNotifier<String?>(null); flightLastTripDateNotifier = ValueNotifier<String?>(null);
@ -509,6 +505,7 @@ class _ForexScreenState extends State<ForexScreen> {
// textControllers["_cardNumber"]!.text = userCardNumber ?? ''; // textControllers["_cardNumber"]!.text = userCardNumber ?? '';
// //
// } // }
_onFieldChangedForOthers(); _onFieldChangedForOthers();
setState(() {}); // Update the UI setState(() {}); // Update the UI
@ -544,7 +541,6 @@ class _ForexScreenState extends State<ForexScreen> {
// Handle field changes // Handle field changes
void _onFieldChanged() { void _onFieldChanged() {
print("_on Field Changed Called");
if (_isForexDataDurationComplete()) { if (_isForexDataDurationComplete()) {
print("Calculate 1"); print("Calculate 1");
CalculateDuration(); CalculateDuration();
@ -581,7 +577,8 @@ class _ForexScreenState extends State<ForexScreen> {
print("Calculate 4"); print("Calculate 4");
// Calculate difference // Calculate difference
final durationInDays = endDate.difference(startDate).inDays ; // +1 to include both days final durationInDays =
endDate.difference(startDate).inDays; // +1 to include both days
// You can now use durationInDays however you want: // You can now use durationInDays however you want:
print("Duration: $durationInDays days"); print("Duration: $durationInDays days");
@ -763,9 +760,6 @@ class _ForexScreenState extends State<ForexScreen> {
for (var controller in textControllers.values) { for (var controller in textControllers.values) {
controller.dispose(); controller.dispose();
} }
// textControllers["_forexStartDate"]?.removeListener(_onFieldChanged);
// textControllers["_forexEndDate"]?.removeListener(_onFieldChanged);
// textControllers.forEach((_, controller) => controller.dispose());
super.dispose(); super.dispose();
} }
@ -1021,19 +1015,37 @@ class _ForexScreenState extends State<ForexScreen> {
textControllers["_forexEndDate"]!.text, textControllers["_forexEndDate"]!.text,
); );
if (startDate != null && if (startDate != null && endDate != null) {
endDate != null && if (endDate.isBefore(startDate)) {
endDate.isBefore(startDate)) {
setState(() { setState(() {
errorMessages["end_date"] = errorMessages["end_date"] =
"End date cannot be earlier than start date"; "End date cannot be earlier than start date";
}); });
} else if (endDate.isAtSameMomentAs(startDate)) {
setState(() {
errorMessages["end_date"] =
"Start and end dates cannot be the same";
});
} else { } else {
setState(() { setState(() {
errorMessages.remove("end_date"); errorMessages.remove("end_date");
}); });
} }
} }
// if (startDate != null &&
// endDate != null &&
// endDate.isBefore(startDate)) {
// setState(() {
// errorMessages["end_date"] =
// "End date cannot be earlier than start date";
// });
// } else {
// setState(() {
// errorMessages.remove("end_date");
// });
// }
}
}, },
child: AbsorbPointer( child: AbsorbPointer(
child: TextField( child: TextField(
@ -1108,6 +1120,11 @@ class _ForexScreenState extends State<ForexScreen> {
errorMessages["end_date"] = errorMessages["end_date"] =
"End date cannot be earlier than start date"; "End date cannot be earlier than start date";
}); });
} else if (endDate!.isAtSameMomentAs(startDate!)) {
setState(() {
errorMessages["end_date"] =
"Start and end dates cannot be the same";
});
} else { } else {
setState(() { setState(() {
errorMessages.remove("end_date"); errorMessages.remove("end_date");

View File

@ -124,6 +124,7 @@ class _CreatePlansState extends State<CreatePlan> {
final bool isApprover = args?['isApprover'] ?? false; final bool isApprover = args?['isApprover'] ?? false;
final String approverId = args['approverId'] ?? ""; final String approverId = args['approverId'] ?? "";
final String delegaterId = args['delegaterId'] ?? ""; final String delegaterId = args['delegaterId'] ?? "";
final String approverStatus = args['approver_status'] ?? "";
final Map<String, dynamic> planData = final Map<String, dynamic> planData =
args['planData'] as Map<String, dynamic>? ?? {}; args['planData'] as Map<String, dynamic>? ?? {};
@ -216,6 +217,7 @@ class _CreatePlansState extends State<CreatePlan> {
isApprover: isApprover, isApprover: isApprover,
approverId: approverId, approverId: approverId,
delegaterId: delegaterId, delegaterId: delegaterId,
approverStatus: approverStatus,
), ),
), ),
), ),
@ -325,6 +327,7 @@ class CreateNewPlan extends StatefulWidget {
final bool isDesktop; final bool isDesktop;
final bool isViewMode; final bool isViewMode;
final bool isApprover; final bool isApprover;
final String? approverStatus;
final Color? bodyColor; final Color? bodyColor;
final Color? layoutColor; final Color? layoutColor;
@ -341,6 +344,7 @@ class CreateNewPlan extends StatefulWidget {
required this.selectedPlanData, required this.selectedPlanData,
required this.isViewMode, required this.isViewMode,
required this.isApprover, required this.isApprover,
required this.approverStatus,
required this.approverId, required this.approverId,
required this.delegaterId, required this.delegaterId,
}); });
@ -375,6 +379,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
bool isStatusExpanded = false; bool isStatusExpanded = false;
bool isShowApprovalAction = false; bool isShowApprovalAction = false;
String? selectedPlanId; String? selectedPlanId;
String? approverStatus;
String? userDetails; String? userDetails;
String? userName; String? userName;
@ -502,7 +507,11 @@ class CreateNewPlansState extends State<CreateNewPlan> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
print("approverStatus - ${widget.approverStatus}");
if (widget.approverStatus == "Approval pending") {
print("Status approver - Approval Pending");
}
flightTripTypeNotifier = ValueNotifier(null); flightTripTypeNotifier = ValueNotifier(null);
fetchUserDetails(); fetchUserDetails();
@ -1169,6 +1178,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
data['plan_id'], data['plan_id'],
data['approverId'], data['approverId'],
data['delegaterId'], data['delegaterId'],
data['approver_status'],
isViewMode: false, isViewMode: false,
isApprover: true, isApprover: true,
); );
@ -1295,7 +1306,10 @@ class CreateNewPlansState extends State<CreateNewPlan> {
), ),
); );
return ResponsiveBuilder( return FocusTraversalGroup(
policy: OrderedTraversalPolicy(), // 👈 more predictable tab order
descendantsAreFocusable: true,
child: ResponsiveBuilder(
builder: (context, sizingInfo) { builder: (context, sizingInfo) {
bool isMobile = sizingInfo.isMobile; bool isMobile = sizingInfo.isMobile;
bool isDesktop = bool isDesktop =
@ -1360,7 +1374,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
Row( Row(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [_buildTripName(isDesktop)], children: [
_buildTripName(isDesktop),
],
), ),
], ],
), ),
@ -1655,6 +1671,8 @@ class CreateNewPlansState extends State<CreateNewPlan> {
// ], // ],
// ) // )
}, },
),
// replace with your full form column
); );
} }
@ -3132,7 +3150,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
// ], // ],
// ), // ),
const SizedBox(height: 10, width: 10), const SizedBox(height: 10, width: 10),
if (widget.isApprover) if (widget.isApprover && (widget.approverStatus == "Approval pending"))
GestureDetector( GestureDetector(
// onTap: () { // onTap: () {
// setState(() { // setState(() {

View File

@ -64,6 +64,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
final Map<String, TextEditingController> controllers = {}; final Map<String, TextEditingController> controllers = {};
bool isViewMode = false; bool isViewMode = false;
bool isEditProfile = false; bool isEditProfile = false;
// late final List<dynamic>? apiCountryData ; // late final List<dynamic>? apiCountryData ;
late List<dynamic>? apiCountryData; late List<dynamic>? apiCountryData;
@ -86,6 +87,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
String? selectedCountry; String? selectedCountry;
String? selectedGender; String? selectedGender;
// String? selectedGender = personalDetailsKey.currentState?.selectedGender; // String? selectedGender = personalDetailsKey.currentState?.selectedGender;
String? selectedUserType; String? selectedUserType;
@ -654,11 +656,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
void handleSubmit() async { void handleSubmit() async {
print("USR Detail Submit"); print("USR Detail Submit");
// printFormData(); // printFormData();
print("travel validation");
bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false; bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false;
if (selectedTab == "travel" || if (selectedRole == "5" || setSelectesUserType == true) {
selectedRole == "5" ||
setSelectesUserType == true) {
print("NO validation"); print("NO validation");
Map<String, dynamic> data = userDetials; Map<String, dynamic> data = userDetials;
@ -702,30 +702,64 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// block-submit-here // block-submit-here
// Additional validation starts - travelDetailsData passport
DateTime? start_Date = travelDetailsData?['date_of_issue'];
DateTime? end_Date = travelDetailsData?['date_of_expiry'];
if (start_Date != null && end_Date != null && start_Date.toString().isNotEmpty && end_Date.toString().isNotEmpty) {
try {
final format = DateFormat("dd-MM-yyyy"); final format = DateFormat("dd-MM-yyyy");
final checkStartDate = format.parse("$start_Date");
final checkEndDate = format.parse("$end_Date");
if (checkEndDate.isBefore(checkStartDate)) { DateTime? start_Date;
// return "End date cannot be earlier than start date";; DateTime? end_Date;
return ;
try {
if (travelDetailsData?['date_of_issue'] != null &&
travelDetailsData!['date_of_issue'].toString().isNotEmpty) {
start_Date = format.parse(travelDetailsData!['date_of_issue']);
} }
} catch (e) { // return "End date cannot be earlier than start date"; if (travelDetailsData?['date_of_expiry'] != null &&
return ; travelDetailsData!['date_of_expiry'].toString().isNotEmpty) {
// errorMessages["end_date"] = "Invalid date format"; end_Date = format.parse(travelDetailsData!['date_of_expiry']);
} }
if (start_Date != null &&
end_Date != null &&
end_Date.isBefore(start_Date)) {
print("End date cannot be earlier than start date");
return;
} }
} catch (e) {
print("Invalid passport date format");
return;
}
// Additional validation starts - travelDetailsData passport
// DateTime? start_Date = travelDetailsData?['date_of_issue'];
// DateTime? end_Date = travelDetailsData?['date_of_expiry'];
//
// if (start_Date != null &&
// end_Date != null &&
// start_Date.toString().isNotEmpty &&
// end_Date.toString().isNotEmpty) {
// try {
// final format = DateFormat("dd-MM-yyyy");
// final checkStartDate = format.parse("$start_Date");
// final checkEndDate = format.parse("$end_Date");
//
// if (checkEndDate.isBefore(checkStartDate)) {
// // return "End date cannot be earlier than start date";;
// return;
// }
// } catch (e) {
// // return "End date cannot be earlier than start date";
// return;
// // errorMessages["end_date"] = "Invalid date format";
// }
// }
// valid_from: 20-06-2025, valid_upto: 19-06-2025 // valid_from: 20-06-2025, valid_upto: 19-06-2025
DateTime? valid_from = data?['valid_from']; DateTime? valid_from = data?['valid_from'];
DateTime? valid_upto = data?['valid_upto']; DateTime? valid_upto = data?['valid_upto'];
if (valid_from != null && valid_upto != null && valid_from.toString().isNotEmpty && valid_upto.toString().isNotEmpty) { if (valid_from != null &&
valid_upto != null &&
valid_from.toString().isNotEmpty &&
valid_upto.toString().isNotEmpty) {
try { try {
final format = DateFormat("dd-MM-yyyy"); final format = DateFormat("dd-MM-yyyy");
final checkValidFrom = format.parse("$valid_from"); final checkValidFrom = format.parse("$valid_from");
@ -733,10 +767,11 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
if (checkValidUpto.isBefore(checkValidFrom)) { if (checkValidUpto.isBefore(checkValidFrom)) {
// return "valid upto cannot be earlier than valid from"; // return "valid upto cannot be earlier than valid from";
return ; return;
} }
} catch (e) { // return "valid upto cannot be earlier than valid from"; } catch (e) {
return ; // return "valid upto cannot be earlier than valid from";
return;
// errorMessages["end_date"] = "Invalid date format"; // errorMessages["end_date"] = "Invalid date format";
} }
} }

View File

@ -155,6 +155,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
} }
bool boolValidation() { bool boolValidation() {
print("travel validation start");
print("visaEntries - $visaEntries");
final passportText = controllers["passportNumber"]?.text ?? ""; final passportText = controllers["passportNumber"]?.text ?? "";
if (_selectedTripType == "Indian") { if (_selectedTripType == "Indian") {
@ -173,6 +176,80 @@ class TravellerDetailsState extends State<TravellerDetails> {
} }
} }
final format = DateFormat("dd-MM-yyyy");
DateTime? start_Date;
DateTime? end_Date;
try {
if (controllers["dateOfIssue"]?.text != null &&
controllers["dateOfIssue"]!.text.isNotEmpty) {
start_Date = format.parse(controllers["dateOfIssue"]!.text);
}
if (controllers["dateOfExpiry"]?.text != null &&
controllers["dateOfExpiry"]!.text.isNotEmpty) {
end_Date = format.parse(controllers["dateOfExpiry"]!.text);
}
if (start_Date != null &&
end_Date != null &&
end_Date.isBefore(start_Date)) {
setState(() {
errorMessages["date_of_expiry"] = "End date cannot be earlier";
});
print("End date cannot be earlier than start date");
}
} catch (e) {
print("Invalid passport date format");
}
// Additional validation starts - travelDetailsData passport
// DateTime? start_Date = travelDetailsData?['date_of_issue'];
// DateTime? end_Date = travelDetailsData?['date_of_expiry'];
//
// if (start_Date != null &&
// end_Date != null &&
// start_Date.toString().isNotEmpty &&
// end_Date.toString().isNotEmpty) {
// try {
// final format = DateFormat("dd-MM-yyyy");
// final checkStartDate = format.parse("$start_Date");
// final checkEndDate = format.parse("$end_Date");
//
// if (checkEndDate.isBefore(checkStartDate)) {
// // return "End date cannot be earlier than start date";;
// return;
// }
// } catch (e) {
// // return "End date cannot be earlier than start date";
// return;
// // errorMessages["end_date"] = "Invalid date format";
// }
// }
// valid_from: 20-06-2025, valid_upto: 19-06-2025
// DateTime? valid_from = data?['valid_from'];
// DateTime? valid_upto = data?['valid_upto'];
//
// if (valid_from != null &&
// valid_upto != null &&
// valid_from.toString().isNotEmpty &&
// valid_upto.toString().isNotEmpty) {
// try {
// final format = DateFormat("dd-MM-yyyy");
// final checkValidFrom = format.parse("$valid_from");
// final checkValidUpto = format.parse("$valid_upto");
//
// if (checkValidUpto.isBefore(checkValidFrom)) {
// // return "valid upto cannot be earlier than valid from";
// }
// } catch (e) {
// // return "valid upto cannot be earlier than valid from";
//
// // errorMessages["end_date"] = "Invalid date format";
// }
// }
print("travel validation end");
return true; return true;
} }
@ -1355,30 +1432,34 @@ class TravellerDetailsState extends State<TravellerDetails> {
DateTime? _selectedDateOfExpiry; DateTime? _selectedDateOfExpiry;
Widget buildDateOfIssue() { Widget buildDateOfIssue() {
Future<void> _selectCheckDateOfIssue(BuildContext context) async { Future<void> _selectCheckDateOfIssue(BuildContext context) async {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
DateTime today = DateTime(now.year, now.month, now.day); DateTime today = DateTime(now.year, now.month, now.day);
DateTime? pickedDate = await showDatePicker( DateTime? pickedDate = await showDatePicker(
context: context, context: context,
initialDate: _selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today) initialDate:
_selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
? _selectedDateOfIssue! ? _selectedDateOfIssue!
: today, : today,
firstDate: DateTime(1900), firstDate: DateTime(1900),
lastDate: DateTime(2100), // lastDate: DateTime(2100),
lastDate: today,
initialEntryMode: DatePickerEntryMode.calendarOnly, initialEntryMode: DatePickerEntryMode.calendarOnly,
); );
if (pickedDate != null && pickedDate != _selectedDateOfIssue) { if (pickedDate != null && pickedDate != _selectedDateOfIssue) {
setState(() { setState(() {
_selectedDateOfIssue = pickedDate; _selectedDateOfIssue = pickedDate;
controllers["dateOfIssue"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate); controllers["dateOfIssue"]?.text = DateFormat(
'dd-MM-yyyy',
).format(pickedDate);
// Revalidate expiry // Revalidate expiry
if (_selectedDateOfExpiry != null && if (_selectedDateOfExpiry != null &&
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) { _selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date"; errorMessages["date_of_expiry"] =
"Expiry date cannot be earlier than Issue date";
} else { } else {
errorMessages.remove("date_of_expiry"); errorMessages.remove("date_of_expiry");
} }
@ -1449,9 +1530,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
} }
Widget buildDateOfExpiry() { Widget buildDateOfExpiry() {
Future<void> _selectCheckDateOfExpiry(BuildContext context) async { Future<void> _selectCheckDateOfExpiry(BuildContext context) async {
DateTime now = DateTime.now(); DateTime now = DateTime.now();
DateTime today = DateTime(now.year, now.month, now.day); DateTime today = DateTime(now.year, now.month, now.day);
// DateTime firstDate = today; // DateTime firstDate = today;
@ -1500,11 +1579,14 @@ class TravellerDetailsState extends State<TravellerDetails> {
if (pickedDate != null) { if (pickedDate != null) {
setState(() { setState(() {
_selectedDateOfExpiry = pickedDate; _selectedDateOfExpiry = pickedDate;
controllers["dateOfExpiry"]?.text = DateFormat("dd-MM-yyyy").format(pickedDate); controllers["dateOfExpiry"]?.text = DateFormat(
"dd-MM-yyyy",
).format(pickedDate);
if (_selectedDateOfIssue != null && if (_selectedDateOfIssue != null &&
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) { _selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date"; errorMessages["date_of_expiry"] =
"Expiry date cannot be earlier than Issue date";
} else { } else {
errorMessages.remove("date_of_expiry"); errorMessages.remove("date_of_expiry");
} }
@ -1588,7 +1670,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
errorMessages["date_of_expiry"]!, errorMessages["date_of_expiry"]!,
style: const TextStyle(color: Colors.red, fontSize: 10), style: const TextStyle(color: Colors.red, fontSize: 10),
maxLines: 2, // Allow it to wrap onto two lines maxLines: 2, // Allow it to wrap onto two lines
overflow: TextOverflow.ellipsis, // Add ellipsis if it still overflows overflow:
TextOverflow.ellipsis, // Add ellipsis if it still overflows
), ),
], ],
], ],
@ -4057,7 +4140,6 @@ class TravellerDetailsState extends State<TravellerDetails> {
DateTime? _selectedCheckInDate; DateTime? _selectedCheckInDate;
Widget buildVisaValidFrom(Map<String, dynamic> entry) { Widget buildVisaValidFrom(Map<String, dynamic> entry) {
TimeOfDay? _selectedCheckOutTime; TimeOfDay? _selectedCheckOutTime;
Future<void> _selectValidFromDate(BuildContext context) async { Future<void> _selectValidFromDate(BuildContext context) async {
@ -4078,19 +4160,23 @@ class TravellerDetailsState extends State<TravellerDetails> {
// initialDate: initialDate, // initialDate: initialDate,
// firstDate: initialDate, // firstDate: initialDate,
firstDate: DateTime(1900), firstDate: DateTime(1900),
lastDate: DateTime(2100), // lastDate: DateTime(2100),
lastDate: today,
initialEntryMode: DatePickerEntryMode.calendarOnly, initialEntryMode: DatePickerEntryMode.calendarOnly,
); );
if (pickedDate != null && pickedDate != _selectedCheckOutDate) { if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
setState(() { setState(() {
_selectedCheckInDate = pickedDate; _selectedCheckInDate = pickedDate;
entry["controller_valid_from"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate); entry["controller_valid_from"]?.text = DateFormat(
'dd-MM-yyyy',
).format(pickedDate);
// Revalidate expiry // Revalidate expiry
if (_selectedCheckOutDate != null && if (_selectedCheckOutDate != null &&
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) { _selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
errorMessages["valid_upto"] = "valid upto cannot be earlier than valid from"; errorMessages["valid_upto"] =
"valid upto cannot be earlier than valid from";
} else { } else {
errorMessages.remove("valid_upto"); errorMessages.remove("valid_upto");
} }
@ -4151,7 +4237,6 @@ class TravellerDetailsState extends State<TravellerDetails> {
} }
Widget buildVisaValidUpTo(Map<String, dynamic> entry) { Widget buildVisaValidUpTo(Map<String, dynamic> entry) {
TimeOfDay? _selectedCheckOutTime; TimeOfDay? _selectedCheckOutTime;
Future<void> _selectValidUpToDate(BuildContext context) async { Future<void> _selectValidUpToDate(BuildContext context) async {
@ -4202,11 +4287,14 @@ class TravellerDetailsState extends State<TravellerDetails> {
if (pickedDate != null && pickedDate != _selectedCheckOutDate) { if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
setState(() { setState(() {
_selectedCheckOutDate = pickedDate; _selectedCheckOutDate = pickedDate;
entry["controller_valid_upto"].text = DateFormat("dd-MM-yyyy").format(pickedDate); entry["controller_valid_upto"].text = DateFormat(
"dd-MM-yyyy",
).format(pickedDate);
if (_selectedCheckInDate != null && if (_selectedCheckInDate != null &&
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) { _selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
errorMessages["valid_upto"] = "valid upto cannot be earlier than valid from"; errorMessages["valid_upto"] =
"valid upto cannot be earlier than valid from";
} else { } else {
errorMessages.remove("valid_upto"); errorMessages.remove("valid_upto");
} }
@ -4269,7 +4357,8 @@ class TravellerDetailsState extends State<TravellerDetails> {
errorMessages["valid_upto"]!, errorMessages["valid_upto"]!,
style: const TextStyle(color: Colors.red, fontSize: 10), style: const TextStyle(color: Colors.red, fontSize: 10),
maxLines: 2, // Allow it to wrap onto two lines maxLines: 2, // Allow it to wrap onto two lines
overflow: TextOverflow.ellipsis, // Add ellipsis if it still overflows overflow:
TextOverflow.ellipsis, // Add ellipsis if it still overflows
), ),
], ],
], ],

View File

@ -5,6 +5,7 @@ class Plan {
final String tripTitle; final String tripTitle;
final String tripType; final String tripType;
final String status; final String status;
final String approver_status;
final String costCenter; final String costCenter;
final String functionalDepartment; final String functionalDepartment;
final String purposeOfTravel; final String purposeOfTravel;
@ -23,6 +24,7 @@ class Plan {
required this.planId, required this.planId,
this.employeeCode, this.employeeCode,
required this.tripTitle, required this.tripTitle,
required this.approver_status,
required this.tripType, required this.tripType,
required this.status, required this.status,
required this.costCenter, required this.costCenter,
@ -46,6 +48,7 @@ class Plan {
employeeCode: json['employee_code'], employeeCode: json['employee_code'],
tripTitle: json['trip_title'], tripTitle: json['trip_title'],
tripType: json['trip_type_value'], tripType: json['trip_type_value'],
approver_status: json['approver_status'],
status: json['status'] == "0" ? "Inactive" : "Active", status: json['status'] == "0" ? "Inactive" : "Active",
costCenter: json['cost_center_value'] ?? '', costCenter: json['cost_center_value'] ?? '',
functionalDepartment: json['functional_department_value'] ?? '', functionalDepartment: json['functional_department_value'] ?? '',

View File

@ -4,6 +4,6 @@ import 'app.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart';
void main() { void main() {
setUrlStrategy(PathUrlStrategy()); // setUrlStrategy(PathUrlStrategy());
runApp(const MyApp()); runApp(const MyApp());
} }

View File

@ -117,6 +117,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
"name": "${userDetails["first_name"]} ${userDetails["last_name"]}", "name": "${userDetails["first_name"]} ${userDetails["last_name"]}",
"email": userDetails["email"] ?? "", "email": userDetails["email"] ?? "",
"role": userDetails["role"] ?? "", "role": userDetails["role"] ?? "",
"last_login_at": userDetails["last_login_at"] ?? "",
}; };
} catch (e) { } catch (e) {
print("Error decoding user data: $e"); print("Error decoding user data: $e");
@ -282,6 +283,18 @@ class _CustomAppBarState extends State<CustomAppBar> {
}); });
} }
Future<void> logout(BuildContext context) async {
// Clear localStorage
final prefs = await SharedPreferences.getInstance();
await prefs.clear(); // Clears all keys
// Optional: clear sessionStorage if used
// html.window.sessionStorage.clear();
// Navigate to login or home page
context.go('/');
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
@ -431,7 +444,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
actions: [ actions: [
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05, horizontal: MediaQuery.of(context).size.width * 0.055,
), ),
child: Row( child: Row(
children: [ children: [
@ -478,7 +491,8 @@ class _CustomAppBarState extends State<CustomAppBar> {
}, },
); );
case '/logout': case '/logout':
context.go('/'); logout(context);
// context.go('/');
break; break;
} }
}, },
@ -523,6 +537,15 @@ class _CustomAppBarState extends State<CustomAppBar> {
color: Colors.black, color: Colors.black,
), ),
), ),
Text(
"Last Login: ${userData?["last_login_at"]}" ??
'',
style: GoogleFonts.poppins(
fontSize: 8.5,
fontWeight: FontWeight.w400,
color: Colors.black,
),
),
const Divider(), // 👈 Divider after role const Divider(), // 👈 Divider after role
], ],
), ),

View File

@ -102,6 +102,7 @@ class ApiService {
throw Exception('Failed to load country list'); throw Exception('Failed to load country list');
} }
} }
Future<List<dynamic>> fetchAirlineList() async { Future<List<dynamic>> fetchAirlineList() async {
final String apiUrldata = '$apiUrl/api/getAirlineMaster'; final String apiUrldata = '$apiUrl/api/getAirlineMaster';
final token = await getToken(); final token = await getToken();
@ -617,6 +618,7 @@ class ApiService {
BuildContext context, BuildContext context,
String planId, String planId,
String? approverId, String? approverId,
String? approver_status,
String? delegaterId, { String? delegaterId, {
bool isViewMode = false, bool isViewMode = false,
bool isApprover = true, bool isApprover = true,
@ -629,6 +631,7 @@ class ApiService {
'/approver/plans', '/approver/plans',
extra: { extra: {
'planData': planData, 'planData': planData,
'approver_status': approver_status,
'approverId': approverId, 'approverId': approverId,
'delegaterId': delegaterId, 'delegaterId': delegaterId,
'isViewMode': isViewMode, 'isViewMode': isViewMode,

View File

@ -14,7 +14,7 @@
This is a placeholder for base href that will be replaced by the value of This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`. the `--base-href` argument provided to `flutter build`.
--> -->
<base href="$FLUTTER_BASE_HREF"> <base href="/tstat/">
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta content="IE=Edge" http-equiv="X-UA-Compatible">