first commit

This commit is contained in:
Hamza-Ayed
2025-07-30 10:24:53 +03:00
parent 0945095398
commit 0b17f93aaa
244 changed files with 40043 additions and 0 deletions

116
lib/models/db_sql.dart Normal file
View File

@@ -0,0 +1,116 @@
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import '../constant/table_names.dart';
class DbSql {
static final DbSql instance = DbSql._();
static Database? _database;
DbSql._();
Future<Database> get database async {
if (_database != null) return _database!;
_database = await _initDatabase();
return _database!;
}
Future<Database> _initDatabase() async {
String path = join(await getDatabasesPath(), 'my_database.db');
return await openDatabase(
path,
version: 1,
onCreate: (db, version) async {
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.carLocations}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
driver_id TEXT,
latitude REAL,
longitude REAL,
created_at TEXT,
updated_at TEXT
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.placesFavorite}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
latitude REAL,
longitude REAL,
name TEXT UNIQUE,
rate TEXT
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.recentLocations}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
latitude REAL,
longitude REAL,
name TEXT ,
rate TEXT
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.driverOrdersRefuse}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
order_id TEXT UNIQUE,
created_at TEXT,
driver_id TEXT
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.rideLocation}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
order_id TEXT ,
created_at TEXT,
lat TEXT,
lng TEXT
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.faceDetectTimes}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
faceDetectTimes INTEGER
)
''');
await db.execute('''
CREATE TABLE IF NOT EXISTS ${TableName.captainNotification}(
id INTEGER PRIMARY KEY AUTOINCREMENT,
faceDetectTimes INTEGER
)
''');
},
);
}
Future<List<Map<String, dynamic>>> getAllData(String table) async {
Database db = await instance.database;
return await db.query(table);
}
Future<List<Map<String, dynamic>>> getCustomQuery(String query) async {
Database db = await instance.database;
return await db.rawQuery(query);
}
Future<int> insertData(Map<String, dynamic> map, String table) async {
Database db = await instance.database;
return await db.insert(table, map);
}
Future<int> updateData(Map<String, dynamic> map, String table, int id) async {
Database db = await instance.database;
return await db.update(table, map, where: 'id = ?', whereArgs: [id]);
}
Future<int> deleteData(String table, int id) async {
Database db = await instance.database;
return await db.delete(table, where: 'id = ?', whereArgs: [id]);
}
Future<int> deleteAllData(String table) async {
Database db = await instance.database;
return await db.delete(table);
}
}

View File

@@ -0,0 +1,40 @@
-- Frequent Complaint Passengers
SELECT
passengers.id AS passenger_id,
passengers.first_name,
passengers.last_name,
passengers.phone,
COUNT(`feedBack`.id) AS complaint_count
FROM
passengers
JOIN `feedBack` ON passengers.id = `feedBack`.`passengerId`
GROUP BY
passengers.id
ORDER BY
complaint_count
DESC
LIMIT 10;
--==========
-- to get all driver payment to pay to them
SELECT
p.driverID,
COALESCE(SUM(p.amount), 0) AS total_amount,
COALESCE(SUM(p.amount), 0) + COALESCE(pd.total_points, 0) AS diff
FROM
payments p
JOIN (
SELECT
driverID,
SUM(amount) AS total_points
FROM
paymentsDriverPoints
WHERE
payment_method = 'fromBudgetToPoints'
GROUP BY
driverID
) pd ON p.driverID = pd.driverID
WHERE
p.isGiven = 'waiting'
AND p.payment_method IN ('visa-in', 'visa', 'visaRide', 'TransferFrom', 'payout', 'TransferTo')
GROUP BY
p.driverID;

View File

@@ -0,0 +1,21 @@
class MonthlyDataModel {
final int year;
final int month;
final int day;
final int ridesCount;
MonthlyDataModel({
required this.year,
required this.month,
required this.day,
required this.ridesCount,
});
factory MonthlyDataModel.fromJson(Map<String, dynamic> json) =>
MonthlyDataModel(
year: json['year'] as int,
month: json['month'] as int,
day: json['day'] as int,
ridesCount: json['rides_count'] as int,
);
}

View File

@@ -0,0 +1,79 @@
class Passenger {
String id;
String phone;
String email;
String gender;
String status;
String birthdate;
String site;
String firstName;
String lastName;
String sosPhone;
String education;
String employmentType;
String maritalStatus;
String createdAt;
String updatedAt;
int countPassenger;
int countFeedback;
double ratingPassenger;
int countDriverRate;
int countPassengerCancel;
double passengerAverageRating;
int countPassengerRate;
int countPassengerRide;
Passenger({
required this.id,
required this.phone,
required this.email,
required this.gender,
required this.status,
required this.birthdate,
required this.site,
required this.firstName,
required this.lastName,
required this.sosPhone,
required this.education,
required this.employmentType,
required this.maritalStatus,
required this.createdAt,
required this.updatedAt,
required this.countPassenger,
required this.countFeedback,
required this.ratingPassenger,
required this.countDriverRate,
required this.countPassengerCancel,
required this.passengerAverageRating,
required this.countPassengerRate,
required this.countPassengerRide,
});
factory Passenger.fromJson(Map<String, dynamic> json) {
return Passenger(
id: json['id'],
phone: json['phone'],
email: json['email'],
gender: json['gender'],
status: json['status'],
birthdate: json['birthdate'],
site: json['site'],
firstName: json['first_name'],
lastName: json['last_name'],
sosPhone: json['sosPhone'],
education: json['education'],
employmentType: json['employmentType'],
maritalStatus: json['maritalStatus'],
createdAt: json['created_at'],
updatedAt: json['updated_at'],
countPassenger: json['countPassenger'],
countFeedback: json['countFeedback'],
ratingPassenger: json['ratingPassenger'].toDouble(),
countDriverRate: json['countDriverRate'],
countPassengerCancel: json['countPassengerCancel'],
passengerAverageRating: json['passengerAverageRating'].toDouble(),
countPassengerRate: json['countPassengerRate'],
countPassengerRide: json['countPassengerRide'],
);
}
}

View File

@@ -0,0 +1,12 @@
class MonthlyDataModel {
int day;
int totalDuration;
MonthlyDataModel({required this.day, required this.totalDuration});
factory MonthlyDataModel.fromJson(Map<String, dynamic> json) =>
MonthlyDataModel(
day: int.parse(json['day'].toString().split('-')[2]),
totalDuration:
int.parse(json['total_duration'].toString().split(':')[0]));
}

View File

@@ -0,0 +1,34 @@
class CarLocationModel {
String id;
String driverId;
double latitude;
double heading;
double speed;
double longitude;
DateTime createdAt;
DateTime updatedAt;
CarLocationModel({
required this.id,
required this.driverId,
required this.latitude,
required this.longitude,
required this.heading,
required this.speed,
required this.createdAt,
required this.updatedAt,
});
factory CarLocationModel.fromJson(Map<String, dynamic> json) {
return CarLocationModel(
id: json['id'],
driverId: json['driver_id'],
latitude: double.parse(json['latitude'].toString()),
longitude: double.parse(json['longitude'].toString()),
heading: double.parse(json['heading'].toString()),
speed: double.parse(json['speed'].toString()),
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
);
}
}

View File

@@ -0,0 +1,30 @@
import 'package:get/get.dart';
List<OnBoardingModel> onBoardingList = [
OnBoardingModel(
title: 'Welcome to Sefer!'.tr,
image: 'assets/images/on1.png',
body:
'Sefer is the ride-hailing app that is safe, reliable, and accessible.'
.tr,
),
OnBoardingModel(
title: 'Get to your destination quickly and easily.'.tr,
image: 'assets/images/on2.png',
body: 'With Sefer, you can get a ride to your destination in minutes.'.tr,
),
OnBoardingModel(
title: 'Enjoy a safe and comfortable ride.'.tr,
image: 'assets/images/on3.png',
body:
'Sefer is committed to safety, and all of our captains are carefully screened and background checked.'
.tr,
),
];
class OnBoardingModel {
final String? title;
final String? image;
final String? body;
OnBoardingModel({this.body, this.title, this.image});
}

View File

@@ -0,0 +1,77 @@
class MonthlyPassengerInstall {
int day;
int totalPassengers;
MonthlyPassengerInstall({required this.day, required this.totalPassengers});
factory MonthlyPassengerInstall.fromJson(Map<String, dynamic> json) =>
MonthlyPassengerInstall(
day: int.parse(json['day'].toString().split('-')[2]),
totalPassengers:
int.parse(json['totalPassengers'].toString().split(':')[0]));
}
class MonthlyRidesInstall {
int day;
int totalRides;
MonthlyRidesInstall({required this.day, required this.totalRides});
factory MonthlyRidesInstall.fromJson(Map<String, dynamic> json) =>
MonthlyRidesInstall(
day: int.parse(json['day'].toString().split('-')[2]),
totalRides: int.parse(json['totalRides'].toString().split(':')[0]));
}
class MonthlyEmployeeData {
int day;
int totalEmployees;
String name;
MonthlyEmployeeData(
{required this.day, required this.totalEmployees, required this.name});
factory MonthlyEmployeeData.fromJson(Map<String, dynamic> json) =>
MonthlyEmployeeData(
day: int.parse(json['date'].toString().split('-')[2]), // Extract day
totalEmployees: json['count'],
name: json['NAME'],
);
}
class MonthlyDriverInstall {
int day;
int totalDrivers;
int dailyTotalDrivers;
int dailyTotalCallingDrivers;
int dailyMatchingNotes;
int totalMonthlyDrivers;
int totalMonthlyCallingDrivers;
int totalMonthlyMatchingNotes;
MonthlyDriverInstall({
required this.day,
required this.totalDrivers,
required this.dailyTotalDrivers,
required this.dailyTotalCallingDrivers,
required this.dailyMatchingNotes,
required this.totalMonthlyDrivers,
required this.totalMonthlyCallingDrivers,
required this.totalMonthlyMatchingNotes,
});
factory MonthlyDriverInstall.fromJson(Map<String, dynamic> json) =>
MonthlyDriverInstall(
day: int.parse(json['day'].toString().split('-')[2]),
totalDrivers: int.parse(json['totalDrivers'].toString()),
dailyTotalDrivers: int.parse(json['dailyTotalDrivers'].toString()),
dailyTotalCallingDrivers:
int.parse(json['dailyTotalCallingDrivers'].toString()),
dailyMatchingNotes: int.parse(json['dailyMatchingNotes'].toString()),
totalMonthlyDrivers: int.parse(json['totalMonthlyDrivers'].toString()),
totalMonthlyCallingDrivers:
int.parse(json['totalMonthlyCallingDrivers'].toString()),
totalMonthlyMatchingNotes:
int.parse(json['totalMonthlyMatchingNotes'].toString()),
);
}