This commit is contained in:
Hamza-Ayed
2024-10-14 11:50:33 +03:00
parent 9854f80971
commit d6200e28e0
11 changed files with 843 additions and 670 deletions

View File

@@ -257,6 +257,45 @@ class HomeCaptainController extends GetxController {
// LocationController().getLocation();
super.onInit();
}
// void getRefusedOrderByCaptain() async {
// // Get today's date in YYYY-MM-DD format
// String today = DateTime.now().toString().substring(0, 10);
// String driverId = box.read(BoxName.driverID).toString();
// String customQuery = '''
// SELECT COUNT(*) AS count
// FROM ${TableName.driverOrdersRefuse}
// WHERE driver_id = '$driverId'
// AND DATE(created_at) = '$today'
// ''';
// try {
// List<Map<String, dynamic>> results =
// await sql.getCustomQuery(customQuery);
// countRefuse = results[0]['count'].toString();
// print(countRefuse);
// update();
// if (int.parse(countRefuse) > 3) {
// box.write(BoxName.statusDriverLocation, 'on');
// locationController.stopLocationUpdates();
// Get.defaultDialog(
// // backgroundColor: CupertinoColors.destructiveRed,
// barrierDismissible: false,
// title: 'You Are Stopped For this Day !'.tr,
// content: Text(
// 'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
// .tr,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// title: 'Ok , See you Tomorrow'.tr,
// onPressed: () => Get.back()));
// } else {
// box.write(BoxName.statusDriverLocation, 'off');
// }
// } catch (e) {}
// }
addToken() async {
await CRUD().post(link: AppLink.addTokensDriver, payload: {

View File

@@ -171,13 +171,20 @@ class MapDriverController extends GetxController {
cancelTripFromDriverAfterApplied() async {
if (formKeyCancel.currentState!.validate()) {
CRUD().post(
await CRUD().post(
link: "${AppLink.seferCairoServer}/ride/rides/update.php",
payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
CRUD().post(
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD()
.post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
}
await CRUD().post(
link:
"${AppLink.seferCairoServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
payload: {
@@ -186,6 +193,17 @@ class MapDriverController extends GetxController {
"status": 'reject After Applied',
"notes": cancelTripCotroller.text.toString()
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(
link:
"${AppLink.endPoint}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
payload: {
"order_id": rideId.toString(),
"driver_id": box.read(BoxName.driverID).toString(),
"status": 'reject After Applied',
"notes": cancelTripCotroller.text.toString()
});
}
FirebaseMessagesController().sendNotificationToDriverMAP(
"Cancel Trip from driver".tr,
"Trip Cancelled from driver. We are looking for a new driver. Please wait."
@@ -194,44 +212,13 @@ class MapDriverController extends GetxController {
[],
'cancel.wav',
);
CRUD().post(
link: "${AppLink.seferGizaServer}/ride/rides/update.php",
payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/ride/rides/update.php",
payload: {
"id": rideId.toString(), // Convert to String
"status": 'CancelFromDriverAfterApply'
});
CRUD().post(
link:
"${AppLink.seferGizaServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
payload: {
"order_id": rideId.toString(),
"driver_id": box.read(BoxName.driverID).toString(),
"status": 'reject After Applied',
"notes": cancelTripCotroller.text.toString()
});
CRUD().post(
link:
"${AppLink.seferAlexandriaServer}/ride/cancelRide/addCancelTripFromDriverAfterApplied.php",
payload: {
"order_id": rideId.toString(),
"driver_id": box.read(BoxName.driverID).toString(),
"status": 'reject After Applied',
"notes": cancelTripCotroller.text.toString()
});
sql.insertData({
'order_id': rideId,
'created_at': DateTime.now().toString(),
'driver_id': box.read(BoxName.driverID).toString(),
}, TableName.driverOrdersRefuse);
Get.put(OrderRequestController()).getRefusedOrderByCaptain();
Get.find<HomeCaptainController>().getRefusedOrderByCaptain();
Get.offAll(HomeCaptain());
}
}
@@ -302,21 +289,13 @@ class MapDriverController extends GetxController {
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
CRUD().post(
link: "${AppLink.seferGizaServer}/ride/rides/update.php",
payload: {
'id': rideId,
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/ride/rides/update.php",
payload: {
'id': rideId,
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: "${AppLink.endPoint}/ride/rides/update.php", payload: {
'id': rideId,
'driverGoToPassengerTime': DateTime.now().toString(),
'status': 'Applied'
});
}
// Get.find<HomeCaptainController>().changeToAppliedRide('Applied');
FirebaseMessagesController().sendNotificationToAnyWithoutData(
@@ -402,20 +381,13 @@ class MapDriverController extends GetxController {
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
CRUD()
.post(link: "${AppLink.seferGizaServer}/rides/update.php", payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'Begin',
});
}
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'RideIsBegin',
box.read(BoxName.name).toString(),
@@ -533,20 +505,14 @@ class MapDriverController extends GetxController {
'rideTimeStart': DateTime.now().toString(),
'status': 'CancelAfterWait',
});
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'CancelAfterWait',
});
CRUD()
.post(link: "${AppLink.seferGizaServer}/rides/update.php", payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'CancelAfterWait',
});
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(link: "${AppLink.endPoint}/rides/update.php", payload: {
'id': rideId,
'rideTimeStart': DateTime.now().toString(),
'status': 'CancelAfterWait',
});
}
var paymentTokenWait =
await generateTokenDriver(costOfWaiting5Minute.toString());
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
@@ -676,23 +642,17 @@ class MapDriverController extends GetxController {
'status': 'Finished',
'price': totalCost,
});
CRUD().post(
link: "${AppLink.seferGizaServer}/rides/update.php",
payload: {
'id': rideId,
'rideTimeFinish': DateTime.now().toString(),
'status': 'Finished',
'price': totalCost,
},
);
CRUD().post(
link: "${AppLink.seferAlexandriaServer}/rides/update.php",
if (AppLink.endPoint != AppLink.seferCairoServer) {
CRUD().post(
link: "${AppLink.endPoint}/rides/update.php",
payload: {
'id': rideId,
'rideTimeFinish': DateTime.now().toString(),
'status': 'Finished',
'price': totalCost,
});
},
);
}
if (walletChecked == 'true') {
paymentToken = await generateTokenPassenger(
((-1) * double.parse(paymentAmount)).toString());

View File

@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:SEFER/constant/links.dart';
@@ -5,7 +7,7 @@ import 'package:SEFER/constant/style.dart';
import 'package:SEFER/main.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'dart:math' as math;
import '../../../constant/box_name.dart';
import '../../../constant/table_names.dart';
import '../../functions/crud.dart';
@@ -24,15 +26,73 @@ class OrderRequestController extends GetxController {
final locationController = Get.put(LocationController());
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
final arguments = Get.arguments;
var myList;
late int hours;
late int minutes;
@override
void onInit() {
getRefusedOrderByCaptain();
// getRefusedOrderByCaptain();
initilizeOrderPage();
addCustomStartIcon();
addCustomEndIcon();
// calculateConsumptionFuel();
update();
super.onInit();
}
late LatLngBounds bounds;
late List<LatLng> pointsDirection;
late String body;
late double latPassengerLocation;
late double lngPassengerLocation;
late double lngPassengerDestination;
late double latPassengerDestination;
initilizeOrderPage() {
final myListString = arguments['myListString'];
// final myList = arguments['DriverList'];
if (arguments['DriverList'] == null || arguments['DriverList'].isEmpty) {
myList = jsonDecode(myListString);
} else {
myList = arguments['DriverList'];
}
body = arguments['body'];
Duration durationToAdd = Duration(seconds: int.parse(myList[4]));
hours = durationToAdd.inHours;
minutes = (durationToAdd.inMinutes % 60).round();
startTimerSpeed(myList[6].toString(), body.toString());
var coords = myList[0].split(',');
var coordDestination = myList[1].split(',');
// Parse to double
latPassengerLocation = double.parse(coords[0]);
lngPassengerLocation = double.parse(coords[1]);
latPassengerDestination = double.parse(coordDestination[0]);
lngPassengerDestination = double.parse(coordDestination[1]);
pointsDirection = [
LatLng(latPassengerLocation, lngPassengerLocation),
LatLng(latPassengerDestination, lngPassengerDestination)
]; // Calculate the midpoint between the two points
// Calculate the minimum and maximum latitude and longitude values
double minLatitude =
math.min(pointsDirection[0].latitude, pointsDirection[1].latitude);
double maxLatitude =
math.max(pointsDirection[0].latitude, pointsDirection[1].latitude);
double minLongitude =
math.min(pointsDirection[0].longitude, pointsDirection[1].longitude);
double maxLongitude =
math.max(pointsDirection[0].longitude, pointsDirection[1].longitude);
// Create a bounding box using the calculated values
bounds = LatLngBounds(
southwest: LatLng(minLatitude, minLongitude),
northeast: LatLng(maxLatitude, maxLongitude),
);
update();
}
getRideDEtailsForBackgroundOrder() async {
await CRUD().get(link: AppLink.getRidesDetails, payload: {
'id': box.read(BoxName.myList)[2].toString(),
@@ -44,9 +104,10 @@ class OrderRequestController extends GetxController {
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
mipmaps: false)
.then((value) {
BitmapDescriptor.asset(
config,
'assets/images/A.png',
).then((value) {
startIcon = value;
update();
});
@@ -55,9 +116,10 @@ class OrderRequestController extends GetxController {
void addCustomEndIcon() {
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png',
mipmaps: false)
.then((value) {
BitmapDescriptor.asset(
config,
'assets/images/b.png',
).then((value) {
endIcon = value;
update();
});
@@ -74,46 +136,6 @@ class OrderRequestController extends GetxController {
12; //todo in register car add mpg in box
}
void getRefusedOrderByCaptain() async {
// Get today's date in YYYY-MM-DD format
String today = DateTime.now().toString().substring(0, 10);
String driverId = box.read(BoxName.driverID).toString();
String customQuery = '''
SELECT COUNT(*) AS count
FROM ${TableName.driverOrdersRefuse}
WHERE driver_id = '$driverId'
AND DATE(created_at) = '$today'
''';
try {
List<Map<String, dynamic>> results =
await sql.getCustomQuery(customQuery);
countRefuse = results[0]['count'].toString();
print(countRefuse);
update();
if (int.parse(countRefuse) > 3) {
box.write(BoxName.statusDriverLocation, 'on');
locationController.stopLocationUpdates();
Get.defaultDialog(
// backgroundColor: CupertinoColors.destructiveRed,
barrierDismissible: false,
title: 'You Are Stopped For this Day !'.tr,
content: Text(
'You Refused 3 Rides this Day that is the reason \nSee you Tomorrow!'
.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'Ok , See you Tomorrow'.tr,
onPressed: () => Get.back()));
} else {
box.write(BoxName.statusDriverLocation, 'off');
}
} catch (e) {}
}
bool _timerActive = false;
Future<void> startTimer(String driverID, String orderID) async {

View File

@@ -476,9 +476,12 @@ Store your money with us and receive it in your bank as a monthly salary.''':
"تُولي Sefer أهمية كبيرة لسلامتك. نحن نقدم ميزات مثل التحقق من هوية السائق ، وتتبع الرحلات داخل التطبيق ، وخيارات الاتصال في حالات الطوارئ.",
'Frequently Questions': 'الأسئلة الشائعة',
"Contact Us": "اتصل بنا",
'Choose a contact option': 'اختر خيار الاتصال',
"You can change the vibration feedback for all buttons":
"يمكنك تغيير اهتزاز الرج لجميع الأزرار",
'About Us': "نبذة عنا",
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.':
'ساعات العمل من 12:00 - 19:00.\nيمكنك إرسال رسالة عبر واتساب أو بريد إلكتروني.',
"Most Secure Methods": "أساليب الأمان الأكثر فاعلية",
"In-App VOIP Calls": "مكالمات VOIP داخل التطبيق",
"Recorded Trips for Safety": "تسجيل الرحلات من أجل السلامة",
@@ -1084,7 +1087,8 @@ Store your money with us and receive it in your bank as a monthly salary.''':
"Please help! Contact me as soon as possible.":
"من فضلك ساعدني! تواصل معي في أقرب وقت ممكن.",
"Share Trip Details": "شارك تفاصيل الرحلة",
"Car Plate is": "لوحة السيارة", 'L.E': 'جنيه',
"Car Plate is": "لوحة السيارة",
'L.E': 'ج.م',
"the 3000 points equal 3000 L.E for you":
"الـ 3000 نقطة تعادل 3000 جنيه مصري بالنسبة لك",
"So go and gain your money": "انطلق واكسب مالك",