8/27/1
This commit is contained in:
@@ -250,6 +250,39 @@ class AI extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
String extractDOB(String nationalNumber) {
|
||||
if (nationalNumber.length != 14) {
|
||||
throw ArgumentError('National number must be 14 digits long.');
|
||||
}
|
||||
|
||||
// Extract the first digit to determine the century
|
||||
String firstDigit = nationalNumber[0];
|
||||
|
||||
// Extract year, month, and day parts
|
||||
String yearPart = nationalNumber.substring(1, 3);
|
||||
String monthPart = nationalNumber.substring(3, 5);
|
||||
String dayPart = nationalNumber.substring(5, 7);
|
||||
|
||||
// Determine the year based on the first digit
|
||||
int yearPrefix;
|
||||
if (firstDigit == '2') {
|
||||
yearPrefix = 1900;
|
||||
} else if (firstDigit == '3') {
|
||||
yearPrefix = 2000;
|
||||
} else {
|
||||
throw ArgumentError('Invalid first digit in national number.');
|
||||
}
|
||||
|
||||
// Construct the full year
|
||||
int year = yearPrefix + int.parse(yearPart);
|
||||
|
||||
// Format the date as YYYY-MM-DD
|
||||
String dob =
|
||||
'$year-${monthPart.padLeft(2, '0')}-${dayPart.padLeft(2, '0')}';
|
||||
|
||||
return dob;
|
||||
}
|
||||
|
||||
Future<void> addDriverEgypt() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
@@ -295,7 +328,8 @@ class AI extends GetxController {
|
||||
'religion':
|
||||
responseIdEgyptBack['religion']?.toString() ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate': responseIdEgyptFront['dob']?.toString() ?? 'Not specified',
|
||||
'birthdate': extractDOB(
|
||||
responseIdEgyptDriverLicense['national_number'].toString()),
|
||||
'maritalStatus':
|
||||
responseIdEgyptBack['maritalStatus']?.toString() ?? 'Not specified',
|
||||
'site': responseIdEgyptDriverLicense['address']?.toString() ??
|
||||
@@ -321,6 +355,12 @@ class AI extends GetxController {
|
||||
|
||||
if (status1['status'] == 'success') {
|
||||
isDriverSaved = true;
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferGizaServer}/auth/captin/register.php',
|
||||
// payload: payload);
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferAlexandriaServer}/auth/captin/register.php',
|
||||
// payload: payload);
|
||||
Get.snackbar('Success', 'Driver data saved successfully',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
} else {
|
||||
@@ -376,6 +416,55 @@ class AI extends GetxController {
|
||||
isCarSaved = true;
|
||||
Get.snackbar('Success', 'message',
|
||||
backgroundColor: AppColor.greenColor);
|
||||
// CRUD().post(
|
||||
// link:
|
||||
// '${AppLink.seferAlexandriaServer}/ride/RegisrationCar/add.php',
|
||||
// payload: {
|
||||
// 'driverID': box.read(BoxName.driverID),
|
||||
// 'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
// 'car_plate':
|
||||
// responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
// 'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
// 'model': responseIdCardDriverEgyptBack['model'],
|
||||
// 'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
// 'expiration_date':
|
||||
// responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
// .toString(),
|
||||
// 'color': responseIdCardDriverEgyptBack['color'],
|
||||
// 'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
// 'color_hex':
|
||||
// responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
// 'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
// 'displacement':
|
||||
// responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
// 'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
// 'registration_date':
|
||||
// '${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
// });
|
||||
// CRUD().post(
|
||||
// link: '${AppLink.seferGizaServer}/ride/RegisrationCar/add.php',
|
||||
// payload: {
|
||||
// 'driverID': box.read(BoxName.driverID),
|
||||
// 'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
|
||||
// 'car_plate':
|
||||
// responseIdCardDriverEgyptFront['car_plate'].toString(),
|
||||
// 'make': responseIdCardDriverEgyptBack['make'].toString(),
|
||||
// 'model': responseIdCardDriverEgyptBack['model'],
|
||||
// 'year': responseIdCardDriverEgyptBack['year'].toString(),
|
||||
// 'expiration_date':
|
||||
// responseIdCardDriverEgyptFront['LicenseExpirationDate']
|
||||
// .toString(),
|
||||
// 'color': responseIdCardDriverEgyptBack['color'],
|
||||
// 'owner': responseIdCardDriverEgyptFront['owner'],
|
||||
// 'color_hex':
|
||||
// responseIdCardDriverEgyptBack['color_hex'].toString(),
|
||||
// 'address': responseIdCardDriverEgyptFront['address'].toString(),
|
||||
// 'displacement':
|
||||
// responseIdCardDriverEgyptBack['engine'].toString(),
|
||||
// 'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
|
||||
// 'registration_date':
|
||||
// '${responseIdCardDriverEgyptBack['inspection_date']}',
|
||||
// });
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user