Initial commit for Tripz Admin

This commit is contained in:
Hamza-Ayed
2026-01-21 17:31:10 +03:00
parent 5919554eaa
commit 1da2357124
31 changed files with 1812 additions and 980 deletions

View File

@@ -4,6 +4,12 @@ import '../env/env.dart';
import 'char_map.dart';
class AK {
static final String allowed = Env.allowed;
static final String passnpassenger = X
.r(X.r(X.r(Env.passnpassenger, cn), cC), cs)
.toString()
.split(Env.addd)[0];
static final String newId = Env.newId;
static final String publishableKey =
X.r(X.r(X.r(Env.stripePublishableKe, cn), cC), cs);
static final String secretKey = X.r(X.r(X.r(Env.secretKey, cn), cC), cs);

View File

@@ -8,6 +8,14 @@ class BoxName {
static const String carPlate = "carPlate";
static const String statusDriverLocation = "statusDriverLocation";
static const String password = "password";
static const String keyOfApp = 'keyOfApp';
static const String initializationVector = 'initializationVector';
static const String firstTimeLoadKey = 'firstTimeLoadKey';
static const String jwt = "jwt";
static const String hmac = "hmac";
static const String fingerPrint = "fingerPrint";
static const String payMobApikey = "payMobApikey";
static const String refreshToken = "refreshToken";
static const String arrivalTime = "arrivalTime";
static const String passwordDriver = "passwordDriver";
static const String agreeTerms = "agreeTerms";

View File

@@ -8,6 +8,7 @@ class AppInformation {
static const String email = 'hamzaayed@mobile-app.store';
static const String complaintPrompt =
'for this data for complaint from driver or passenger i collect all data i want you analyze this complaint and show what is reason and what is solution .this data collected from many table to find solution if payment in visa not complete and if ride status is finished it will be paymnet in payment table if ride status is not finished there is no need to pay and payment table is null for this ride and if paymentFromPaymentTable not null and visa type not cash the payment sucssessed . if ratingpassenger is low or passengr rating drivers low grade then dont mine of this passenger ,look at driver too like passengerratingdriver with rating or ratingtopassenger .in json add status of complaint and message to passenger and message to driver and message to call center write in arabic in json output with key in english .for output please just json i want';
static const String addd = 'BlBlNl';
static const String privacyPolicy = '''

View File

@@ -1,19 +1,25 @@
import '../env/env.dart';
class AppLink {
static final String seferPaymentServer0 = Env.seferPaymentServer;
static final String seferPaymentServer = '${Env.seferPaymentServer}/ride';
static final String seferAlexandriaServer = Env.seferAlexandriaServer;
static final String seferCairoServer = Env.seferCairoServer;
// static final String seferGizaServer = Env.seferGizaServer;
static String seferPaymentServer = 'https://wl.tripz-egypt.com/v1/main';
static final String tripzPaymentServer0 = seferPaymentServer;
static final String tripzPaymentServer = '$seferPaymentServer/ride';
static final String tripzAlexandriaServer = Env.seferAlexandriaServer;
static final String tripzCairoServer = Env.seferCairoServer;
static final String tripzGizaServer = Env.seferGizaServer;
// static final String endPoint = box.read(BoxName.serverChosen);
static final String server = Env.seferCairoServer;
// static const String server = 'https://api.sefer.live/sefer';
// static final String server = Env.seferCairoServer;
static final String server = 'https://api.tripz-egypt.com/tripz';
static String loginJwtDriver =
"https://api.tripz-egypt.com/tripz/loginAdmin.php";
static String getPaymentsDashboard =
"$seferPaymentServer/Admin/getPaymentsDashboard.php";
static String googleMapsLink = 'https://maps.googleapis.com/maps/api/';
static String llama = 'https://api.llama-api.com/chat/completions';
static String gemini =
'https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText';
static String loginWalletAdmin = "$seferPaymentServer/loginWalletAdmin.php";
static String test = "$server/test.php";
//===============firebase==========================
@@ -28,14 +34,14 @@ class AppLink {
//=======================Wallet===================
static String addPaymentTokenDriver =
"$seferPaymentServer/driverWallet/addPaymentToken.php";
static String addSeferWallet = "$seferPaymentServer/seferWallet/add.php";
static String getSeferWallet = "$seferPaymentServer/seferWallet/get.php";
static String addDrivePayment = "$seferPaymentServer/payment/add.php";
"$tripzPaymentServer/driverWallet/addPaymentToken.php";
static String addSeferWallet = "$tripzPaymentServer/seferWallet/add.php";
static String getSeferWallet = "$tripzPaymentServer/seferWallet/get.php";
static String addDrivePayment = "$tripzPaymentServer/payment/add.php";
static String updatePaymetToPaid =
"$seferPaymentServer/payment/updatePaymetToPaid.php";
static String wallet = '$seferPaymentServer/passengerWallet';
static String walletDriver = '$seferPaymentServer/driverWallet';
"$tripzPaymentServer/payment/updatePaymetToPaid.php";
static String wallet = '$tripzPaymentServer/passengerWallet';
static String walletDriver = '$tripzPaymentServer/driverWallet';
static String getAllPassengerTransaction =
"$wallet/getAllPassengerTransaction.php";
static String getWalletByPassenger = "$wallet/getWalletByPassenger.php";
@@ -85,17 +91,17 @@ class AppLink {
static String addKazanPercent = "$ride/kazan/add.php";
////-----------------DriverPayment------------------
static String addDriverpayment = "$seferPaymentServer/payment/add.php";
static String addDriverpayment = "$tripzPaymentServer/payment/add.php";
static String addDriverPaymentPoints =
"$seferPaymentServer/driverPayment/add.php";
"$tripzPaymentServer/driverPayment/add.php";
static String getDriverPaymentPoints =
"$seferPaymentServer/driverWallet/get.php";
static String getDriverpaymentToday = "$seferPaymentServer/payment/get.php";
static String getCountRide = "$seferPaymentServer/payment/getCountRide.php";
"$tripzPaymentServer/driverWallet/get.php";
static String getDriverpaymentToday = "$tripzPaymentServer/payment/get.php";
static String getCountRide = "$tripzPaymentServer/payment/getCountRide.php";
static String getAllPaymentFromRide =
"$seferPaymentServer/payment/getAllPayment.php";
"$tripzPaymentServer/payment/getAllPayment.php";
static String getAllPaymentVisa =
"$seferPaymentServer/payment/getAllPaymentVisa.php";
"$tripzPaymentServer/payment/getAllPaymentVisa.php";
//-----------------Passenger NotificationCaptain------------------
static String addNotificationPassenger =
@@ -166,7 +172,7 @@ class AppLink {
static String sendEmailToPassengerForTripDetails =
"$ride/rides/emailToPassengerTripDetail.php";
static String sendEmailToDrivertransaction =
"https://api.sefer.live/sefer/Admin/sendEmailToDrivertransaction.php";
"https://api.tripz-egypt.com/tripz/Admin/sendEmailToDrivertransaction.php";
// ===========================================
static String pathImage = "$server/upload/types/";
@@ -232,6 +238,11 @@ class AppLink {
static String getdashbord = "$server/Admin/dashbord.php";
static String getEmployee = "$server/Admin/employee/get.php";
static String getBestDriver = "$server/Admin/driver/getBestDriver.php";
static String getBestDriverGiza =
"https://gizasefer.online/sefer/Admin/driver/getBestDriver.php";
static String getBestDriverAlexandria =
"$tripzAlexandriaServer/Admin/driver/getBestDriver.php";
static String deleteRecord = "$server/Admin/driver/deleteRecord.php";
static String addEmployee = "$server/Admin/employee/add.php";
static String getdashbordPayment = "$server/Admin/dashbordPayment.php";
static String getAdminUser = "$server/Admin/adminUser/get.php";

View File

@@ -17,18 +17,60 @@ class DashboardController extends GetxController {
final formKey = GlobalKey<FormState>();
final smsText = TextEditingController();
// Future getDashBoard() async {
// isLoading = true;
// update();
// var res = await CRUD().get(link: AppLink.getdashbord, payload: {});
// if (res != 'failure') {
// var d = jsonDecode(res);
// Log.print('d: ${d}');
// dashbord = d['message'];
// isLoading = false;
// update();
// }
// var res2 = await CRUD().kazumiSMS(
// link: 'https://sms.kazumi.me/api/sms/check-credit',
// payload: {"username": "Sefer", "password": AK.smsPasswordEgypt},
// );
// creditSMS = res2['credit'];
// Log.print(' res2[credit]: ${res2['credit']}');
// Log.print('creditSMS: ${creditSMS}');
// update();
// }
Future getDashBoard() async {
isLoading = true;
update();
// الطلب من السيرفر الرئيسي
var res = await CRUD().get(link: AppLink.getdashbord, payload: {});
if (res != 'failure') {
var d = jsonDecode(res);
Log.print('d: ${d}');
dashbord = d['message'];
isLoading = false;
update();
// Log.print('d: ${d}');
dashbord = d['message']; // هذا عبارة عن List<Map>
}
// الطلب من سيرفر المحافظ
var resPayments = await CRUD().postWallet(
link: AppLink.getPaymentsDashboard,
payload: {},
);
if (resPayments != 'failure') {
var p = resPayments;
// Log.print('p: ${p}');
// نتأكد أن الكل Map بداخل List
if (dashbord.isNotEmpty &&
p['message'] is List &&
p['message'].isNotEmpty) {
dashbord[0].addAll(p['message'][0]); // ندمج المعلومات داخل نفس الـ Map
}
}
// كريدت الرسائل
var res2 = await CRUD().kazumiSMS(
link: 'https://sms.kazumi.me/api/sms/check-credit',
payload: {"username": "Sefer", "password": AK.smsPasswordEgypt},
@@ -38,9 +80,11 @@ class DashboardController extends GetxController {
Log.print(' res2[credit]: ${res2['credit']}');
Log.print('creditSMS: ${creditSMS}');
isLoading = false;
update();
}
sendSMSMethod() async {
if (formKey.currentState!.validate()) {
for (var phoneNumber in box.read(BoxName.tokensDrivers)['message']) {

View File

@@ -87,79 +87,104 @@ class StaticController extends GetxController {
}
Future<void> fetchEmployee() async {
isLoading = true;
update();
try {
isLoading = true;
update();
var res = await CRUD().get(link: AppLink.getEmployeeStatic, payload: {});
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
isLoading = false;
var res = await CRUD().get(link: AppLink.getEmployeeStatic, payload: {});
final List<dynamic> jsonData = jsonResponse['message'];
totalMonthlyRides = jsonData[0]['totalMonthly'].toString();
// Group data by employee
Map<String, List<MonthlyEmployeeData>> employeeDataMap = {};
for (var item in jsonData) {
var employeeData = MonthlyEmployeeData.fromJson(item);
if (!employeeDataMap.containsKey(employeeData.name)) {
employeeDataMap[employeeData.name] = [];
// First check if the response is valid JSON
if (res == 'failure') {
throw FormatException('Invalid response: $res');
}
employeeDataMap[employeeData.name]!.add(employeeData);
var jsonResponse = jsonDecode(res) as Map<String, dynamic>;
// Initialize empty lists for all chart data
chartDataEmployeeMaryam = <FlSpot>[];
chartDataEmployeeRawda = <FlSpot>[];
chartDataEmployeeMena = <FlSpot>[];
chartDataEmployeeSefer4 = <FlSpot>[];
totalMonthlyRides = '0';
// Check for error response
if (jsonResponse['status'] == 'failure') {
isLoading = false;
update();
return;
}
final List<dynamic> jsonData = jsonResponse['message'];
if (jsonData.isEmpty) {
isLoading = false;
update();
return;
}
totalMonthlyRides = jsonData[0]['totalMonthly']?.toString() ?? '0';
// Group data by employee
Map<String, List<MonthlyEmployeeData>> employeeDataMap = {};
for (var item in jsonData) {
var employeeData = MonthlyEmployeeData.fromJson(item);
if (!employeeDataMap.containsKey(employeeData.name)) {
employeeDataMap[employeeData.name] = [];
}
employeeDataMap[employeeData.name]!.add(employeeData);
}
final today = DateTime.now().day;
// Create data for each employee
final employeeNames = {
'maryam': chartDataEmployeeMaryam,
'yasmine': chartDataEmployeeRawda,
'mena': chartDataEmployeeMena,
'ashjan': chartDataEmployeeSefer4,
};
employeeNames.forEach((name, chartData) {
var spots = <FlSpot>[];
for (int day = 1; day <= today; day++) {
spots.add(FlSpot(
day.toDouble(),
employeeDataMap[name]
?.firstWhere(
(e) => e.day == day,
orElse: () => MonthlyEmployeeData(
day: day,
totalEmployees: 0,
name: name,
),
)
.totalEmployees
.toDouble() ??
0,
));
}
// Explicitly cast to List<FlSpot>
if (name == 'maryam')
chartDataEmployeeMaryam = List<FlSpot>.from(spots);
if (name == 'yasmine')
chartDataEmployeeRawda = List<FlSpot>.from(spots);
if (name == 'mena') chartDataEmployeeMena = List<FlSpot>.from(spots);
if (name == 'ashjan')
chartDataEmployeeSefer4 = List<FlSpot>.from(spots);
});
} catch (e) {
Log.print('Error in fetchEmployee: $e');
// Set empty FlSpot lists in case of error
chartDataEmployeeMaryam = <FlSpot>[];
chartDataEmployeeRawda = <FlSpot>[];
chartDataEmployeeMena = <FlSpot>[];
chartDataEmployeeSefer4 = <FlSpot>[];
totalMonthlyRides = '0';
} finally {
isLoading = false;
update();
}
// Create FlSpot data for each employee
List<FlSpot> chartDataMaryam = [];
List<FlSpot> chartDataRawda = [];
List<FlSpot> chartDataMena = [];
List<FlSpot> chartDataSefer4 = [];
for (int day = 1; day <= DateTime.now().day; day++) {
chartDataMaryam.add(FlSpot(
day.toDouble(),
employeeDataMap['maryam']
?.firstWhere((e) => e.day == day,
orElse: () => MonthlyEmployeeData(
day: day, totalEmployees: 0, name: 'maryam'))
.totalEmployees
.toDouble() ??
0));
chartDataRawda.add(FlSpot(
day.toDouble(),
employeeDataMap['yasmine']
?.firstWhere((e) => e.day == day,
orElse: () => MonthlyEmployeeData(
day: day, totalEmployees: 0, name: 'yasmine'))
.totalEmployees
.toDouble() ??
0));
chartDataMena.add(FlSpot(
day.toDouble(),
employeeDataMap['mena']
?.firstWhere((e) => e.day == day,
orElse: () => MonthlyEmployeeData(
day: day, totalEmployees: 0, name: 'mena'))
.totalEmployees
.toDouble() ??
0));
chartDataSefer4.add(FlSpot(
day.toDouble(),
employeeDataMap['ashjan']
?.firstWhere((e) => e.day == day,
orElse: () => MonthlyEmployeeData(
day: day, totalEmployees: 0, name: 'ashjan'))
.totalEmployees
.toDouble() ??
0));
}
// Combine spots into a single list if needed or keep them separate
chartDataEmployeeMaryam = chartDataMaryam;
chartDataEmployeeRawda = chartDataRawda;
chartDataEmployeeMena = chartDataMena;
chartDataEmployeeSefer4 = chartDataSefer4;
update();
}
Future<void> fetchDrivers() async {

View File

@@ -25,3 +25,44 @@ class Driverthebest extends GetxController {
super.onInit();
}
}
class DriverTheBestGizaController extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res = await CRUD().get(link: AppLink.getBestDriverGiza, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}
class DriverTheBestAlexandriaController extends GetxController {
bool isLoading = false;
List driver = [];
getBestDriver() async {
var res =
await CRUD().get(link: AppLink.getBestDriverAlexandria, payload: {});
if (res != 'failure') {
driver = jsonDecode(res)['message'];
update();
} else {
Get.snackbar('error', '', backgroundColor: AppColor.redColor);
}
}
@override
void onInit() {
getBestDriver();
super.onInit();
}
}

View File

@@ -1,22 +1,144 @@
import 'dart:convert';
import 'dart:io';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:jwt_decoder/jwt_decoder.dart';
import 'package:secure_string_operations/secure_string_operations.dart';
import '../../constant/api_key.dart';
import '../../constant/box_name.dart';
import '../../constant/char_map.dart';
import '../../constant/info.dart';
import '../../constant/links.dart';
import '../../env/env.dart';
import '../../main.dart';
import '../../print.dart';
import '../../views/widgets/elevated_btn.dart';
import 'device_info.dart';
import 'encrypt_decrypt.dart';
class CRUD {
var dev = '';
getJWT() async {
dev = Platform.isAndroid ? 'android' : 'ios';
var payload = {
'id': 'admin',
'password': AK.passnpassenger,
'aud': '${AK.allowed}$dev',
};
var response1 = await http.post(
Uri.parse(AppLink.loginJwtDriver),
body: payload,
);
if (response1.statusCode == 200) {
final decodedResponse1 = jsonDecode(response1.body);
final jwt = decodedResponse1['jwt'];
await box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
// await AppInitializer().getKey();
}
}
getJwtWallet() async {
String fingerPrint = await DeviceHelper.getDeviceFingerprint();
print('fingerPrint: ${fingerPrint}');
dev = Platform.isAndroid ? 'android' : 'ios';
var payload = {
'id': '1',
'password': AK.passnpassenger,
'aud': '${Env.allowedWallet}$dev',
'fingerPrint': fingerPrint
};
// Log.print('payload: ${payload}');
var response1 = await http.post(
Uri.parse(AppLink.loginWalletAdmin),
body: payload,
);
// Log.print('response.request: ${response1.request}');
// Log.print('response.body: ${response1.body}');
// print(payload);
// Log.print(
// 'jsonDecode(response1.body)["jwt"]: ${jsonDecode(response1.body)['jwt']}');
await box.write(BoxName.hmac, jsonDecode(response1.body)['hmac']);
return jsonDecode(response1.body)['jwt'].toString();
}
Future<dynamic> postWallet(
{required String link, Map<String, dynamic>? payload}) async {
var s = await getJwtWallet();
Log.print('jwt: ${s}');
final hmac = box.read(BoxName.hmac);
Log.print('hmac: ${hmac}');
var url = Uri.parse(link);
Log.print('url: ${url}');
try {
// await LoginDriverController().getJWT();
var response = await http.post(
url,
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization': 'Bearer $s',
'X-HMAC-Auth': hmac.toString(),
},
);
Log.print('response.request:${response.request}');
Log.print('response.body: ${response.body}');
Log.print('payload:$payload');
if (response.statusCode == 200) {
try {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
return jsonData;
} else {
return jsonData['status'];
}
} catch (e) {
// addError(e.toString(), 'crud().post - JSON decoding');
return 'failure';
}
} else if (response.statusCode == 401) {
// Specifically handle 401 Unauthorized
var jsonData = jsonDecode(response.body);
if (jsonData['error'] == 'Token expired') {
return 'token_expired'; // Return a specific value for token expiration
} else {
// Other 401 errors
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
return 'failure';
}
} else {
// addError('Non-200 response code: ${response.statusCode}',
// 'crud().post - Other');
return 'failure';
}
} catch (e) {
// addError('HTTP request error: $e', 'crud().post - HTTP');
return 'failure';
}
}
Future<dynamic> get({
required String link,
Map<String, dynamic>? payload,
}) async {
if (box.read(BoxName.jwt) == null) {
await getJWT();
}
bool isTokenExpired = JwtDecoder.isExpired(X
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
.toString()
.split(AppInformation.addd)[0]);
if (isTokenExpired) {
await getJWT();
}
// await Get.put(LoginDriverController()).getJWT();
var url = Uri.parse(
link,
);
@@ -26,18 +148,148 @@ class CRUD {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
},
);
Log.print('response: ${response.request}');
// if (response.statusCode == 200) {
var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
Log.print('response: ${response.body}');
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
return response.body;
}
if (jsonData['status'] == 'success') {
return response.body;
return jsonData['status'];
} else if (response.statusCode == 401) {
// Specifically handle 401 Unauthorized
var jsonData = jsonDecode(response.body);
if (jsonData['error'] == 'Token expired') {
// Show snackbar prompting to re-login
// await Get.put(LoginDriverController()).getJWT();
// mySnackbarSuccess('please order now'.tr);
return 'token_expired'; // Return a specific value for token expiration
} else {
// Other 401 errors
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
return 'failure';
}
} else {
// addError('Non-200 response code: ${response.statusCode}',
// 'crud().post - Other');
return 'failure';
}
}
return jsonData['status'];
// Future<dynamic> getWallet({
// required String link,
// Map<String, dynamic>? payload,
// }) async {
// var s = await getJwtWallet();
// var url = Uri.parse(
// link,
// );
// var response = await http.post(
// url,
// body: payload,
// headers: {
// "Content-Type": "application/x-www-form-urlencoded",
// 'Authorization': 'Bearer $s'
// },
// );
// if (response.statusCode == 200) {
// var jsonData = jsonDecode(response.body);
// if (jsonData['status'] == 'success') {
// return response.body;
// }
// return jsonData['status'];
// } else if (response.statusCode == 401) {
// // Specifically handle 401 Unauthorized
// var jsonData = jsonDecode(response.body);
// if (jsonData['error'] == 'Token expired') {
// // Show snackbar prompting to re-login
// // await Get.put(LoginDriverController()).getJwtWallet();
// return 'token_expired'; // Return a specific value for token expiration
// } else {
// // Other 401 errors
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
// return 'failure';
// }
// } else {
// addError('Non-200 response code: ${response.statusCode}',
// 'crud().post - Other');
// return 'failure';
// }
// }
Future<dynamic> post(
{required String link, Map<String, dynamic>? payload}) async {
var url = Uri.parse(link);
try {
bool isTokenExpired = JwtDecoder.isExpired(X
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
.toString()
.split(AppInformation.addd)[0]);
if (isTokenExpired) {
await getJWT();
}
var response = await http.post(
url,
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
// 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
},
);
if (response.statusCode == 200) {
try {
var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
return jsonData;
} else {
return jsonData['status'];
}
} catch (e) {
// addError(e.toString(), 'crud().post - JSON decoding');
return 'failure';
}
} else if (response.statusCode == 401) {
// Specifically handle 401 Unauthorized
var jsonData = jsonDecode(response.body);
if (jsonData['error'] == 'Token expired') {
// Show snackbar prompting to re-login
await getJWT();
// MyDialog().getDialog(
// 'Session expired. Please log in again.'.tr,
// '',
// () {
// Get.put(LoginController()).loginUsingCredentials(
// box.read(BoxName.passengerID), box.read(BoxName.email));
// Get.back();
// },
// );
return 'token_expired'; // Return a specific value for token expiration
} else {
// Other 401 errors
// addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
return 'failure';
}
} else {
// addError('Non-200 response code: ${response.statusCode}',
// 'crud().post - Other');
return 'failure';
}
} catch (e) {
// addError('HTTP request error: $e', 'crud().post - HTTP');
return 'failure';
}
}
// }
@@ -67,10 +319,7 @@ class CRUD {
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
} else {
print(response.reasonPhrase);
}
} else {}
}
Future<dynamic> getAgoraToken({
@@ -209,15 +458,12 @@ class CRUD {
String imagePathFull =
'${AppLink.server}/card_image/$imagePath-$driverID.jpg';
Log.print('imagePathFull: $imagePathFull');
var request = http.Request(
'POST',
Uri.parse(
'https://eastus.api.cognitive.microsoft.com/computervision/imageanalysis:analyze?features=caption,read&model-version=latest&language=en&api-version=2024-02-01'));
request.body = json.encode({"url": imagePathFull});
Log.print('request.body: ${request.body}');
request.headers.addAll(headers);
Log.print('request.headers: ${request.headers}');
http.StreamedResponse response = await request.send();
@@ -281,49 +527,6 @@ class CRUD {
} else {}
}
Future<dynamic> post({
required String link,
Map<String, dynamic>? payload,
}) async {
try {
var url = Uri.parse(link);
var response = await http.post(
url,
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
},
);
Log.print('payload: ${payload}');
var jsonData = jsonDecode(response.body);
Log.print('jsonData: ${jsonData}');
if (response.statusCode == 200) {
if (jsonData['status'] == 'success') {
return response.body;
} else {
return jsonData['status'];
}
} else {
// Log non-fatal errors to Crashlytics
await FirebaseCrashlytics.instance.log("Failed API request :$link");
FirebaseCrashlytics.instance.recordError(
Exception('Error: ${response.statusCode}'),
null,
reason: 'Failed HTTP POST request',
);
return response.statusCode;
}
} catch (e, stackTrace) {
// Log error to Crashlytics
await FirebaseCrashlytics.instance
.recordError(e, stackTrace, reason: 'Exception in post request');
return 'Error occurred';
}
}
Future<dynamic> kazumiSMS({
required String link,
Map<String, dynamic>? payload,
@@ -344,7 +547,6 @@ class CRUD {
if (response.statusCode == 200) {
var responseBody = await response.stream.bytesToString();
var data = json.decode(responseBody);
Log.print('data: ${data}');
return data;
} else {}
}
@@ -366,7 +568,6 @@ class CRUD {
body: body,
headers: headers,
);
Log.print('res: ${res.body}');
}
Future<dynamic> postPayMob({

View File

@@ -1,6 +1,48 @@
// import 'dart:io';
// import 'package:device_info_plus/device_info_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'dart:io';
class DeviceHelper {
static Future<String> getDeviceFingerprint() async {
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
var deviceData;
try {
if (Platform.isAndroid) {
// Fetch Android-specific device information
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
deviceData = androidInfo.toMap(); // Convert to a map for easier access
// Log.print('deviceData: ${jsonEncode(deviceData)}');
} else if (Platform.isIOS) {
// Fetch iOS-specific device information
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
deviceData = iosInfo.toMap(); // Convert to a map for easier access
} else {
throw UnsupportedError('Unsupported platform');
}
// Extract relevant device information
final String deviceId = Platform.isAndroid
? deviceData['androidId'] ?? deviceData['serialNumber'] ?? 'unknown'
: deviceData['identifierForVendor'] ?? 'unknown';
final String deviceModel = deviceData['model'] ?? 'unknown';
final String osVersion = Platform.isAndroid
? deviceData['version']['release'] ?? 'unknown'
: deviceData['systemVersion'] ?? 'unknown';
// Log the extracted information
// Generate and return the encrypted fingerprint
final String fingerprint = '${deviceId}_${deviceModel}_$osVersion';
// print(EncryptionHelper.instance.encryptData(fingerprint));
return (fingerprint);
} catch (e) {
throw Exception('Failed to generate device fingerprint');
}
}
}
// class DeviceInfoPlus {
// static List<Map<String, dynamic>> deviceDataList = [];

View File

@@ -0,0 +1,70 @@
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:flutter/foundation.dart';
import 'package:sefer_admin1/env/env.dart';
import '../../constant/box_name.dart';
import '../../main.dart';
class EncryptionHelper {
static EncryptionHelper? _instance;
late final encrypt.Key key;
late final encrypt.IV iv;
EncryptionHelper._(this.key, this.iv);
static EncryptionHelper get instance {
if (_instance == null) {
throw Exception(
"EncryptionHelper is not initialized. Call `await EncryptionHelper.initialize()` in main.");
}
return _instance!;
}
/// Initializes and stores the instance globally
static Future<void> initialize() async {
if (_instance != null) {
debugPrint("EncryptionHelper is already initialized.");
return; // Prevent re-initialization
}
debugPrint("Initializing EncryptionHelper...");
// Read stored keys
String? keyOfApp = Env.keyOfApp.toString().split('XrXlBl')[0];
//await storage.read(key: BoxName.keyOfApp);
// Log.print('keyOfApp: ${keyOfApp}');
String? initializationVector = Env.initializationVector;
// await storage.read(key: BoxName.initializationVector);
// Log.print('initializationVector: ${initializationVector}');
// Set the global instance
_instance = EncryptionHelper._(
encrypt.Key.fromUtf8(keyOfApp!),
encrypt.IV.fromUtf8(initializationVector!),
);
debugPrint("EncryptionHelper initialized successfully.");
}
/// Encrypts a string
String encryptData(String plainText) {
try {
final encrypter =
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypter.encrypt(plainText, iv: iv);
return encrypted.base64;
} catch (e) {
debugPrint('Encryption Error: $e');
return '';
}
}
/// Decrypts a string
String decryptData(String encryptedText) {
try {
final encrypter =
encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypt.Encrypted.fromBase64(encryptedText);
return encrypter.decrypt(encrypted, iv: iv);
} catch (e) {
debugPrint('Decryption Error: $e');
return '';
}
}
}

View File

@@ -21,17 +21,17 @@ class WalletController extends GetxController {
addPaymentToDriver(String amount, driverID, token) async {
paymentToken = await generateTokenDriver(amount.toString(), driverID);
var res = await CRUD().post(link: AppLink.addDrivePayment, payload: {
'rideId': 'gift$driverID',
'rideId': 'gift_$driverID _${DateTime.now().toIso8601String()}',
'amount': amount,
'payment_method': 'visaRide',
'passengerID': 'passengerId',
'passengerID': 'gift',
'token': paymentToken,
'driverID': driverID.toString(),
});
if (res != 'failure') {
FirebaseMessagesController().sendNotificationToAnyWithoutData(
'you have gift from SEFER'.tr,
'',
"لديك هدية من سفَر".tr,
'لقد حصلت على هدية من سفر بقيمة $amount ',
token, // Access token correctly
'ding.wav',
);

View File

@@ -10,6 +10,7 @@ import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'controller/firebase/firbase_messge.dart';
import 'controller/functions/encrypt_decrypt.dart';
import 'firebase_options.dart';
import 'models/db_sql.dart';
import 'views/admin/admin_home_page.dart';
@@ -29,6 +30,7 @@ DbSql sql = DbSql.instance;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GetStorage.init();
await EncryptionHelper.initialize();
if (Platform.isAndroid || Platform.isIOS) {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,

View File

@@ -20,6 +20,7 @@ import '../../controller/functions/gemeni.dart';
import '../../print.dart';
import '../widgets/my_scafold.dart';
import 'captain/captain.dart';
import 'dashboard_widget.dart';
import 'drivers/driver_the_best.dart';
import 'packages.dart';
import 'passenger/passenger.dart';
@@ -29,432 +30,352 @@ import 'wallet/wallet.dart';
class AdminHomePage extends StatelessWidget {
const AdminHomePage({super.key});
int _calculateCrossAxisCount(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
if (screenWidth > 1200) {
// Large desktops
return 5;
} else if (screenWidth > 900) {
// Desktops / Large Tablets
return 4;
} else if (screenWidth > 600) {
// Tablets
return 3;
} else {
// Phones
return 2;
}
}
// Helper to format currency (assuming '₵' is your currency symbol)
String _formatCurrency(dynamic value) {
final number = double.tryParse(value.toString());
if (number != null) {
return '${number.toStringAsFixed(2)}';
}
return value.toString(); // Fallback to original string if not a number
}
@override
Widget build(BuildContext context) {
Get.put(DashboardController());
return MyScafolld(
title: 'Admin Home Page',
action: IconButton(
onPressed: () async {
await Get.find<DashboardController>().getDashBoard();
},
icon: const Icon(
Icons.refresh,
color: AppColor.greenColor,
),
title: 'Admin Home Page',
action: IconButton(
onPressed: () async {
await Get.find<DashboardController>().getDashBoard();
},
icon: const Icon(
Icons.refresh,
color: AppColor.greenColor,
),
body: [
GetBuilder<DashboardController>(builder: (dashboardController) {
return dashboardController.dashbord.isEmpty
? const MyCircularProgressIndicator()
: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
// crossAxisAlignment: WrapCrossAlignment.center,
// alignment: WrapAlignment.center,
children: [
Container(
width: Get.width,
height: Get.height * .6,
decoration: AppStyle.boxDecoration1,
child: Wrap(
spacing: 6,
alignment: WrapAlignment.spaceBetween,
runAlignment: WrapAlignment.spaceBetween,
children: [
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Sms',
style: AppStyle.title,
),
Text(dashboardController.creditSMS
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Passengers',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['countPassengers']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Drivers',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['countDriver']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Rides this month',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['countRideThisMonth']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'avg costs',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['avg_passenger_price']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'completed ride',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['completed_rides']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'cancelled ride',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['cancelled_rides']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'payments to driver',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['payments']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'sefer wallet',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['seferWallet']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'count of transfer',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['transfer_from_count']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Morning',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['morning_ride_count']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'evening',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['evening_ride_count']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'night',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['night_ride_count']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'comfort',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['comfort']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Speed',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['speed']
.toString()),
],
),
)),
Container(
decoration: AppStyle.boxDecoration1,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text(
'Lady',
style: AppStyle.title,
),
Text(dashboardController.dashbord[0]
['lady']
.toString()),
],
),
)),
],
)),
AdminWidgetsDashBoard(
title: 'Passengers',
onPressed: () => Get.to(() => Passengrs(),
transition: Transition.topLevel)),
AdminWidgetsDashBoard(
title: 'Captains',
onPressed: () => Get.to(() => Captain(),
transition: Transition.size)),
AdminWidgetsDashBoard(
title: 'Wallet',
onPressed: () => Get.to(() => Wallet(),
transition: Transition.fade)),
AdminWidgetsDashBoard(
title: 'Rides',
onPressed: () => Get.to(() => Rides(),
transition: Transition.downToUp)),
AdminWidgetsDashBoard(
title: 'Static',
onPressed: () async {
await Get.put(StaticController()).getAll();
),
body: [
// This is a List<Widget> for MyScafolld
GetBuilder<DashboardController>(builder: (dashboardController) {
return dashboardController.dashbord.isEmpty
? const MyCircularProgressIndicator()
: Padding(
// This Padding wraps the entire content for this section
padding: const EdgeInsets.all(8.0),
child: ListView(
// Changed from a direct ListView for the whole page
// to a ListView that contains the stats grid and then other items.
children: [
// --- Statistics Grid Section ---
Container(
// width: Get.width, // Not needed in ListView
// height: Get.height * .6, // Let GridView determine its height
padding: const EdgeInsets.all(
8.0), // Padding for the grid container
decoration: AppStyle.boxDecoration1.copyWith(
// Optional: slightly different background for the grid area
// color: (AppStyle.boxDecoration1.color as Color?)?.withAlpha(200) ?? Theme.of(context).cardColor.withAlpha(200),
boxShadow: [] // Remove shadow if cards have them, or use a very subtle one
),
child: GridView.count(
crossAxisCount: _calculateCrossAxisCount(context),
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(), // Grid shouldn't scroll independently
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
childAspectRatio:
1.7, // Adjust for desired card W/H ratio (e.g. 1.5 to 2.0)
children: [
DashboardStatCard(
title: 'SMS Credits',
value: dashboardController.creditSMS.toString(),
icon: Icons.sms_outlined,
iconColor: Colors.lightBlueAccent,
),
DashboardStatCard(
title: 'Passengers',
value: dashboardController.dashbord[0]
['countPassengers']
.toString(),
icon: Icons.people_alt_outlined,
iconColor: Colors.teal,
),
DashboardStatCard(
title: 'Drivers',
value: dashboardController.dashbord[0]
['countDriver']
.toString(),
icon: Icons.sports_motorsports_outlined,
iconColor: Colors.orangeAccent,
),
DashboardStatCard(
title: 'Rides (Month)',
value: dashboardController.dashbord[0]
['countRideThisMonth']
.toString(),
icon: Icons.calendar_month_outlined,
iconColor: Colors.purpleAccent,
),
DashboardStatCard(
title: 'Avg. Ride Cost',
value: _formatCurrency(dashboardController
.dashbord[0]['avg_passenger_price']),
icon: Icons.monetization_on_outlined,
iconColor: Colors.green,
valueColor: Colors.green.shade700,
),
DashboardStatCard(
title: 'Completed Rides',
value: dashboardController.dashbord[0]
['completed_rides']
.toString(),
icon: Icons.check_circle_outline,
iconColor: AppColor.greenColor,
),
DashboardStatCard(
title: 'Cancelled Rides',
value: dashboardController.dashbord[0]
['cancelled_rides']
.toString(),
icon: Icons.cancel_outlined,
iconColor: AppColor.redColor,
),
DashboardStatCard(
title: 'Driver Payments',
value: _formatCurrency(
dashboardController.dashbord[0]['payments']),
icon: Icons.payments_outlined,
iconColor: Colors.indigoAccent,
valueColor: Colors.indigo.shade700,
),
DashboardStatCard(
title: 'Tripz Wallet',
value: _formatCurrency(dashboardController
.dashbord[0]['seferWallet']),
icon: Icons.account_balance_wallet_outlined,
iconColor: Colors.deepOrangeAccent,
valueColor: Colors.deepOrange.shade700,
),
DashboardStatCard(
title: 'Transfers Count',
value: dashboardController.dashbord[0]
['transfer_from_count']
.toString(),
icon: Icons.swap_horiz_outlined,
iconColor: Colors.brown,
),
DashboardStatCard(
title: 'Morning Rides',
value: dashboardController.dashbord[0]
['morning_ride_count']
.toString(),
icon: Icons.wb_sunny_outlined,
iconColor: Colors.amberAccent,
),
DashboardStatCard(
title: 'Evening Rides',
value: dashboardController.dashbord[0]
['evening_ride_count']
.toString(),
icon: Icons.brightness_4_outlined,
iconColor: Colors.blueGrey,
),
DashboardStatCard(
title: 'Night Rides',
value: dashboardController.dashbord[0]
['night_ride_count']
.toString(),
icon: Icons.nightlight_round_outlined,
iconColor: Colors.black54,
),
DashboardStatCard(
title: 'Comfort Type',
value: dashboardController.dashbord[0]['comfort']
.toString(),
icon: Icons.event_seat_outlined,
iconColor: Colors.cyan,
),
DashboardStatCard(
title: 'Speed Type',
value: dashboardController.dashbord[0]['speed']
.toString(),
icon: Icons.speed_outlined,
iconColor: Colors.red,
),
DashboardStatCard(
title: 'Lady Type',
value: dashboardController.dashbord[0]['lady']
.toString(),
icon: Icons.woman_2_outlined,
iconColor: Colors.pinkAccent,
),
],
),
),
// --- End of Statistics Grid Section ---
Get.to(() => const StaticDash());
},
),
AdminWidgetsDashBoard(
title: 'send Whatsapp to Drivers',
onPressed: () async {
Get.defaultDialog(
title: 'Are you sure to send by WhatsApp ?',
middleText: '',
confirm: MyElevatedButton(
title: 'Ok',
kolor: AppColor.greenColor,
onPressed: () async {
Log.print(
'CRUD().phoneDriversTest.: ${CRUD().phoneDriversTest}');
for (var phoneNumber
in CRUD().phoneDrivers) {
await CRUD().sendWhatsAppAuth(
phoneNumber.toString());
}
}),
cancel: MyElevatedButton(
title: 'cancel',
kolor: AppColor.redColor,
onPressed: () => Get.back()));
}),
AdminWidgetsDashBoard(
title: 'send notification Drivers',
onPressed: () async {
await Get.put(NotificationController())
.getTokensDrivers();
}),
AdminWidgetsDashBoard(
title: 'send SMS Drivers',
onPressed: () async {
Get.defaultDialog(
title: 'Are you sure to send SMS ?',
middleText: '',
content: Padding(
padding: const EdgeInsets.all(8.0),
child: Form(
key: dashboardController.formKey,
child: MyTextForm(
controller:
dashboardController.smsText,
label: 'label',
hint: 'hint',
type: TextInputType.name)),
),
confirm: MyElevatedButton(
title: 'Ok',
kolor: AppColor.greenColor,
onPressed: () async {
dashboardController.sendSMSMethod();
}),
cancel: MyElevatedButton(
title: 'cancel',
kolor: AppColor.redColor,
onPressed: () => Get.back()));
}),
AdminWidgetsDashBoard(
title: 'send notification Passengers',
onPressed: () async {
await Get.put(NotificationController())
.getTokensPassengers();
}),
AdminWidgetsDashBoard(
title: 'register captain'.tr,
// --- Your AdminWidgetsDashBoard items follow ---
AdminWidgetsDashBoard(
title: 'Passengers',
icon: Icons.people_outline,
onPressed: () => Get.to(() => Passengrs(),
transition: Transition.topLevel)),
AdminWidgetsDashBoard(
title: 'Captains',
icon: Icons.sports_motorsports_outlined,
onPressed: () => Get.to(() => Captain(),
transition: Transition.size)),
// ... (Add all your other AdminWidgetsDashBoard items here with icons)
AdminWidgetsDashBoard(
title: 'Wallet',
icon: Icons.account_balance_wallet_outlined,
onPressed: () => Get.to(() => Wallet(),
transition: Transition.fade)),
AdminWidgetsDashBoard(
title: 'Rides',
icon: Icons.directions_car_filled_outlined,
onPressed: () => Get.to(() => Rides(),
transition: Transition.downToUp)),
AdminWidgetsDashBoard(
title: 'Static',
icon: Icons.bar_chart_outlined,
onPressed: () async {
await Get.put(StaticController()).getAll();
Get.to(() => const StaticDash());
},
),
AdminWidgetsDashBoard(
title: 'send Whatsapp to Drivers',
icon: Icons.message_outlined,
iconColor: Colors.green,
onPressed: () async {
await Get.put(RegisterCaptainController())
.getDriverNotCompleteRegistration();
Get.to(() => const DriversCantRegister());
},
),
AdminWidgetsDashBoard(
title: 'update packages'.tr,
Get.defaultDialog(
title: 'Are you sure to send by WhatsApp ?',
middleText: '',
confirm: MyElevatedButton(
title: 'Ok',
kolor: AppColor.greenColor,
onPressed: () async {
Log.print(
'CRUD().phoneDriversTest.: ${CRUD().phoneDriversTest}');
for (var phoneNumber
in CRUD().phoneDrivers) {
await CRUD().sendWhatsAppAuth(
phoneNumber.toString());
}
}),
cancel: MyElevatedButton(
title: 'cancel',
kolor: AppColor.redColor,
onPressed: () => Get.back()));
}),
AdminWidgetsDashBoard(
title: 'send notification Drivers',
icon: Icons.notifications_active_outlined,
onPressed: () async {
Get.to(() => PackageUpdateScreen());
},
),
AdminWidgetsDashBoard(
title: 'Employee'.tr,
await Get.put(NotificationController())
.getTokensDrivers();
}),
AdminWidgetsDashBoard(
title: 'send SMS Drivers',
icon: Icons.sms_outlined,
onPressed: () async {
Get.to(() => EmployeePage());
},
),
AdminWidgetsDashBoard(
title: 'Drivers the best'.tr,
Get.defaultDialog(
title: 'Are you sure to send SMS ?',
middleText: '',
content: Padding(
padding: const EdgeInsets.all(8.0),
child: Form(
key: dashboardController.formKey,
child: MyTextForm(
controller:
dashboardController.smsText,
label: 'label',
hint: 'hint',
type: TextInputType.name)),
),
confirm: MyElevatedButton(
title: 'Ok',
kolor: AppColor.greenColor,
onPressed: () async {
dashboardController.sendSMSMethod();
}),
cancel: MyElevatedButton(
title: 'cancel',
kolor: AppColor.redColor,
onPressed: () => Get.back()));
}),
AdminWidgetsDashBoard(
title: 'send notification Passengers',
icon: Icons.notification_important_outlined,
onPressed: () async {
Get.to(() => DriverTheBest());
},
),
// AdminWidgetsDashBoard(
// title: 'Llama',
// onPressed: () =>
// CarRegistrationRecognizerController().scanText()),
AdminWidgetsDashBoard(
title: 'Add device to be Admin',
onPressed: () async {
// Map device = DeviceInfoPlus.deviceData;
await CRUD()
.post(link: AppLink.addAdminUser, payload: {
// 'deviceNumber': device['serialNumber'].toString(),
'name': 'b',
});
}),
],
),
);
})
],
isleading: false);
await Get.put(NotificationController())
.getTokensPassengers();
}),
AdminWidgetsDashBoard(
title: 'register captain'.tr,
icon: Icons.person_add_alt_1_outlined,
onPressed: () async {
await Get.put(RegisterCaptainController())
.getDriverNotCompleteRegistration();
Get.to(() => const DriversCantRegister());
},
),
AdminWidgetsDashBoard(
title: 'update packages'.tr,
icon: Icons.inventory_2_outlined,
onPressed: () async {
Get.to(() => PackageUpdateScreen());
},
),
AdminWidgetsDashBoard(
title: 'Employee'.tr,
icon: Icons.badge_outlined,
onPressed: () async {
Get.to(() => EmployeePage());
},
),
AdminWidgetsDashBoard(
title: 'Drivers the best'.tr,
icon: Icons.star_outline,
onPressed: () async {
Get.to(() => DriverTheBest());
},
),
AdminWidgetsDashBoard(
title: 'Add device to be Admin',
icon: Icons.admin_panel_settings_outlined,
onPressed: () async {
await CRUD()
.post(link: AppLink.addAdminUser, payload: {
'name': 'b',
});
}),
],
),
);
})
],
isleading: false,
);
}
}
@@ -463,25 +384,76 @@ class AdminWidgetsDashBoard extends StatelessWidget {
super.key,
required this.title,
required this.onPressed,
this.icon, // Optional icon
this.iconColor,
this.backgroundColor,
});
final String title;
final Callback onPressed;
final IconData? icon;
final Color? iconColor;
final Color? backgroundColor;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.symmetric(vertical: 6.0, horizontal: 12.0),
child: InkWell(
onTap: onPressed,
borderRadius:
BorderRadius.circular(12.0), // Rounded corners for tap effect
child: Container(
decoration: AppStyle.boxDecoration,
height: 50,
width: Get.width * .4,
child: Center(
child: Text(
title.tr,
style: AppStyle.title,
),
padding: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 16.0), // Increased padding
decoration: BoxDecoration(
color: backgroundColor ??
Theme.of(context).cardColor, // Use provided or theme card color
borderRadius: BorderRadius.circular(12.0),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.15),
spreadRadius: 1,
blurRadius: 8,
offset: const Offset(0, 2), // changes position of shadow
),
],
// If you want to use AppStyle.boxDecoration as a base and modify it:
// ...AppStyle.boxDecoration.copyWith(
// color: backgroundColor ?? AppStyle.boxDecoration.color,
// // Potentially override other properties of AppStyle.boxDecoration if needed
// ),
),
child: Row(
children: [
if (icon != null) ...[
Icon(
icon,
size: 28, // Slightly larger icon
color: iconColor ??
AppColor.primaryColor, // Use primary color or provided
),
const SizedBox(width: 16),
],
Expanded(
child: Text(
title.tr,
style: AppStyle.title.copyWith(
fontSize: 16, // Adjust font size for better readability
fontWeight: FontWeight.w500, // Medium weight
color: Theme.of(context)
.textTheme
.bodyLarge
?.color, // Use theme text color
),
),
),
const Icon(
Icons.arrow_forward_ios,
size: 18,
color: Colors.grey, // Subtle indicator for navigation
),
],
),
),
),

View File

@@ -4,6 +4,7 @@ import 'package:get/get.dart';
import '../../../constant/colors.dart';
import '../../../constant/style.dart';
import '../../../controller/admin/captain_admin_controller.dart';
import '../../../controller/functions/encrypt_decrypt.dart';
import '../../widgets/elevated_btn.dart';
import '../../widgets/my_scafold.dart';
import '../../widgets/my_textField.dart';
@@ -153,7 +154,7 @@ class Captain extends StatelessWidget {
.spaceBetween,
children: [
Text(
'Name : ${user['first_name']} ${user['last_name']}',
'Name : ${(user['first_name'])} ${(user['last_name'])}',
style: AppStyle.title,
),
Text(

View File

@@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart'; // For Get.width if needed, and .tr
import 'package:sefer_admin1/constant/colors.dart'; // Assuming AppColor is here
import 'package:sefer_admin1/constant/style.dart'; // Assuming AppStyle is here
class DashboardStatCard extends StatelessWidget {
final String title;
final String value;
final IconData? icon;
final Color? iconColor;
final Color? backgroundColor;
final Color? valueColor;
const DashboardStatCard({
Key? key,
required this.title,
required this.value,
this.icon,
this.iconColor,
this.backgroundColor,
this.valueColor,
}) : super(key: key);
@override
Widget build(BuildContext context) {
// Attempt to use AppStyle.boxDecoration1 properties if it's a BoxDecoration
BoxDecoration? baseDecoration = AppStyle.boxDecoration1;
Color? finalBackgroundColor =
backgroundColor ?? baseDecoration?.color ?? Theme.of(context).cardColor;
BorderRadius? finalBorderRadius =
baseDecoration?.borderRadius?.resolve(Directionality.of(context)) ??
BorderRadius.circular(12.0);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 12.0),
decoration: BoxDecoration(
color: finalBackgroundColor,
borderRadius: finalBorderRadius,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
spreadRadius: 1,
blurRadius: 6,
offset: const Offset(0, 2),
),
],
// If AppStyle.boxDecoration1 includes a border, you might want to add it here too
// border: baseDecoration?.border,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center, // Center content vertically
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Text(
title.tr,
style: AppStyle.title.copyWith(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme.bodySmall?.color,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
if (icon != null)
Icon(
icon,
size: 24,
color: iconColor ?? AppColor.primaryColor.withOpacity(0.7),
),
],
),
const SizedBox(height: 6),
Text(
value,
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: valueColor ?? AppColor.primaryColor,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
);
}
}

View File

@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_admin1/constant/links.dart';
import 'package:sefer_admin1/controller/functions/crud.dart';
import 'package:sefer_admin1/controller/functions/wallet.dart';
import 'package:sefer_admin1/views/widgets/my_scafold.dart';
import '../../../controller/drivers/driverthebest.dart';
class DriverTheBestAlexandria extends StatelessWidget {
const DriverTheBestAlexandria({super.key});
@override
Widget build(BuildContext context) {
Get.put(DriverTheBestAlexandriaController(), permanent: true);
return MyScafolld(
title: 'Alexandria'.tr,
body: [
GetBuilder<DriverTheBestAlexandriaController>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
((driver['driver_count'] * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text(driver['name_arabic'] ?? 'Unknown Name'),
subtitle: Text('Phone: ${driver['phone'] ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'.tr,
middleText: '',
onConfirm: () async {
final wallet = Get.put(WalletController());
await wallet.addPaymentToDriver('100',
driver['id'].toString(), driver['token']);
await wallet.addSeferWallet(
'100', driver['id'].toString());
await CRUD().post(
link: AppLink.deleteRecord,
payload: {
'driver_id': driver['id'].toString()
});
driverthebest.driver.removeAt(index);
driverthebest.update();
},
onCancel: () => Get.back());
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
)
: const Center(
child: Text('No drivers available.'),
);
})
],
isleading: true,
);
}
}

View File

@@ -1,54 +1,96 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_admin1/constant/links.dart';
import 'package:sefer_admin1/controller/functions/crud.dart';
import 'package:sefer_admin1/controller/functions/encrypt_decrypt.dart';
import 'package:sefer_admin1/controller/functions/wallet.dart';
import 'package:sefer_admin1/views/admin/wallet/wallet.dart';
import 'package:sefer_admin1/views/widgets/elevated_btn.dart';
import 'package:sefer_admin1/views/widgets/my_scafold.dart';
import '../../../controller/drivers/driverthebest.dart';
import 'alexandria.dart';
import 'giza.dart';
class DriverTheBest extends StatelessWidget {
const DriverTheBest({super.key});
@override
Widget build(BuildContext context) {
Get.put(Driverthebest());
Get.put(Driverthebest(), permanent: true);
return MyScafolld(
title: 'Best Drivers'.tr,
body: [
GetBuilder<Driverthebest>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
((driver['driver_count'] * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text(driver['name_arabic'] ?? 'Unknown Name'),
subtitle: Text('Phone: ${driver['phone'] ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'.tr,
middleText: '',
onConfirm: () async {
final wallet = Get.put(WalletController());
await wallet.addPaymentToDriver('200',
driver['id'].toString(), driver['token']);
await wallet.addSeferWallet(
'200', driver['id'].toString());
? Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyElevatedButton(
title: 'Giza',
onPressed: () {
Get.to(() => DriverTheBestGiza());
}),
MyElevatedButton(
title: 'Alexandria',
onPressed: () {
Get.to(() => DriverTheBestAlexandria());
}),
],
),
SizedBox(
height: Get.height * .7,
child: ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
(int.parse(driver['driver_count']) * 5 / 3600)
.toStringAsFixed(
0), // Perform division first, then convert to string
),
),
title:
Text((driver['name_arabic']) ?? 'Unknown Name'),
subtitle:
Text('Phone: ${(driver['phone']) ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'
.tr,
middleText: '',
onConfirm: () async {
final wallet =
Get.put(WalletController());
await wallet.addPaymentToDriver(
'200',
driver['id'].toString(),
driver['token']);
await wallet.addSeferWallet(
'200', driver['id'].toString());
await CRUD().post(
link: AppLink.deleteRecord,
payload: {
'driver_id': driver['id'].toString()
});
driverthebest.driver.removeAt(index);
driverthebest.update();
Get.back();
},
onCancel: () => Get.back());
},
onCancel: () => Get.back());
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
),
],
)
: const Center(
child: Text('No drivers available.'),

View File

@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_admin1/constant/links.dart';
import 'package:sefer_admin1/controller/functions/crud.dart';
import 'package:sefer_admin1/controller/functions/wallet.dart';
import 'package:sefer_admin1/views/widgets/my_scafold.dart';
import '../../../controller/drivers/driverthebest.dart';
class DriverTheBestGiza extends StatelessWidget {
const DriverTheBestGiza({super.key});
@override
Widget build(BuildContext context) {
Get.put(DriverTheBestGizaController(), permanent: true);
return MyScafolld(
title: 'Giza'.tr,
body: [
GetBuilder<DriverTheBestGizaController>(builder: (driverthebest) {
return driverthebest.driver.isNotEmpty
? ListView.builder(
itemCount: driverthebest.driver.length,
itemBuilder: (context, index) {
final driver = driverthebest.driver[index];
return ListTile(
leading: CircleAvatar(
child: Text(
((driver['driver_count'] * 5) / 3600)
.toStringAsFixed(0),
),
),
title: Text(driver['name_arabic'] ?? 'Unknown Name'),
subtitle: Text('Phone: ${driver['phone'] ?? 'N/A'}'),
trailing: IconButton(
onPressed: () async {
Get.defaultDialog(
title:
'are you sure to pay to this driver gift'.tr,
middleText: '',
onConfirm: () async {
final wallet = Get.put(WalletController());
await wallet.addPaymentToDriver('100',
driver['id'].toString(), driver['token']);
await wallet.addSeferWallet(
'100', driver['id'].toString());
await CRUD().post(
link: AppLink.deleteRecord,
payload: {
'driver_id': driver['id'].toString()
});
driverthebest.driver.removeAt(index);
driverthebest.update();
},
onCancel: () => Get.back());
},
icon: const Icon(Icons.wallet_giftcard_rounded),
),
);
},
)
: const Center(
child: Text('No drivers available.'),
);
})
],
isleading: true,
);
}
}

View File

@@ -165,7 +165,8 @@ class EmployeeDetails extends StatelessWidget {
height: 200,
width: 400,
child: Image.network(
'https://sefer.click/sefer/card_image/idFrontEmployee-${employeeController.employee[index]['id']}.jpg'),
// https: //server.sefer.click/sefer.click/sefer/card_image/idFrontEmployee-GC15188P.jpg
'https://server.sefer.click/sefer.click/sefer/card_image/idFrontEmployee-${employeeController.employee[index]['id']}.jpg'),
),
const SizedBox(
height: 10,
@@ -174,7 +175,7 @@ class EmployeeDetails extends StatelessWidget {
height: 200,
width: 400,
child: Image.network(
'https://sefer.click/sefer/card_image/idFrontEmployee-${employeeController.employee[index]['id']}.jpg'),
'https://server.sefer.click/sefer.click/sefer/card_image/idFrontEmployee-${employeeController.employee[index]['id']}.jpg'),
)
],
);

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sefer_admin1/controller/functions/encrypt_decrypt.dart';
import '../../../constant/style.dart';
import '../../../controller/admin/passenger_admin_controller.dart';
@@ -136,7 +137,7 @@ class Passengrs extends StatelessWidget {
.spaceBetween,
children: [
Text(
'Name : ${user['first_name']} ${user['last_name']}',
'Name : ${(user['first_name'])} ${(user['last_name'])}',
style: AppStyle.title,
),
Text(