From a17ef6a7e6fc1ff2bc6a7c4e9ea529efd6fe2ca7 Mon Sep 17 00:00:00 2001 From: Hamza Aleghwairyeen Date: Wed, 3 Apr 2024 16:45:45 +0300 Subject: [PATCH] 4/3/9 --- lib/constant/links.dart | 3 ++ .../home/captin/order_request_controller.dart | 34 ++++++++++++++++++- .../home/map_passenger_controller.dart | 10 ++++++ lib/controller/local/translations.dart | 2 +- .../orderCaptin/order_request_page.dart | 15 +++++++- 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/lib/constant/links.dart b/lib/constant/links.dart index 93816bc..d9242c3 100644 --- a/lib/constant/links.dart +++ b/lib/constant/links.dart @@ -82,6 +82,8 @@ class AppLink { "$ride/notificationPassenger/update.php"; //-----------------Driver NotificationCaptain------------------ static String addNotificationCaptain = "$ride/notificationCaptain/add.php"; + static String addWaitingRide = "$ride/notificationCaptain/addWaitingRide.php"; + static String getRideWaiting = "$ride/notificationCaptain/getRideWaiting.php"; static String getNotificationCaptain = "$ride/notificationCaptain/get.php"; static String updateNotificationCaptain = "$ride/notificationCaptain/update.php"; @@ -133,6 +135,7 @@ class AppLink { static String addRateToPassenger = "$ride/rate/add.php"; static String addRateToDriver = "$ride/rate/addRateToDriver.php"; static String getDriverRate = "$ride/rate/getDriverRate.php"; + static String getPassengerRate = "$ride/rate/getPassengerRate.php"; ////////////////emails ============// static String sendEmailToPassengerForTripDetails = diff --git a/lib/controller/home/captin/order_request_controller.dart b/lib/controller/home/captin/order_request_controller.dart index ddbf139..26b2c35 100644 --- a/lib/controller/home/captin/order_request_controller.dart +++ b/lib/controller/home/captin/order_request_controller.dart @@ -107,7 +107,9 @@ class OrderRequestController extends GetxController { // } } - void refuseOrder(orderID) async { + void refuseOrder( + orderID, + ) async { await CRUD().postFromDialogue(link: AppLink.addDriverOrder, payload: { //TODO need review 'driver_id': box.read(BoxName.driverID), @@ -134,4 +136,34 @@ class OrderRequestController extends GetxController { Get.back(); // Get.offAll(HomeCaptain()); } + + addRideToNotificationDriverString( + orderID, + String startLocation, + String endLocation, + String date, + String time, + String price, + String passengerId, + String status, + String carType, + String passengerRate, + String priceForPassenger, + String distance, + ) async { + await CRUD().post(link: AppLink.addWaitingRide, payload: { + 'id': orderID, + 'start_location': startLocation, + 'end_location': endLocation, + 'date': date, + 'time': time, + 'price': price, + 'passenger_id': passengerId, + 'status': status, + 'carType': carType, + 'passengerRate': passengerRate, + 'price_for_passenger': priceForPassenger, + 'distance': distance, + }); + } } diff --git a/lib/controller/home/map_passenger_controller.dart b/lib/controller/home/map_passenger_controller.dart index 32ffa0d..606cdbd 100644 --- a/lib/controller/home/map_passenger_controller.dart +++ b/lib/controller/home/map_passenger_controller.dart @@ -834,6 +834,7 @@ class MapPassengerController extends GetxController { endNameAddress, box.read(BoxName.carType), kazan.toStringAsFixed(0), + passengerRate.toStringAsFixed(2), ]; print(body); FirebaseMessagesController().sendNotificationToDriverMapPolyline( @@ -2327,6 +2328,7 @@ class MapPassengerController extends GetxController { recentPlaces = await sql.getAllData(TableName.recentLocations); } + double passengerRate = 5; getKazanPercent() async { var res = await CRUD().get(link: AppLink.getKazanPercent); if (res != 'failure') { @@ -2337,6 +2339,13 @@ class MapPassengerController extends GetxController { } } + getPassengerRate() async { + var res = await CRUD().get(link: AppLink.getPassengerRate); + if (res != 'failure') { + passengerRate = double.parse(jsonDecode(res)['message'][0]['rating']); + } + } + @override void onInit() async { mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY); @@ -2345,6 +2354,7 @@ class MapPassengerController extends GetxController { await getLocation(); await addToken(); await getKazanPercent(); + await getPassengerRate(); startMarkerReloading(); // await getCarsLocationByPassenger(); // await getNearestDriverByPassengerLocation(); diff --git a/lib/controller/local/translations.dart b/lib/controller/local/translations.dart index c8925a4..f72a32c 100644 --- a/lib/controller/local/translations.dart +++ b/lib/controller/local/translations.dart @@ -479,7 +479,7 @@ class MyTranslation extends Translations { "المسافة من الراكب إلى الوجهة هي ", 'Cost Of Trip IS ': "تكلفة الرحلة هي ", 'Accept Order': "‏اقبل الطلب", - 'rejct your order.': "رفض طلبك.", + 'reject your order.': "رفض طلبك.", 'Bottom Bar Example': "مثال لشريط الأسفل", 'Statistics': "الإحصائيات", 'Scan Id': "مسح الهوية", diff --git a/lib/views/home/Captin/orderCaptin/order_request_page.dart b/lib/views/home/Captin/orderCaptin/order_request_page.dart index ea9fbd1..2e41390 100644 --- a/lib/views/home/Captin/orderCaptin/order_request_page.dart +++ b/lib/views/home/Captin/orderCaptin/order_request_page.dart @@ -389,7 +389,7 @@ class OrderRequestPage extends StatelessWidget { FirebaseMessagesController() .sendNotificationToPassengerToken( 'Refused Ride', - '${box.read(BoxName.nameDriver)} ${'rejct your order.'.tr}', + '${box.read(BoxName.nameDriver)} ${'reject your order.'.tr}', arguments['DriverList'][9].toString(), // box.read(BoxName.tokenDriver).toString(), bodyToPassenger, @@ -397,6 +397,19 @@ class OrderRequestPage extends StatelessWidget { orderRequestController.refuseOrder( myList[16].toString(), ); + orderRequestController.addRideToNotificationDriverString( + myList[16].toString(), + myList[0].toString(), + myList[1].toString(), + '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}', + '${DateTime.now().hour}:${DateTime.now().minute}', + myList[2].toString(), + myList[7].toString(), + 'wait', + myList[31].toString(), + myList[33].toString(), + myList[2].toString(), + myList[5].toString()); }, kolor: AppColor.redColor, ),