issues fixes

This commit is contained in:
venba-Inspriron-3558 2025-06-11 17:45:03 +05:30
parent 2e85273b06
commit 65528b1df3
12 changed files with 107 additions and 40 deletions

View File

@ -768,6 +768,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
child: TextField(
focusNode: _checkInFocusNode,
controller: _checkInController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -822,6 +823,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
child: TextField(
focusNode: _checkInTimeFocusNode,
controller: _checkInTimeController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Time",
@ -873,6 +875,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
child: TextField(
focusNode: _checkOutFocusNode,
controller: _checkOutController,
readOnly: true,
style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration(
labelText: "Select Date",
@ -924,6 +927,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
child: TextField(
focusNode: _checkOutTimeFocusNode,
controller: _checkOutTimeController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Time",

View File

@ -541,6 +541,7 @@ class _BusScreenState extends State<BusScreen> {
child: TextField(
focusNode: _dateFocusNode,
controller: _dateController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -593,6 +594,7 @@ class _BusScreenState extends State<BusScreen> {
child: TextField(
focusNode: _timeFocusNode,
controller: _timeController,
readOnly: true,
style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration(
labelText: "Select Time",

View File

@ -1947,6 +1947,7 @@ class FlightScreenState extends State<FlightScreen> {
focusNode: focusNodes["_date${index}FocusNode"],
// controller: _dateController,
controller: textControllers["_date${index}Controller"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -2012,7 +2013,7 @@ class FlightScreenState extends State<FlightScreen> {
focusNode: focusNodes["_time${index}FocusNode"],
// controller: _timeController,
controller: textControllers["_time${index}Controller"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Time",

View File

@ -82,19 +82,49 @@ class _ForexScreenState extends State<ForexScreen> {
String _formatDate(String? date) {
if (date == null || date.isEmpty) return "";
try {
DateTime parsedDate = DateTime.parse(
date,
); // Assuming input is YYYY-MM-DD
return DateFormat(
"dd-MM-yyyy",
).format(parsedDate); // Convert to DD-MM-YYYY
// First try parsing as ISO format (YYYY-MM-DD)
DateTime parsedDate;
try {
parsedDate = DateTime.parse(date);
} catch (e) {
// If ISO parse fails, try parsing as DD-MM-YYYY
final parts = date.split('-');
if (parts.length == 3) {
parsedDate = DateTime(
int.parse(parts[2]), // year
int.parse(parts[1]), // month
int.parse(parts[0]), // day
);
} else {
throw FormatException("Unsupported date format");
}
}
return DateFormat("dd-MM-yyyy").format(parsedDate);
} catch (e) {
print("Error formatting date: $e");
return date; // Return as is if parsing fails
print("Error formatting date '$date': $e");
return ""; // Return empty string or handle differently
}
}
// String _formatDate(String? date) {
// if (date == null || date.isEmpty) return "";
// try {
// DateTime parsedDate = DateTime.parse(
// date,
// ); // Assuming input is YYYY-MM-DD
// return DateFormat(
// "dd-MM-yyyy",
// ).format(parsedDate); // Convert to DD-MM-YYYY
// } catch (e) {
// print("Error formatting date: $e");
// return date; // Return as is if parsing fails
// }
// }
Map<String, String> errorMessages = {};
String? selectedCountry;
@ -320,6 +350,16 @@ class _ForexScreenState extends State<ForexScreen> {
final cash = data["deposit_on_cash"];
print("card - $card");
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)) {
// && errorMessages.isNotEmpty) {
@ -376,8 +416,6 @@ class _ForexScreenState extends State<ForexScreen> {
textControllers["_forexStartDate"]?.addListener(_onFieldChanged);
textControllers["_forexEndDate"]?.addListener(_onFieldChanged);
handleUpdatedField();
flightFirstTripDateNotifier = ValueNotifier<String?>(null);
flightLastTripDateNotifier = ValueNotifier<String?>(null);
@ -386,6 +424,8 @@ class _ForexScreenState extends State<ForexScreen> {
print("tripuserId - $tripuserId");
final result = getFlightTripDateRange(widget.flightData);
print("result - $result");
flightFirstTripDateNotifier.value = result['firstTripDate'];
flightLastTripDateNotifier.value = result['lastTripDate'];
@ -409,6 +449,9 @@ class _ForexScreenState extends State<ForexScreen> {
'dd-MM-yyyy',
).format(parsedEndDate);
}
handleUpdatedField();
});
}
@ -429,16 +472,16 @@ class _ForexScreenState extends State<ForexScreen> {
print("UPDATAED SELECTION");
textControllers["_forexStartDate"] = initController("start_date");
textControllers["_forexStartDate"]?.addListener(_onFieldChanged); // Reattach
textControllers["_forexEndDate"] = initController("end_date");
textControllers["_forexEndDate"]?.addListener(_onFieldChanged); // Reattach
textControllers["_transport"] = initController("transport");
textControllers["_accomodation"] = initController("accommodation");
textControllers["_telephone"] = initController("telephone");
textControllers["_cardNumber"] = initController("card_number");
textControllers["_card"] = initController("deposit_on_card");
textControllers["_cash"] = initController("deposit_on_cash");
textControllers["_deliveryLocation"] = initController(
"delivery_location",
);
textControllers["_deliveryLocation"] = initController("delivery_location");
textControllers["_comments"] = initController("comments");
// Set dropdown values
@ -466,7 +509,6 @@ class _ForexScreenState extends State<ForexScreen> {
// textControllers["_cardNumber"]!.text = userCardNumber ?? '';
//
// }
_onFieldChangedForOthers();
setState(() {}); // Update the UI
@ -502,6 +544,7 @@ class _ForexScreenState extends State<ForexScreen> {
// Handle field changes
void _onFieldChanged() {
print("_on Field Changed Called");
if (_isForexDataDurationComplete()) {
print("Calculate 1");
CalculateDuration();
@ -532,14 +575,13 @@ class _ForexScreenState extends State<ForexScreen> {
// final startDate = DateFormat('dd/mm/yyyy').parse(startDateString);
// final endDate = DateFormat('dd/mm/yyyy').parse(endDateString);
final startDate = DateFormat('dd-MM-yyyy').parse(startDateString);
final endDate = DateFormat('dd-MM-yyyy').parse(endDateString);
final startDate = DateFormat('dd-MM-yyyy').parse(startDateString.trim()) ;
final endDate = DateFormat('dd-MM-yyyy').parse(endDateString.trim()) ;
print("Calculate 4");
// Calculate difference
final durationInDays =
endDate.difference(startDate).inDays + 1; // +1 to include both days
final durationInDays = endDate.difference(startDate).inDays ; // +1 to include both days
// You can now use durationInDays however you want:
print("Duration: $durationInDays days");
@ -721,6 +763,9 @@ class _ForexScreenState extends State<ForexScreen> {
for (var controller in textControllers.values) {
controller.dispose();
}
// textControllers["_forexStartDate"]?.removeListener(_onFieldChanged);
// textControllers["_forexEndDate"]?.removeListener(_onFieldChanged);
// textControllers.forEach((_, controller) => controller.dispose());
super.dispose();
}
@ -994,6 +1039,7 @@ class _ForexScreenState extends State<ForexScreen> {
child: TextField(
focusNode: focusNodes["_forexStartDate"],
controller: textControllers["_forexStartDate"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
labelText: "Select Date",
@ -1074,6 +1120,7 @@ class _ForexScreenState extends State<ForexScreen> {
child: TextField(
focusNode: focusNodes["_forexEndDate"],
controller: textControllers["_forexEndDate"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",

View File

@ -887,6 +887,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
child: TextField(
focusNode: _startDateFocusNode,
controller: _startDateController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select ",
@ -956,6 +957,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
child: TextField(
focusNode: _endDateFocusNode,
controller: _endDateController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select ",

View File

@ -832,6 +832,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
child: TextField(
focusNode: _dateFocusNode,
controller: _dateController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -883,6 +884,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
child: TextField(
focusNode: _timeFocusNode,
controller: _timeController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Time",

View File

@ -1034,6 +1034,7 @@ class _TrainScreenState extends State<TrainScreen> {
child: TextField(
focusNode: _dateFocusNode,
controller: _dateController,
readOnly: true, // Prevents typing
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -1086,6 +1087,7 @@ class _TrainScreenState extends State<TrainScreen> {
child: TextField(
focusNode: _timeFocusNode,
controller: _timeController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Time",

View File

@ -734,6 +734,7 @@ class _VisaScreenState extends State<VisaScreen> {
child: TextField(
focusNode: _dateFocusNode,
controller: _dateController,
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",

View File

@ -142,27 +142,26 @@ class TravellerListState extends State<TravellerList> {
// });
// print("filteredPlans: $filteredTraveller");
print("all before filtering: $query");
final lowerQuery = query.toLowerCase();
final lowerQuery = query.toLowerCase().trim();
setState(() {
filteredTraveller =
allTraveller.where((object) {
final isActiveStatus =
object['is_active'] == "1" ? "active" : "inactive";
return (object['traveller_id']?.toLowerCase().contains(
lowerQuery,
) ??
false) ||
(object['first_name']?.toLowerCase().contains(lowerQuery) ??
false) ||
(object['last_name']?.toLowerCase().contains(lowerQuery) ??
false) ||
(object['mobile']?.toLowerCase().contains(lowerQuery) ??
false) ||
(object['email']?.toLowerCase().contains(lowerQuery) ??
false) ||
(isActiveStatus.contains(lowerQuery));
}).toList();
filteredTraveller = allTraveller.where((object) {
final travellerId = object['traveller_id']?.toLowerCase() ?? '';
final firstName = object['first_name']?.toLowerCase() ?? '';
final lastName = object['last_name']?.toLowerCase() ?? '';
final fullName = '$firstName $lastName';
final mobile = object['mobile']?.toLowerCase() ?? '';
final email = object['email']?.toLowerCase() ?? '';
final isActiveStatus = object['is_active'] == "1" ? "active" : "inactive";
return travellerId.contains(lowerQuery) ||
firstName.contains(lowerQuery) ||
lastName.contains(lowerQuery) ||
fullName.contains(lowerQuery) ||
mobile.contains(lowerQuery) ||
email.contains(lowerQuery) ||
isActiveStatus.contains(lowerQuery);
}).toList();
currentPage = 0;
});
print("filteredTraveller: $filteredTraveller");

View File

@ -1392,6 +1392,7 @@ class _OfficeDetailsState extends State<OfficeDetails> {
child: AbsorbPointer(
child: TextField(
controller: widget.controllers["delegationStartDate"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
labelText: "Select Date",
@ -1496,6 +1497,7 @@ class _OfficeDetailsState extends State<OfficeDetails> {
child: AbsorbPointer(
child: TextField(
controller: widget.controllers["delegationEndDate"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: InputDecoration(
labelText: "Select Date",

View File

@ -1098,6 +1098,7 @@ class PersonalDetailsState extends State<PersonalDetails> {
child: AbsorbPointer(
child: TextField(
controller: widget.controllers["dob"],
readOnly: true,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
labelText: "Select Date",

View File

@ -1422,6 +1422,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
child: AbsorbPointer(
child: TextField(
controller: controllers["dateOfIssue"],
readOnly: true,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
labelText: "Select Date",
@ -1559,6 +1560,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
child: AbsorbPointer(
child: TextField(
controller: controllers["dateOfExpiry"],
readOnly: true,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
labelText: "Select Date",
@ -2884,6 +2886,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
child: AbsorbPointer(
child: TextField(
controller: controllers["forex_expiry_date"],
readOnly: true,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
labelText: "Select Date",
@ -4124,7 +4127,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
child: TextField(
// focusNode: _dateFocusNode,
controller: entry["controller_valid_from"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
@ -4241,6 +4244,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
// focusNode: _dateFocusNode,
// controller: _dateController,
controller: entry["controller_valid_upto"],
readOnly: true,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",