12/22/1
This commit is contained in:
@@ -42,6 +42,8 @@ enum DocumentType {
|
||||
carLicenseFront,
|
||||
carLicenseBack,
|
||||
idCardFront,
|
||||
nonIdCardFront,
|
||||
nonIdCardBack,
|
||||
idCardBack,
|
||||
driverLicense,
|
||||
unknown,
|
||||
@@ -150,6 +152,14 @@ class AI extends GetxController {
|
||||
// Check if the inspection date is before today
|
||||
final inspectionDateTime = DateTime(year, 12, 31);
|
||||
final isInspectionExpired = inspectionDateTime.isBefore(today);
|
||||
// Add birthdate comparison for non-Egyptian ID
|
||||
final frontBirthDate =
|
||||
DateTime.tryParse(responseNonIdCardFront['birthdate'] ?? '');
|
||||
final backBirthDate =
|
||||
DateTime.tryParse(responseNonIdCardBack['birthDate'] ?? '');
|
||||
final birthdatesMismatch = frontBirthDate != null &&
|
||||
backBirthDate != null &&
|
||||
frontBirthDate != backBirthDate;
|
||||
|
||||
if (isExpiredCar || isInspectionExpired) {
|
||||
Get.defaultDialog(
|
||||
@@ -186,6 +196,41 @@ class AI extends GetxController {
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (birthdatesMismatch && !isEgypt) {
|
||||
Get.defaultDialog(
|
||||
title: 'Birthdate Mismatch'.tr,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.warning, size: 48, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"The birthdate on your ID front doesn't match the one on the back. Please verify your documents."
|
||||
.tr,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
await Get.find<TextToSpeechController>().speakText(
|
||||
"The birthdate on your ID front doesn't match the one on the back. Please verify your documents."
|
||||
.tr,
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.volume_up),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (isExpired) {
|
||||
Get.defaultDialog(
|
||||
title: 'Expired Driver’s License'.tr,
|
||||
@@ -298,7 +343,7 @@ class AI extends GetxController {
|
||||
// );
|
||||
// }
|
||||
else {
|
||||
await addDriverEgypt();
|
||||
isEgypt ? await addDriverEgypt() : await addDriverForeign();
|
||||
await addRegistrationCarEgypt();
|
||||
|
||||
if (isCarSaved && isDriverSaved) {
|
||||
@@ -343,6 +388,99 @@ class AI extends GetxController {
|
||||
return dob;
|
||||
}
|
||||
|
||||
Future<void> addDriverForeign() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var payload = {
|
||||
'first_name':
|
||||
responseNonIdCardFront['full_name']?.toString().split(' ')[0] ??
|
||||
'Not specified',
|
||||
'last_name':
|
||||
responseNonIdCardFront['full_name']?.toString().split(' ').last ??
|
||||
'Not specified',
|
||||
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
|
||||
'phone': box.read(BoxName.phoneDriver)?.toString() ?? 'Not specified',
|
||||
'id': box.read(BoxName.driverID)?.toString() ?? 'Not specified',
|
||||
'password':
|
||||
Get.put(LoginDriverController()).passwordController.text.isEmpty
|
||||
? box.read(BoxName.emailDriver).toString()
|
||||
: Get.find<LoginDriverController>()
|
||||
.passwordController
|
||||
.text
|
||||
.toString(),
|
||||
'gender': responseNonIdCardFront['gender']?.toString() ?? 'Not specified',
|
||||
'license_type': 'Foreign',
|
||||
'national_number':
|
||||
responseNonIdCardFront['passport_no']?.toString() ?? 'Not specified',
|
||||
'name_arabic':
|
||||
responseNonIdCardFront['full_name']?.toString() ?? 'Not specified',
|
||||
'name_english': 'Not specified',
|
||||
'issue_date':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
'expiry_date':
|
||||
responseNonIdCardBack['residencyExpirationDate']?.toString() ??
|
||||
'Not specified',
|
||||
'license_categories': responseIdEgyptDriverLicense['license_categories']
|
||||
is List
|
||||
? responseIdEgyptDriverLicense['license_categories'].join(', ')
|
||||
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
|
||||
'Not specified',
|
||||
'address':
|
||||
responseNonIdCardFront['address']?.toString() ?? 'Not specified',
|
||||
'card_id':
|
||||
responseNonIdCardFront['card_id']?.toString() ?? 'Not specified',
|
||||
'occupation':
|
||||
responseNonIdCardBack['workStatus']?.toString() ?? 'Not specified',
|
||||
'education': 'Not specified',
|
||||
'licenseIssueDate':
|
||||
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
|
||||
'religion':
|
||||
responseNonIdCardFront['country']?.toString() ?? 'Not specified',
|
||||
'status': 'yet',
|
||||
'birthdate':
|
||||
responseNonIdCardFront['birthdate']?.toString() ?? 'Not specified',
|
||||
'maritalStatus': 'Not specified',
|
||||
'site': responseNonIdCardFront['address']?.toString() ?? 'Not specified',
|
||||
'employmentType':
|
||||
responseNonIdCardBack['residencyType']?.toString() ?? 'Not specified',
|
||||
};
|
||||
|
||||
try {
|
||||
var res = await CRUD().post(link: AppLink.signUpCaptin, payload: payload);
|
||||
|
||||
var status1;
|
||||
try {
|
||||
status1 = jsonDecode(res);
|
||||
} catch (e) {
|
||||
throw FormatException("Invalid JSON response: $res");
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
|
||||
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);
|
||||
mySnackbarSuccess('Foreign driver data saved successfully');
|
||||
} else {
|
||||
mySnackeBarError(
|
||||
'${'Failed to save driver data'.tr}: ${status1['message']}');
|
||||
}
|
||||
} catch (e) {
|
||||
isLoading = false;
|
||||
update();
|
||||
mySnackeBarError(
|
||||
'An error occurred while saving driver data'.tr,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addDriverEgypt() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
@@ -542,16 +680,24 @@ class AI extends GetxController {
|
||||
Map<String, dynamic> responseForComplaint = {};
|
||||
Map<String, dynamic> responseIdCardDriverEgyptFront = {};
|
||||
Map<String, dynamic> responseIdEgyptFront = {};
|
||||
Map<String, dynamic> responseNonIdCardFront = {};
|
||||
Map<String, dynamic> responseNonIdCardBack = {};
|
||||
Map<String, dynamic> responseCriminalRecordEgypt = {};
|
||||
Map<String, dynamic> responseIdEgyptBack = {};
|
||||
Map<String, dynamic> responseIdEgyptDriverLicense = {};
|
||||
String? responseIdCardDriverEgypt1;
|
||||
bool isloading = false;
|
||||
bool isLoading = false;
|
||||
bool isEgypt = true;
|
||||
var image;
|
||||
CroppedFile? croppedFile;
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
changeNationality() {
|
||||
isEgypt = !isEgypt;
|
||||
update();
|
||||
}
|
||||
|
||||
Future<void> pickImage() async {
|
||||
final pickedImage = await picker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
@@ -607,6 +753,12 @@ class AI extends GetxController {
|
||||
],
|
||||
DocumentType.idCardBack: ['البطاقةساريةحتى'],
|
||||
DocumentType.driverLicense: ['قيادةخاصة', 'خاصه', 'قيادة'],
|
||||
DocumentType.nonIdCardFront: ['Foreign Residence Card', 'أجنبي', 'جواز'],
|
||||
DocumentType.nonIdCardBack: [
|
||||
'نوع الإقامة',
|
||||
'الإقامة',
|
||||
'Cardexpiresbyendofresidencepermit'
|
||||
],
|
||||
};
|
||||
|
||||
// Check each document type
|
||||
@@ -637,7 +789,10 @@ class AI extends GetxController {
|
||||
var extractedString =
|
||||
await CRUD().arabicTextExtractByVisionAndAI(imagePath: imagePath);
|
||||
var json = jsonDecode(extractedString);
|
||||
// Log.print('extractedString: ${extractedString}');
|
||||
var textValues = CRUD().extractTextFromLines(json);
|
||||
Log.print('textValues: ${textValues}');
|
||||
// Log.print('json: ${json}');
|
||||
|
||||
DocumentType detectedType = checkDocumentType(textValues);
|
||||
String expectedDocument = getExpectedDocument(imagePath);
|
||||
@@ -720,6 +875,10 @@ class AI extends GetxController {
|
||||
return 'id_card_back'.tr;
|
||||
case 'id_front':
|
||||
return 'id_card_front'.tr;
|
||||
case 'non_id_front':
|
||||
return 'non_id_card_front'.tr;
|
||||
case 'non_id_back':
|
||||
return 'non_id_card_back'.tr;
|
||||
case 'driver_license':
|
||||
return 'driver_license'.tr;
|
||||
default:
|
||||
@@ -737,6 +896,10 @@ class AI extends GetxController {
|
||||
return DocumentType.idCardBack;
|
||||
case 'id_front':
|
||||
return DocumentType.idCardFront;
|
||||
case 'non_id_front':
|
||||
return DocumentType.nonIdCardFront;
|
||||
case 'non_id_back':
|
||||
return DocumentType.nonIdCardBack;
|
||||
case 'driver_license':
|
||||
return DocumentType.driverLicense;
|
||||
default:
|
||||
@@ -754,6 +917,10 @@ class AI extends GetxController {
|
||||
return 'id_card_front'.tr;
|
||||
case DocumentType.idCardBack:
|
||||
return 'id_card_back'.tr;
|
||||
case DocumentType.nonIdCardFront:
|
||||
return 'non_id_card_front'.tr;
|
||||
case DocumentType.nonIdCardBack:
|
||||
return 'non_id_card_back'.tr;
|
||||
case DocumentType.driverLicense:
|
||||
return 'driver_license'.tr;
|
||||
default:
|
||||
@@ -938,6 +1105,11 @@ class AI extends GetxController {
|
||||
} else if (idType == 'criminalRecord') {
|
||||
responseCriminalRecordEgypt =
|
||||
jsonDecode(responseData['content'][0]['text']);
|
||||
} else if (idType == 'non_id_front') {
|
||||
responseNonIdCardFront = jsonDecode(responseData['content'][0]['text']);
|
||||
Log.print('responseNonIdCardFront: ${responseNonIdCardFront}');
|
||||
} else if (idType == 'non_id_back') {
|
||||
responseNonIdCardBack = jsonDecode(responseData['content'][0]['text']);
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -1014,6 +1186,12 @@ class AI extends GetxController {
|
||||
responseIdEgyptBack = jsonDecode(jsonString);
|
||||
} else if (idType == 'driver_license') {
|
||||
responseIdEgyptDriverLicense = jsonDecode(jsonString);
|
||||
} else if (idType == 'non_id_front') {
|
||||
responseNonIdCardFront =
|
||||
jsonDecode(responseData['content'][0]['text']);
|
||||
} else if (idType == 'non_id_back') {
|
||||
responseNonIdCardBack =
|
||||
jsonDecode(responseData['content'][0]['text']);
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user