Initial commit with updated Auth and media ignored

This commit is contained in:
Hamza-Ayed
2026-04-28 13:04:27 +03:00
commit 67af97474c
477 changed files with 66444 additions and 0 deletions

101
serviceapp/addCartoDriver.php Executable file
View File

@@ -0,0 +1,101 @@
<?php
require_once __DIR__ . '/../connect.php';
// Fetch and validate each parameter
$driverID = filterRequest("driverID");
$vin = $encryptionHelper->encryptData(filterRequest("vin"));
$carPlate = $encryptionHelper->encryptData(filterRequest("car_plate"));
$make = filterRequest("make");
$model = filterRequest("model");
$year = filterRequest("year");
$expirationDate = filterRequest("expiration_date");
$color = filterRequest("color");
$owner = $encryptionHelper->encryptData(filterRequest("owner"));
$colorHex = filterRequest("color_hex");
$address = $encryptionHelper->encryptData(filterRequest("address"));
$displacement = filterRequest("displacement");
$fuel = filterRequest("fuel");
$registrationDate = filterRequest("registration_date");
// تحقق من الحقول المطلوبة
if (
is_null($driverID) || is_null($vin) || is_null($carPlate) ||
is_null($make) || is_null($model) || is_null($year) ||
is_null($expirationDate) || is_null($color) || is_null($owner) ||
is_null($colorHex) || is_null($address) || is_null($displacement) ||
is_null($fuel) || is_null($registrationDate)
) {
jsonError("One or more required parameters are missing.");
exit();
}
$con->beginTransaction();
try {
$checkSql = "SELECT * FROM `CarRegistration` WHERE `driverID` = :driverID";
$checkStmt = $con->prepare($checkSql);
$checkStmt->bindParam(':driverID', $driverID);
$checkStmt->execute();
if ($checkStmt->rowCount() > 0) {
jsonError("Car has already been registered for this driver.");
exit();
}
// إدخال السيارة
$sqlInsert = "INSERT INTO `CarRegistration` (
`driverID`, `vin`, `car_plate`, `make`, `model`, `year`, `expiration_date`,
`color`, `owner`, `color_hex`, `address`, `displacement`, `fuel`, `registration_date`
) VALUES (
:driverID, :vin, :carPlate, :make, :model, :year, :expirationDate,
:color, :owner, :colorHex, :address, :displacement, :fuel, :registrationDate
)";
$stmtInsert = $con->prepare($sqlInsert);
$stmtInsert->bindParam(':driverID', $driverID);
$stmtInsert->bindParam(':vin', $vin);
$stmtInsert->bindParam(':carPlate', $carPlate);
$stmtInsert->bindParam(':make', $make);
$stmtInsert->bindParam(':model', $model);
$stmtInsert->bindParam(':year', $year);
$stmtInsert->bindParam(':expirationDate', $expirationDate);
$stmtInsert->bindParam(':color', $color);
$stmtInsert->bindParam(':owner', $owner);
$stmtInsert->bindParam(':colorHex', $colorHex);
$stmtInsert->bindParam(':address', $address);
$stmtInsert->bindParam(':displacement', $displacement);
$stmtInsert->bindParam(':fuel', $fuel);
$stmtInsert->bindParam(':registrationDate', $registrationDate);
$stmtInsert->execute();
if ($stmtInsert->rowCount() > 0) {
// سجل في carPlateEdit
$sqlLog = "INSERT INTO `carPlateEdit`
(`driverId`, `carPlate`, `color`, `make`, `model`, `expiration_date`, `owner`, `year`, `isEdit`)
VALUES (:driverID, :carPlate, :color, :make, :model, :expirationDate, :owner, :year, 0)";
$stmtLog = $con->prepare($sqlLog);
$stmtLog->bindParam(':driverID', $driverID);
$stmtLog->bindParam(':carPlate', $carPlate);
$stmtLog->bindParam(':color', $color);
$stmtLog->bindParam(':make', $make);
$stmtLog->bindParam(':model', $model);
$stmtLog->bindParam(':expirationDate', $expirationDate);
$stmtLog->bindParam(':owner', $owner);
$stmtLog->bindParam(':year', $year);
$stmtLog->execute();
$con->commit();
jsonSuccess(null, "Car registration data saved and logged successfully");
} else {
$con->rollBack();
jsonError("Failed to save car registration data");
}
} catch (Exception $e) {
$con->rollBack();
jsonError("An error occurred: " . $e->getMessage());
}
?>

View File

@@ -0,0 +1,40 @@
<?php
require_once __DIR__ . '/../connect.php';
// Retrieve and sanitize input parameters
$phone = filterRequest("phone");
$note = filterRequest("note");
$editor = filterRequest("editor");
// Encrypt the phone number
$encryptedPhone = $encryptionHelper->encryptData($phone);
// SQL query: insert new row OR update existing one if phone already exists
$sql = "INSERT INTO `notesForDriverService` (`phone`, `note`, `editor`)
VALUES (:phone, :note, :editor)
ON DUPLICATE KEY UPDATE
`note` = VALUES(`note`),
`editor` = VALUES(`editor`)";
// Prepare the SQL statement
$stmt = $con->prepare($sql);
// Bind the parameters
$stmt->bindParam(':phone', $encryptedPhone);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':editor', $editor);
// Execute the query
$success = $stmt->execute();
if ($success) {
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Note inserted/updated successfully");
} else {
jsonError("No changes were made");
}
} else {
jsonError("Database error");
}
?>

View File

@@ -0,0 +1,31 @@
<?php
require_once __DIR__ . '/../connect.php';
// Retrieve and sanitize input parameters
$phone = filterRequest("phone");
$note = filterRequest("note");
$editor = filterRequest("editor");
// Encrypt phone before storing
$encryptedPhone = $encryptionHelper->encryptData($phone);
// SQL query to insert into notesForPassengerService
$sql = "INSERT INTO `notesForPassengerService` (`phone`, `note`, `editor`)
VALUES (:phone, :note, :editor)";
// Prepare the statement
$stmt = $con->prepare($sql);
$stmt->bindParam(':phone', $encryptedPhone);
$stmt->bindParam(':note', $note);
$stmt->bindParam(':editor', $editor);
// Execute and respond
$stmt->execute();
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Note inserted successfully");
} else {
jsonError("Failed to insert note");
}
?>

View File

@@ -0,0 +1,33 @@
<?php
require_once __DIR__ . '/../connect.php';
// Sanitize and retrieve input parameters
$driverId = filterRequest("driverId");
$notes = filterRequest("notes");
// SQL: Insert or Update if already exists
$sql = "INSERT INTO `welcomeDriverCall` (`driverId`, `isCall`, `notes`)
VALUES (:driverId, '1', :notes)
ON DUPLICATE KEY UPDATE
`isCall` = '1',
`notes` = VALUES(`notes`),
`createdAt` = NOW()";
// Prepare the statement
$stmt = $con->prepare($sql);
// Bind parameters
$stmt->bindParam(':driverId', $driverId);
$stmt->bindParam(':notes', $notes);
// Execute the statement
$success = $stmt->execute();
if ($success) {
jsonSuccess(null, "Record inserted/updated successfully");
} else {
jsonError("Failed to insert or update record");
}
?>

View File

@@ -0,0 +1,35 @@
<?php
require_once __DIR__ . '/../connect.php';
// 1. استقبال رقم الهاتف القادم من التطبيق
$phone = filterRequest("phone");
// التحقق من أن الهاتف ليس فارغاً
if ($phone == null) {
jsonError("Phone number is empty");
exit();
}
$phone = $encryptionHelper->encryptData($phone);
// 2. تنفيذ الحذف بشرط تطابق الهاتف وأن الحالة 'yet'
$sql = "DELETE FROM driver
WHERE phone = ?
AND employmentType = 'yet'";
$stmt = $con->prepare($sql);
$stmt->execute(array($phone));
$count = $stmt->rowCount();
if ($count > 0) {
// 3. إرسال رد النجاح ليتم عرضه في التطبيق (Get.snackbar)
jsonSuccess(null, "Driver deleted successfully");
} else {
// إرسال رد فشل (إذا لم يتم العثور على الرقم أو كان السائق مكتملاً)
jsonError("Driver not found or already active");
}
?>

View File

@@ -0,0 +1,34 @@
<?php
require_once __DIR__ . '/../connect.php';
// استعلام للحصول على السائقين الذين لديهم ملاحظات في نفس الشهر الحالي
$sql = "
SELECT
d.id AS driver_id,
d.first_name,
d.last_name,
d.phone,
d.created_at,
n.note,
n.editor,
n.created_at AS note_created_at
FROM
driver d
LEFT JOIN notesForDriverService n ON n.phone = d.phone
WHERE
MONTH(d.created_at) = MONTH(CURRENT_DATE())
AND n.phone IS NOT NULL
ORDER BY
d.created_at DESC
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
jsonSuccess($row);
} else {
jsonError("No driver records found with notes this month.");
}
?>

723
serviceapp/drivers_list.txt Normal file
View File

@@ -0,0 +1,723 @@
Phone: 963995473295 | Note: No Note
Phone: 963932997741 | Note: No Note
Phone: 963946792550 | Note: No Note
Phone: | Note: لا يوجد رقم
Phone: 963930124895 | Note: No Note
Phone: 963932845375 | Note: No Note
Phone: 9630937563437 | Note: No Note
Phone: 963937563437 | Note: No Note
Phone: 963933014381 | Note: No Note
Phone: 963940740211 | Note: No Note
Phone: 963997731147 | Note: No Note
Phone: 9630982494498 | Note: No Note
Phone: 963982494498 | Note: No Note
Phone: 963936780435 | Note: No Note
Phone: 963932894042 | Note: No Note
Phone: 963955609157 | Note: No Note
Phone: 963943433943 | Note: No Note
Phone: 963934020587 | Note: No Note
Phone: 963991486923 | Note: No Note
Phone: 963930246282 | Note: No Note
Phone: 963936388893 | Note: No Note
Phone: 963965444917 | Note: No Note
Phone: 963968622928 | Note: No Note
Phone: 963941588818 | Note: No Note
Phone: 9630941588818 | Note: No Note
Phone: 963998557963 | Note: No Note
Phone: 963995737121 | Note: ماعندو واتس وخطو مسكر
Phone: 963996673522 | Note: No Note
Phone: 963992159193 | Note: No Note
Phone: 963933231038 | Note: No Note
Phone: 963990320212 | Note: تم
Phone: 963991918177 | Note: No Note
Phone: 963962293692 | Note: No Note
Phone: 963980043065 | Note: No Note
Phone: 963933665775 | Note: No Note
Phone: 963997678811 | Note: No Note
Phone: 963935541277 | Note: No Note
Phone: 963937173449 | Note: تم
Phone: 963998235145 | Note: No Note
Phone: 963991514602 | Note: No Note
Phone: 963993725589 | Note: No Note
Phone: 963939761870 | Note: No Note
Phone: 963956825657 | Note: No Note
Phone: 963933642491 | Note: No Note
Phone: 963956906783 | Note: No Note
Phone: 9630956906783 | Note: No Note
Phone: 9630936984029 | Note: No Note
Phone: 963941418151 | Note: No Note
Phone: 9630941418151 | Note: No Note
Phone: 963981237272 | Note: No Note
Phone: 963933897890 | Note: No Note
Phone: 963944344937 | Note: No Note
Phone: 963993828902 | Note: No Note
Phone: 963933659200 | Note: No Note
Phone: 963955414963 | Note: No Note
Phone: 963942024560 | Note: No Note
Phone: 9639494022840 | Note: No Note
Phone: 9639639362485 | Note: No Note
Phone: 963965833448 | Note: مشغول
Phone: 9630930291349 | Note: بدو يفعل
Phone: 963945267161 | Note: تم
Phone: 9630934627741 | Note: No Note
Phone: 963934627741 | Note: No Note
Phone: 963935777840 | Note: No Note
Phone: 963994436621 | Note: No Note
Phone: 963940031237 | Note: No Note
Phone: 963957833531 | Note: No Note
Phone: 963943949925 | Note: No Note
Phone: 963953263161 | Note: ما برن
Phone: 963980486635 | Note: No Note
Phone: 963٩٩٢٩٩٩٠٨٣ | Note: No Note
Phone: 963950505715 | Note: No Note
Phone: 963934443912 | Note: كان بدو يشتري سيارة وفقست بس يكفي رح يسجل
Phone: 963945452222 | Note: رح يكفي تسجيل
Phone: 963948899644 | Note: No Note
Phone: 963937525133 | Note: رح يكفي تسجيل
Phone: 963934441423 | Note: No Note
Phone: 963968044972 | Note: تم التواصل
Phone: 963984137014 | Note: مابدو
Phone: 963796377987 | Note: No Note
Phone: 963988455623 | Note: No Note
Phone: 9630939386057 | Note: No Note
Phone: 963939386057 | Note: No Note
Phone: 963966880940 | Note: تم
Phone: 963932928765 | Note: تم
Phone: 963993641405 | Note: تم
Phone: 963933027735 | Note: No Note
Phone: 963933433725 | Note: تم
Phone: 963988870417 | Note: تم
Phone: 963951670237 | Note: تم
Phone: 963930795196 | Note: تم
Phone: 963991960766 | Note: تم
Phone: 963935998441 | Note: تم
Phone: 963947938918 | Note: تم
Phone: 963992435599 | Note: تم
Phone: 963954364865 | Note: تم
Phone: 963995438666 | Note: تم
Phone: 963991420279 | Note: تم
Phone: 963933969836 | Note: تم
Phone: 963095874505 | Note: الرقم خطأ
Phone: 963933586167 | Note: تم
Phone: 963997791974 | Note: تم
Phone: 963938092584 | Note: تم
Phone: 963936412209 | Note: تم
Phone: 963993998201 | Note: تم
Phone: 963954845028 | Note: No Note
Phone: 963985472276 | Note: No Note
Phone: 963983727779 | Note: تم
Phone: 963935005982 | Note: تم
Phone: 963996095507 | Note: No Note
Phone: 963993952009 | Note: تم
Phone: 9630993952009 | Note: No Note
Phone: 963940056304 | Note: تم
Phone: 963995797246 | Note: تم
Phone: 963993492062 | Note: No Note
Phone: 963988493310 | Note: تم
Phone: 971567312720 | Note: No Note
Phone: 963991748590 | Note: تم
Phone: 963996807389 | Note: تم
Phone: 963933624099 | Note: تم
Phone: 963981997355 | Note: تم
Phone: 9630983758855 | Note: تم
Phone: 963986198636 | Note: No Note
Phone: 963932392061 | Note: No Note
Phone: 963944087759 | Note: No Note
Phone: 9630944087759 | Note: No Note
Phone: 963996489269 | Note: No Note
Phone: 963956465908 | Note: No Note
Phone: 963937829076 | Note: No Note
Phone: 963952398851 | Note: No Note
Phone: 963947785627 | Note: No Note
Phone: 963944725825 | Note: No Note
Phone: 963985041549 | Note: No Note
Phone: 963992485425 | Note: No Note
Phone: 963990462939 | Note: No Note
Phone: 963997451873 | Note: No Note
Phone: 9630992952235 | Note: No Note
Phone: 963991543059 | Note: No Note
Phone: 963938800414 | Note: No Note
Phone: 963955915110 | Note: No Note
Phone: 963933436896 | Note: No Note
Phone: 963962203899 | Note: No Note
Phone: 963980561370 | Note: No Note
Phone: 963938449446 | Note: No Note
Phone: 963933989564 | Note: No Note
Phone: 963952726606 | Note: No Note
Phone: 963954152143 | Note: No Note
Phone: 963095272660 | Note: No Note
Phone: 963985131776 | Note: No Note
Phone: 963093184436 | Note: No Note
Phone: 963933751093 | Note: No Note
Phone: 963937475542 | Note: No Note
Phone: 963944619801 | Note: No Note
Phone: 963994776559 | Note: No Note
Phone: 963931802363 | Note: No Note
Phone: 963986312807 | Note: No Note
Phone: 963933502898 | Note: No Note
Phone: 963992667679 | Note: No Note
Phone: 963988514496 | Note: No Note
Phone: 963954251613 | Note: No Note
Phone: 963955630089 | Note: No Note
Phone: 963096491319 | Note: رقم غلط
Phone: 963999352010 | Note: تم
Phone: 963997823542 | Note: No Note
Phone: 963935561540 | Note: No Note
Phone: 963991907984 | Note: تم التواصل
Phone: 963963992952 | Note: غير موضوع بالخدمة
Phone: 919154792561 | Note: غلط
Phone: 963095371707 | Note: غير صحيح
Phone: 963964701914 | Note: تم
Phone: 963991175918 | Note: No Note
Phone: 963962215103 | Note: تم
Phone: 963099295223 | Note: خطأ
Phone: 963990368364 | Note: تم التواصل
Phone: 963931447359 | Note: No Note
Phone: 963994875810 | Note: تم التواصل
Phone: 963998047263 | Note: تم التواصل
Phone: 963988892598 | Note: تم التواصل
Phone: 963996136343 | Note: تم التواصل
Phone: 963934245841 | Note: تم التواصل
Phone: 963933944881 | Note: تم التواصل
Phone: 963993484762 | Note: تم التواصل
Phone: 963997386925 | Note: تم التواصل
Phone: 963955300562 | Note: تم التواصل
Phone: 963099123427 | Note: الرقم خطأ
Phone: 963998752835 | Note: تم التواصل
Phone: 963986164501 | Note: تم التواصل
Phone: 963994221981 | Note: تم
Phone: 963985111107 | Note: تم
Phone: 963965665584 | Note: تم
Phone: 963093309389 | Note: الرقم خطأ
Phone: 963933009411 | Note: تم التواصل
Phone: 963997226674 | Note: تم التواصل
Phone: 963985322261 | Note: تم التواصل
Phone: 963944585751 | Note: تم
Phone: 963936520446 | Note: تم
Phone: 963942272548 | Note: تم
Phone: 963932784840 | Note: تم
Phone: 963966337233 | Note: تم
Phone: 963982498933 | Note: تم
Phone: 963934792333 | Note: تم
Phone: 963992323421 | Note: No Note
Phone: 963937512107 | Note: تم
Phone: 963095247574 | Note: No Note
Phone: 963994800068 | Note: تم
Phone: 963955809725 | Note: No Note
Phone: 963933823485 | Note: No Note
Phone: 963949204755 | Note: تم
Phone: 963983691808 | Note: No Note
Phone: 963983626721 | Note: No Note
Phone: 963981610336 | Note: No Note
Phone: 963937927500 | Note: No Note
Phone: 963959853846 | Note: No Note
Phone: 963997073925 | Note: تم
Phone: 963956732767 | Note: غلط
Phone: 963947021104 | Note: تم
Phone: 963940052998 | Note: تم
Phone: 963944662446 | Note: تم
Phone: 963982678522 | Note: تم
Phone: 963962135909 | Note: تم
Phone: 963936610855 | Note: تم التواصل
Phone: 963994299736 | Note: تم التواصل
Phone: 963994202784 | Note: تم التواصل
Phone: 963938506392 | Note: تم التواصل
Phone: 963996355773 | Note: تم التواصل
Phone: 963993211641 | Note: تم التواصل
Phone: 963958885#01 | Note: خطأ
Phone: 963993214588 | Note: تم التواصل
Phone: 963930690439 | Note: تم التواصل
Phone: 963981320471 | Note: No Note
Phone: 963958749567 | Note: No Note
Phone: 963955399707 | Note: السيارة بالتصليح
Phone: 963981661357 | Note: تم
Phone: 963935151385 | Note: تم
Phone: 963933524019 | Note: تم
Phone: 963969079332 | Note: تم
Phone: 963982380563 | Note: تم
Phone: 963998817414 | Note: تم
Phone: 963962864640 | Note: تم
Phone: 963954932302 | Note: تم
Phone: 963951628380 | Note: No Note
Phone: 963956742311 | Note: تم
Phone: 963988605516 | Note: No Note
Phone: 963933122432 | Note: No Note
Phone: 963943562177 | Note: No Note
Phone: 963936700433 | Note: No Note
Phone: 963991539595 | Note: No Note
Phone: 963997634135 | Note: No Note
Phone: 963954512319 | Note: No Note
Phone: 963991392595 | Note: No Note
Phone: 963930053897 | Note: No Note
Phone: 963941494393 | Note: No Note
Phone: 963938963278 | Note: No Note
Phone: 963996725663 | Note: No Note
Phone: 963932998203 | Note: No Note
Phone: 963984743097 | Note: No Note
Phone: 963+20952653 | Note: No Note
Phone: 963933263408 | Note: No Note
Phone: 963992603003 | Note: No Note
Phone: 963999186608 | Note: No Note
Phone: 963093319092 | Note: No Note
Phone: 963992200572 | Note: No Note
Phone: 963935860379 | Note: تم التواصل
Phone: 963932612511 | Note: No Note
Phone: 963955665828 | Note: No Note
Phone: 963958748659 | Note: No Note
Phone: 963948956757 | Note: No Note
Phone: 963991527216 | Note: No Note
Phone: 963967434852 | Note: No Note
Phone: 963933473946 | Note: No Note
Phone: 963959281303 | Note: No Note
Phone: 963937506427 | Note: No Note
Phone: 963945017743 | Note: No Note
Phone: 963941973355 | Note: No Note
Phone: 963969369322 | Note: No Note
Phone: 963935221144 | Note: No Note
Phone: 963991933762 | Note: No Note
Phone: 963991331539 | Note: No Note
Phone: 963995940170 | Note: No Note
Phone: 963996450146 | Note: No Note
Phone: 963942283959 | Note: No Note
Phone: 963936825881 | Note: No Note
Phone: 963994058290 | Note: تم التواصل
Phone: 963980387211 | Note: No Note
Phone: 963960003815 | Note: No Note
Phone: 963938705215 | Note: No Note
Phone: 963930097924 | Note: No Note
Phone: 963982872652 | Note: تم التواصل
Phone: 963985327571 | Note: No Note
Phone: 963958786360 | Note: No Note
Phone: 963968840086 | Note: No Note
Phone: 963937536957 | Note: No Note
Phone: 963953925409 | Note: No Note
Phone: 963947157325 | Note: No Note
Phone: 963981489190 | Note: No Note
Phone: 963937583931 | Note: No Note
Phone: 963949631384 | Note: No Note
Phone: 963953344805 | Note: No Note
Phone: 963930104547 | Note: No Note
Phone: 963952300665 | Note: No Note
Phone: 963095230066 | Note: No Note
Phone: 963988510023 | Note: No Note
Phone: 963992274229 | Note: No Note
Phone: 963991506951 | Note: تم التواصل
Phone: 963954894895 | Note: تم التواصل
Phone: 963955585012 | Note: خارج الخدمة
Phone: 963996307122 | Note: تم التواصل
Phone: 963991610683 | Note: تم التواصل
Phone: 963991355714 | Note: تم التواصل
Phone: 963937557764 | Note: تم التواصل
Phone: 963988514321 | Note: تم التواصل
Phone: 963944077035 | Note: تم التواصل
Phone: 963938129427 | Note: تم التواصل
Phone: 963990444099 | Note: تم التواصل
Phone: 963956786668 | Note: تم التواصل
Phone: 963940728564 | Note: تم التواصل
Phone: 963954402659 | Note: خارج الخدمة وتس واتصال
Phone: 963936765364 | Note: تم التواصل
Phone: 963933078901 | Note: تم التواصل
Phone: 963934417178 | Note: تم التواصل
Phone: 963930447695 | Note: تم التواصل
Phone: 963094051564 | Note: الرقم خطأ
Phone: 963992417040 | Note: تم التواصل
Phone: 963958922780 | Note: تم الاتصال سكودا
Phone: 963951379303 | Note: تم التواصل
Phone: 963953858808 | Note: تم التواصل
Phone: 963964646415 | Note: تم التواصل
Phone: 963960098818 | Note: تم التواصل
Phone: 963933899771 | Note: تم التواصل
Phone: 963096949698 | Note: الرقم خطأ
Phone: 963982861634 | Note: No Note
Phone: 963938252876 | Note: No Note
Phone: 963986561347 | Note: No Note
Phone: 963933700937 | Note: No Note
Phone: 963960078368 | Note: No Note
Phone: 963933737355 | Note: No Note
Phone: 963983755054 | Note: hvta
Phone: 963940907547 | Note: No Note
Phone: 963949757956 | Note: No Note
Phone: 963938938514 | Note: No Note
Phone: 963980457705 | Note: No Note
Phone: 963944404002 | Note: No Note
Phone: 963965410313 | Note: No Note
Phone: 963982325766 | Note: No Note
Phone: 963981289181 | Note: No Note
Phone: 963993462192 | Note: No Note
Phone: 963968504915 | Note: No Note
Phone: 963936628380 | Note: No Note
Phone: 963951366246 | Note: No Note
Phone: 963998727408 | Note: No Note
Phone: 963953877512 | Note: No Note
Phone: 963940478435 | Note: No Note
Phone: 963984625505 | Note: No Note
Phone: 963954659494 | Note: No Note
Phone: 963947653804 | Note: No Note
Phone: 963959218092 | Note: No Note
Phone: 963994511053 | Note: No Note
Phone: 963938341514 | Note: No Note
Phone: 963982672582 | Note: No Note
Phone: 963992495126 | Note: No Note
Phone: 963993163487 | Note: No Note
Phone: 963966516151 | Note: No Note
Phone: 963958472195 | Note: No Note
Phone: 963954611914 | Note: No Note
Phone: 963940865211 | Note: No Note
Phone: 963955875120 | Note: No Note
Phone: 963985347924 | Note: No Note
Phone: 963951450015 | Note: No Note
Phone: 963991449908 | Note: No Note
Phone: 963939715983 | Note: No Note
Phone: 963932166786 | Note: No Note
Phone: 963932334792 | Note: No Note
Phone: 963998615843 | Note: No Note
Phone: 963995232226 | Note: No Note
Phone: 963983772298 | Note: No Note
Phone: 963988736467 | Note: No Note
Phone: 963959109269 | Note: No Note
Phone: 963934770200 | Note: No Note
Phone: 963995149210 | Note: No Note
Phone: 963985665216 | Note: No Note
Phone: 963962423870 | Note: No Note
Phone: 963939894588 | Note: No Note
Phone: 963930018143 | Note: No Note
Phone: 963944940930 | Note: No Note
Phone: 963930354266 | Note: No Note
Phone: 963952380026 | Note: No Note
Phone: 963932838183 | Note: No Note
Phone: 963988131966 | Note: No Note
Phone: 963993300063 | Note: No Note
Phone: 963949754561 | Note: No Note
Phone: 963935927218 | Note: No Note
Phone: 963935595928 | Note: No Note
Phone: 963949282497 | Note: No Note
Phone: 963934392382 | Note: No Note
Phone: 963937593945 | Note: No Note
Phone: 963938883892 | Note: No Note
Phone: 963093727926 | Note: No Note
Phone: 963999062031 | Note: No Note
Phone: 963938059209 | Note: No Note
Phone: 963964685561 | Note: No Note
Phone: 963944344299 | Note: No Note
Phone: 963955355766 | Note: No Note
Phone: 963999823383 | Note: No Note
Phone: 963944439897 | Note: No Note
Phone: 963995127821 | Note: No Note
Phone: 963994257265 | Note: No Note
Phone: 963936490987 | Note: No Note
Phone: 963993530236 | Note: No Note
Phone: 963 959 503 | Note: No Note
Phone: 963986797797 | Note: No Note
Phone: 963933529331 | Note: No Note
Phone: 963951343947 | Note: No Note
Phone: 963997585651 | Note: No Note
Phone: 963991907052 | Note: No Note
Phone: 963988964744 | Note: No Note
Phone: 963099161662 | Note: No Note
Phone: 963933175809 | Note: No Note
Phone: 963937590105 | Note: No Note
Phone: 963984222103 | Note: No Note
Phone: 963099467874 | Note: No Note
Phone: 963930301422 | Note: No Note
Phone: 963988561330 | Note: No Note
Phone: 963986769366 | Note: No Note
Phone: 963940554896 | Note: No Note
Phone: 963934825832 | Note: No Note
Phone: 963980823984 | Note: No Note
Phone: 963993761215 | Note: No Note
Phone: 963+96399339 | Note: No Note
Phone: 963992811392 | Note: No Note
Phone: 963993292569 | Note: No Note
Phone: 963985774901 | Note: No Note
Phone: 963992475789 | Note: No Note
Phone: 963995953364 | Note: No Note
Phone: 96385166225 | Note: No Note
Phone: 96398516622 | Note: No Note
Phone: 963935689658 | Note: No Note
Phone: 963933572705 | Note: No Note
Phone: 963935722215 | Note: No Note
Phone: 963981140916 | Note: No Note
Phone: 963985215116 | Note: No Note
Phone: 963932762035 | Note: No Note
Phone: 963946120103 | Note: No Note
Phone: 963933818455 | Note: No Note
Phone: 963964858616 | Note: No Note
Phone: 963944390916 | Note: No Note
Phone: 963945739489 | Note: No Note
Phone: 963932776772 | Note: No Note
Phone: 963933333813 | Note: No Note
Phone: 963980874584 | Note: No Note
Phone: 963980294990 | Note: No Note
Phone: 963934185580 | Note: No Note
Phone: 963936921204 | Note: No Note
Phone: 963093554127 | Note: No Note
Phone: 963095965191 | Note: No Note
Phone: 963093352887 | Note: No Note
Phone: 963988128853 | Note: No Note
Phone: 963094729812 | Note: No Note
Phone: 963998748039 | Note: No Note
Phone: 963955374066 | Note: تم
Phone: 963095537406 | Note: No Note
Phone: 963949005027 | Note: تم
Phone: 963959651915 | Note: لاااااا
Phone: 963094906005 | Note: No Note
Phone: 963988617564 | Note: No Note
Phone: 963992652773 | Note: No Note
Phone: 963996727211 | Note: No Note
Phone: 963991363270 | Note: No Note
Phone: 963946790074 | Note: No Note
Phone: 963939297072 | Note: No Note
Phone: 963991197416 | Note: No Note
Phone: 963980362067 | Note: No Note
Phone: 963987076781 | Note: No Note
Phone: 963945458695 | Note: No Note
Phone: 963936408390 | Note: No Note
Phone: 963991431763 | Note: No Note
Phone: 963964795089 | Note: No Note
Phone: 963965800050 | Note: No Note
Phone: 963953677959 | Note: No Note
Phone: 963099310584 | Note: No Note
Phone: 963934108410 | Note: No Note
Phone: 963944498647 | Note: No Note
Phone: 963943569855 | Note: No Note
Phone: 963992000214 | Note: No Note
Phone: 963988733184 | Note: No Note
Phone: 963997357928 | Note: No Note
Phone: 963968217127 | Note: No Note
Phone: 963984213886 | Note: No Note
Phone: 963969955380 | Note: No Note
Phone: 963093039426 | Note: No Note
Phone: 963993067534 | Note: No Note
Phone: 963996882906 | Note: No Note
Phone: 963930981086 | Note: No Note
Phone: 2979639929 | Note: No Note
Phone: 963948320564 | Note: No Note
Phone: 963933236526 | Note: No Note
Phone: 963935731025 | Note: No Note
Phone: 963940005693 | Note: No Note
Phone: 963093435196 | Note: No Note
Phone: 963933147140 | Note: رح يكمل تسجيل
Phone: 963982950096 | Note: عم يصلح سيارتو بس تجهز رح يكمل تسجيل
Phone: 963992304426 | Note: سيارتو جيب مصروفات كبير
Phone: 963093412182 | Note: رقمو غلط
Phone: 963944707024 | Note: راح النت من عندو واليوم رح يرجع يسجل
Phone: 963997952574 | Note: No Note
Phone: 963932863040 | Note: سيارتو بالتصليح
Phone: 963942074619 | Note: مابدو
Phone: 963934146486 | Note: تم التواصل
Phone: 963992566299 | Note: تم التواصل
Phone: 9634894573 | Note: رقم غلط
Phone: 963933383373 | Note: تم التواصل
Phone: 963962419880 | Note: تم التواصل
Phone: 963938105556 | Note: تم التواصل
Phone: 963981347112 | Note: تم التواصل
Phone: 963959052791 | Note: تم التواصل
Phone: 963949608050 | Note: تم التواصل
Phone: 963998977934 | Note: تم التواصل
Phone: 963931839232 | Note: تم التواصل
Phone: 963935140176 | Note: تم التواصل
Phone: 963932033543 | Note: تم التواصل
Phone: 963991172711 | Note: تم التواصل
Phone: 963959164134 | Note: تم التواصل
Phone: 963943919419 | Note: ماعندو واتس رقمو مسكر
Phone: 963994000556 | Note: تم التواصل
Phone: 963098084512 | Note: رقم غلط
Phone: 963932254575 | Note: تم التواصل
Phone: 963945117692 | Note: تم التواصل
Phone: 963932119678 | Note: تم التواصل
Phone: 963993034046 | Note: تم التواصل
Phone: 963954183741 | Note: تم التواصل
Phone: 963951433826 | Note: ماعندو واتس خطو مسكر
Phone: 963093661085 | Note: رقم غلط
Phone: 963998287801 | Note: تم التواصل
Phone: 963988912182 | Note: ماعندو واتس
Phone: 963996024113 | Note: تم التواصل
Phone: 963931677655 | Note: تم التواصل
Phone: 963933921336 | Note: تم التواصل
Phone: 963936374163 | Note: تم التواصل
Phone: 963942047365 | Note: تم التواصل
Phone: 963981360800 | Note: تم التواصل
Phone: 963956396223 | Note: تم التواصل
Phone: 963963899416 | Note: رقم غلط
Phone: 963934493911 | Note: تم التواصل
Phone: 963934950868 | Note: تم التواصل
Phone: 963936659081 | Note: تم التواصل
Phone: 963945973939 | Note: تم التواصل
Phone: 963983444102 | Note: تم التواصل
Phone: 963951844719 | Note: تم التواصل
Phone: 963932663633 | Note: تم التواصل
Phone: 963093266363 | Note: رقم غلط
Phone: 963937271849 | Note: تم التواصل معو بيك اب
Phone: 963938728361 | Note: تم التواصل
Phone: 963947640146 | Note: تم التواصل
Phone: 963992439500 | Note: No Note
Phone: 963997489672 | Note: تم التواصل
Phone: 963094850489 | Note: رقم غلط
Phone: 963990115156 | Note: تم التواصل
Phone: 963962311317 | Note: ماعندو واتس وخطو مسكر
Phone: 963093172947 | Note: الرقم غلط
Phone: 963993762515 | Note: تم التواصل
Phone: 963931799545 | Note: تم التواصل
Phone: 963945187714 | Note: تم التواصل
Phone: 963968911015 | Note: ماعندو واتس رقمو مسكر
Phone: 963944750715 | Note: تم التواصل
Phone: 963998134492 | Note: تم التواصل
Phone: 963099813449 | Note: رقمو غلط
Phone: 963932727476 | Note: تم التواصل
Phone: 963933518336 | Note: تم التواصل
Phone: 963998885309 | Note: تم التواصل
Phone: 963988248185 | Note: تم التواصل
Phone: 963093067938 | Note: No Note
Phone: 963981383714 | Note: تم التواصل
Phone: 963939362191 | Note: رقمو مغلق وماعندو واتس
Phone: 963933440323 | Note: تم التواصل
Phone: 963982143227 | Note: تم التواصل
Phone: 963938145916 | Note: تم التواصل
Phone: 963933718454 | Note: تم التواصل
Phone: 963931800533 | Note: تم التواصل
Phone: 963934294133 | Note: تم التواصل
Phone: 963939808314 | Note: رقم غلط ومسكر خطو
Phone: 963935745914 | Note: تم التواصل
Phone: 963969902667 | Note: تم التواصل
Phone: 963933735326 | Note: ماعندو واتس رقمو غلط
Phone: 963998699541 | Note: تم التواصل
Phone: 963093333839 | Note: رقم غلط
Phone: 963966313126 | Note: تم التواصل
Phone: 963956451887 | Note: تم التواصل
Phone: 963967415296 | Note: تم التواصل
Phone: 963997766064 | Note: تم التواصل
Phone: 963962854801 | Note: تم التواصل
Phone: 963998190089 | Note: تم التواصل
Phone: 963981634358 | Note: تم التواصل
Phone: 963938289156 | Note: تم التواصل
Phone: 963095645188 | Note: رقم غلط
Phone: 963936908818 | Note: تم التواصل
Phone: 963941385190 | Note: تم التواصل
Phone: 963009639885 | Note: رقم غلط
Phone: 963935777750 | Note: تم التواصل
Phone: 963985578199 | Note: تم التواصل
Phone: 963099317895 | Note: رقم غلط
Phone: 963990417834 | Note: تم التواصل
Phone: 963093727184 | Note: رقم غلط
Phone: 963968750666 | Note: ماعندو واتس ورقمو مسكر
Phone: 963998668125 | Note: تم التواصل
Phone: 963991833068 | Note: تم التواصل
Phone: 963940740151 | Note: ماعندي واتس ورقمو مسكر
Phone: 963955544813 | Note: تم التواصل
Phone: 963933202022 | Note: ماعندو واتساب ورخطو مسكر
Phone: 963933221881 | Note: ماعندو واتس وخطو مسكر
Phone: 963943358179 | Note: تم التواصل
Phone: 963+96393349 | Note: رقم غلط
Phone: 963933804760 | Note: تم التواصل
Phone: 963988214321 | Note: تم التواصل
Phone: 963991903251 | Note: تم التواصل
Phone: 963933400489 | Note: تم التواصل
Phone: 963940340848 | Note: تم التواصل
Phone: 963992458425 | Note: تم التواصل
Phone: 963932555452 | Note: تم التواصل
Phone: 963965218471 | Note: تم التواصل
Phone: 963933292470 | Note: تم التواصل
Phone: 963943889236 | Note: تم التواصل وكمل تسجيلو
Phone: 963988133863 | Note: تم التواصل
Phone: 963094444810 | Note: رقمو غلط
Phone: 963930946809 | Note: تم التواصل
Phone: 963968191496 | Note: تم التواصل
Phone: 963935090886 | Note: تم التواصل
Phone: 963991922952 | Note: تم التواصل
Phone: 963991112991 | Note: تم التواصل
Phone: 963986170776 | Note: تم التواصل
Phone: 963999743765 | Note: تم التواصل
Phone: 963932111786 | Note: تم التواصل
Phone: 963933681672 | Note: تم التواصل
Phone: 963938552167 | Note: تم التواصل
Phone: 963933206306 | Note: تم التواصل
Phone: 963957346118 | Note: تم التواصل
Phone: 963997392413 | Note: تم التواصل
Phone: 963988227272 | Note: تم التواصل
Phone: 963988029059 | Note: تم التواصل
Phone: 963945832988 | Note: تم التواصل
Phone: 963997944590 | Note: تم التواصل
Phone: 963980363715 | Note: تم التواصل
Phone: 963935102639 | Note: تم التواصل
Phone: 963954438781 | Note: تم التواصل
Phone: 963945223878 | Note: تم التواصل
Phone: 963980581094 | Note: تم التواصل
Phone: 963939164164 | Note: تم التواصل
Phone: 963938124006 | Note: تم التواصل
Phone: 963944349036 | Note: تم التواصل
Phone: 963992057768 | Note: غير مهتم
Phone: 963988177909 | Note: تم التواصل
Phone: 963932049144 | Note: No Note
Phone: 963992393038 | Note: No Note
Phone: 963952391236 | Note: No Note
Phone: 963935039644 | Note: No Note
Phone: 963985924850 | Note: No Note
Phone: 963932377014 | Note: No Note
Phone: 963993235215 | Note: No Note
Phone: 963980541950 | Note: No Note
Phone: 963945957334 | Note: No Note
Phone: 963981355144 | Note: No Note
Phone: 963938139830 | Note: No Note
Phone: 963932562745 | Note: No Note
Phone: 963994661362 | Note: No Note
Phone: 963988342603 | Note: No Note
Phone: 963994011134 | Note: No Note
Phone: 963936104080 | Note: No Note
Phone: 963992788749 | Note: No Note
Phone: 963998892720 | Note: No Note
Phone: 963996682748 | Note: No Note
Phone: 963938570002 | Note: No Note
Phone: 963931745699 | Note: No Note
Phone: 963992165521 | Note: No Note
Phone: 963993595631 | Note: No Note
Phone: 963933949753 | Note: No Note
Phone: 963934629935 | Note: No Note
Phone: 963965778887 | Note: اجدب
Phone: 963980212534 | Note: No Note
Phone: 963956784191 | Note: No Note
Phone: 963935443899 | Note: No Note
Phone: 963958642713 | Note: No Note
Phone: 963999138915 | Note: No Note
Phone: 963948941187 | Note: No Note
Phone: 963953459606 | Note: تم
Phone: 963934146288 | Note: تم
Phone: 963933256528 | Note: تم
Phone: 963998883027 | Note: تم
Phone: 963968481449 | Note: تم
Phone: 963965247307 | Note: ما معو سيارة
Phone: 963956761624 | Note: تم
Phone: 963939724962 | Note: تم
Phone: 963936030548 | Note: تم
Phone: 962781821306 | Note: خطأ
Phone: 963960040775 | Note: No Note
Phone: 963996642236 | Note: No Note
Phone: 963934293954 | Note: تم
Phone: 963934928537 | Note: تم
Phone: 963941440312 | Note: No Note
Phone: 963937214172 | Note: No Note
Phone: 963933824331 | Note: No Note
Phone: 963945555043 | Note: No Note
Phone: 963938676742 | Note: تم
Phone: 963933306898 | Note: تم
Phone: 963933708476 | Note: No Note
Phone: 963994795950 | Note: No Note
Phone: 963990329520 | Note: تم
Phone: 963960977309 | Note: تم
Phone: 963933267955 | Note: تم
Phone: 963996186195 | Note: تم
Phone: 916364908545 | Note: تم
Phone: 919154792575 | Note: تم
Phone: 963998119558 | Note: تم
Phone: 919606970074 | Note: خطأ
Phone: 916364908621 | Note: خطأ
Phone: 962772735902 | Note: No Note
Phone: 916366356713 | Note: No Note
Phone: 16693334444 | Note: No Note
Phone: 962782700835 | Note: No Note
Phone: 962782070515 | Note: No Note
Phone: 963984429412 | Note: No Note
Phone: 963966673673 | Note: No Note
Phone: 962796377987 | Note: No Note
Phone: 963947222548 | Note: No Note
Phone: 639276036618 | Note: No Note
Phone: 963798583052 | Note: No Note

64
serviceapp/editCarPlate.php Executable file
View File

@@ -0,0 +1,64 @@
<?php
require_once __DIR__ . '/../connect.php';
// استرجاع وتصفية البيانات
$driverId = filterRequest("driverId");
$carPlate = $encryptionHelper->encryptData(filterRequest("carPlate"));
$color = filterRequest("color");
$color_hex = filterRequest("color_hex");
$make = filterRequest("make");
$model = filterRequest("model");
$expiration_date = filterRequest("expiration_date");
$owner = $encryptionHelper->encryptData(filterRequest("owner"));
$year = filterRequest("year");
$employee = filterRequest("employee");
// تحديث CarRegistration
$sqlUpdate = "
UPDATE `CarRegistration`
SET
`car_plate` = :carPlate,
`color` = :color,
`color_hex` = :color_hex,
`make` = :make,
`model` = :model,
`year` = :year,
`expiration_date` = :expiration_date,
`owner` = :owner
WHERE `driverID` = :driverId";
$stmtUpdate = $con->prepare($sqlUpdate);
$stmtUpdate->execute([
':carPlate' => $carPlate,
':color' => $color,
':color_hex' => $color_hex,
':make' => $make,
':model' => $model,
':year' => $year,
':expiration_date' => $expiration_date,
':owner' => $owner,
':driverId' => $driverId
]);
if ($stmtUpdate->rowCount() > 0) {
// تسجيل التعديل
$sqlInsert = "INSERT INTO `carPlateEdit`
(`driverId`, `carPlate`, `color`, `make`, `model`, `expiration_date`, `owner`, `year`, `employee`, `isEdit`)
VALUES (:driverId, :carPlate, :color, :make, :model, :expiration_date, :owner, :year, :employee, 1)";
$stmtInsert = $con->prepare($sqlInsert);
$stmtInsert->execute([
':driverId' => $driverId,
':carPlate' => $carPlate,
':color' => $color,
':make' => $make,
':model' => $model,
':expiration_date' => $expiration_date,
':owner' => $owner,
':year' => $year,
':employee' => $employee
]);
jsonSuccess(null, "Car data updated and edit logged successfully.");
} else {
jsonError("No changes were made to the car data.");
}

View File

@@ -0,0 +1,54 @@
<?php
require_once __DIR__ . '/../connect.php';
$phoneNumber = filterRequest("phone_number");
$sql = "SELECT
CR.`id`,
CR.`driverID`,
CR.`vin`,
CR.`car_plate`,
CR.`make`,
CR.`model`,
CR.`year`,
CR.`expiration_date`,
CR.`color`,
CR.`owner`,
CR.`color_hex`,
CR.`address`,
CR.`displacement`,
CR.`fuel`,
CR.`registration_date`,
CR.`created_at`,
d.phone
FROM
`CarRegistration` CR
LEFT JOIN driver d ON d.id = CR.driverID
WHERE
CR.`driverID` NOT IN (
SELECT DISTINCT CPE.`driverId`
FROM `carPlateEdit` CPE
)
ORDER BY RAND()
LIMIT 10;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as &$row) {
$row['vin'] = $encryptionHelper->decryptData($row['vin']);
$row['car_plate'] = $encryptionHelper->decryptData($row['car_plate']);
$row['owner'] = $encryptionHelper->decryptData($row['owner']);
$row['address'] = $encryptionHelper->decryptData($row['address']);
$row['phone'] = $encryptionHelper->decryptData($row['phone']);
}
jsonSuccess($rows);
} else {
jsonError($message = "No Car verified yet found");
}
?>

View File

@@ -0,0 +1,183 @@
<?php
require_once __DIR__ . '/../connect.php';
// $driverID = filterRequest("driverID");
$sql = "SELECT
cm.`id`,
cm.`ride_id`,
cm.`passenger_id`,
cm.`driver_id`,
cm.`complaint_type`,
cm.`description`,
cm.`date_filed`,
cm.`statusComplaint`,
cm.`resolution`,
cm.`date_resolved`,
p.first_name AS passengerName,
d.name_arabic AS driverName,
d.gender,
ride.price AS priceOfRide,
ride.status AS rideStatus,
ride.carType ascarType,
ride.paymentMethod AS ridePaymentMethod,
ride.rideTimeFinish AS rideTimeFinish,
payments.amount as paymentFromPaymentTable,
payments.created_at as timeFromPaymentTable,
(
SELECT
AVG(rd.rating)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS avgRatingDriverFromPassengers,
(
SELECT
COUNT(*)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS countratingDriverFromPassengers,
(
SELECT
AVG(rp.rating)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS avgRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS countRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.driver_id = cm.driver_id
) countDriverRide,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.passenger_id = cm.passenger_id
) countPassengerRide,
(
SELECT
COALESCE(SUM(amount),
0) AS visaDriver
FROM
payments
WHERE
isGiven = 'waiting' AND `payment_method` IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND payments.`driverID` = cm.driver_id
) AS driverVisa,
(
SELECT
COALESCE(SUM(amount),
0) AS pointDriver
FROM
driverWallet dw
WHERE
dw.paymentMethod IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND dw.`driverID` = cm.driver_id
) AS driverWallet,
(
SELECT
COALESCE(SUM(pw.balance),
0)
FROM
passengerWallet pw
WHERE
pw.passenger_id = cm.passenger_id
) AS passengerWallet,
(
SELECT
token
FROM
driverToken
WHERE
driverToken.captain_id = cm.driver_id
) AS driverToken,
(
SELECT
token
FROM
tokens
WHERE
tokens.passengerID = cm.passenger_id
) AS passengerToken,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.passenger_id = cm.passenger_id AND cm.complaint_type = 'Passenger'
) AS countOfComplaintFromPassenger,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.driver_id = cm.driver_id AND cm.complaint_type = 'Driver'
) AS countOfComplaintFromDriver
FROM
`complaint` cm
LEFT JOIN passengers p ON
p.id = cm.`passenger_id`
LEFT JOIN driver d ON
d.id = cm.driver_id
LEFT JOIN ride ON ride.id = cm.ride_id
left join payments on payments.rideId=cm.ride_id";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($row as &$item) {
if (isset($item['passengerName'])) {
$item['passengerName'] = $encryptionHelper->decryptData($item['passengerName']);
}
if (isset($item['driverName'])) {
$item['driverName'] = $encryptionHelper->decryptData($item['driverName']);
}
if (isset($item['gender'])) {
$item['gender'] = $encryptionHelper->decryptData($item['gender']);
}
if (isset($item['driverToken'])) {
$item['driverToken'] = $encryptionHelper->decryptData($item['driverToken']);
}
if (isset($item['passengerToken'])) {
$item['passengerToken'] = $encryptionHelper->decryptData($item['passengerToken']);
}
}
jsonSuccess($row);
} else {
jsonError("No wallet record found");
}
?>

View File

@@ -0,0 +1,185 @@
<?php
require_once __DIR__ . '/../connect.php';
$driverID = filterRequest("driver_id");
$sql = "SELECT
cm.`id`,
cm.`ride_id`,
cm.`passenger_id`,
cm.`driver_id`,
cm.`complaint_type`,
cm.`description`,
cm.`date_filed`,
cm.`statusComplaint`,
cm.`resolution`,
cm.`date_resolved`,
p.first_name AS passengerName,
d.name_arabic AS driverName,
d.gender,
ride.price AS priceOfRide,
ride.status AS rideStatus,
ride.carType AS carType,
ride.paymentMethod AS ridePaymentMethod,
ride.rideTimeFinish AS rideTimeFinish,
payments.amount AS paymentFromPaymentTable,
payments.created_at AS timeFromPaymentTable,
(
SELECT
AVG(rd.rating)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS avgRatingDriverFromPassengers,
(
SELECT
COUNT(*)
FROM
ratingDriver rd
WHERE
rd.driver_id = cm.driver_id
) AS countratingDriverFromPassengers,
(
SELECT
AVG(rp.rating)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS avgRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ratingPassenger rp
WHERE
rp.passenger_id = cm.passenger_id
) AS countRatingPassengerFromDrivers,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.driver_id = cm.driver_id
) countDriverRide,
(
SELECT
COUNT(*)
FROM
ride
WHERE
ride.passenger_id = cm.passenger_id
) countPassengerRide,
(
SELECT
COALESCE(SUM(amount),
0) AS visaDriver
FROM
payments
WHERE
isGiven = 'waiting' AND `payment_method` IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND payments.`driverID` = cm.driver_id
) AS driverVisa,
(
SELECT
COALESCE(SUM(amount),
0) AS pointDriver
FROM
driverWallet dw
WHERE
dw.paymentMethod IN(
'visa-in',
'visa',
'visaRide',
'TransferFrom',
'payout',
'TransferTo'
) AND dw.`driverID` = cm.driver_id
) AS driverWallet,
(
SELECT
COALESCE(SUM(pw.balance),
0)
FROM
passengerWallet pw
WHERE
pw.passenger_id = cm.passenger_id
) AS passengerWallet,
(
SELECT
token
FROM
driverToken
WHERE
driverToken.captain_id = cm.driver_id
) AS driverToken,
(
SELECT
token
FROM
tokens
WHERE
tokens.passengerID = cm.passenger_id
) AS passengerToken,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.passenger_id = cm.passenger_id AND cm.complaint_type = 'Passenger'
) AS countOfComplaintFromPassenger,
(
SELECT
COUNT(*)
FROM
complaint
WHERE
complaint.driver_id = cm.driver_id AND cm.complaint_type = 'Driver'
) AS countOfComplaintFromDriver
FROM
`complaint` cm
LEFT JOIN passengers p ON
p.id = cm.`passenger_id`
LEFT JOIN driver d ON
d.id = cm.driver_id
LEFT JOIN ride ON ride.id = cm.ride_id
LEFT JOIN payments ON payments.rideId = cm.ride_id
WHERE
cm.driver_id = '$driverID'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($row as &$item) {
if (isset($item['passengerName'])) {
$item['passengerName'] = $encryptionHelper->decryptData($item['passengerName']);
}
if (isset($item['driverName'])) {
$item['driverName'] = $encryptionHelper->decryptData($item['driverName']);
}
if (isset($item['gender'])) {
$item['gender'] = $encryptionHelper->decryptData($item['gender']);
}
if (isset($item['driverToken'])) {
$item['driverToken'] = $encryptionHelper->decryptData($item['driverToken']);
}
if (isset($item['passengerToken'])) {
$item['passengerToken'] = $encryptionHelper->decryptData($item['passengerToken']);
}
}
jsonSuccess($row);
} else {
jsonError($message = $sql);
}
?>

View File

@@ -0,0 +1,125 @@
<?php
require_once __DIR__ . '/../connect.php';
// 1. استقبال الرقم الوطني بدلاً من الهاتف
$national_number = filterRequest("national_number");
// 2. تشفير الرقم الوطني للمقارنة مع القيمة المشفرة في قاعدة البيانات
$encryptedNationalNumber = $encryptionHelper->encryptData($national_number);
$sql = "SELECT
COALESCE(
(
SELECT COUNT(*) FROM `ride` WHERE `ride`.`driver_id` = d.id
),
0) AS countRide,
COALESCE(
(
SELECT AVG(`ratingDriver`.`rating`)
FROM ratingDriver
WHERE `ratingDriver`.`driver_id` = d.id
),
0) AS rating,
COALESCE(
(
SELECT SUM(pd.amount)
FROM `payments` pd
WHERE pd.driverID = d.id
),
0) AS totalPayment,
COALESCE(
(
SELECT SUM(dw.amount)
FROM `driverWallet` dw
WHERE dw.driverID = d.id
),
0) AS totalDriverWallet,
COALESCE(
(
SELECT COUNT(*)
FROM complaint
WHERE complaint.driver_id = d.id
),
0) AS countComplaint,
COALESCE(
(
SELECT COUNT(*)
FROM driver_ride_scam scam
WHERE scam.driverID = d.id
),
0) AS countScam,
COALESCE(
(
SELECT complaint.description
FROM complaint
WHERE complaint.driver_id = d.id
ORDER BY complaint.date_resolved DESC
LIMIT 1
),
''
) AS complaint,
COALESCE(
(
SELECT COUNT(*)
FROM ratingPassenger
WHERE ratingPassenger.driverID = d.id
),
0) AS DRatingPassengersCount,
COALESCE(
(
SELECT AVG(ratingPassenger.rating)
FROM ratingPassenger
WHERE ratingPassenger.driverID = d.id
),
0) AS avgDRatingPassenger,
cr.*,
d.*
FROM driver d
LEFT JOIN CarRegistration cr ON cr.driverID = d.id
WHERE d.national_number = :national_number;
";
// 3. تم تعديل الشرط أعلاه للبحث بالرقم الوطني
$stmt = $con->prepare($sql);
// 4. ربط الباراميتر الجديد
$stmt->bindParam(':national_number', $encryptedNationalNumber);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك تشفير الحقول المهمة
foreach ($row as &$r) {
if (isset($r['phone'])) $r['phone'] = $encryptionHelper->decryptData($r['phone']);
if (isset($r['email'])) $r['email'] = $encryptionHelper->decryptData($r['email']);
if (isset($r['first_name'])) $r['first_name'] = $encryptionHelper->decryptData($r['first_name']);
if (isset($r['last_name'])) $r['last_name'] = $encryptionHelper->decryptData($r['last_name']);
if (isset($r['gender'])) $r['gender'] = $encryptionHelper->decryptData($r['gender']);
if (isset($r['birthdate'])) $r['birthdate'] = $encryptionHelper->decryptData($r['birthdate']);
if (isset($r['site'])) $r['site'] = $encryptionHelper->decryptData($r['site']);
if (isset($r['name_arabic'])) $r['name_arabic'] = $encryptionHelper->decryptData($r['name_arabic']);
if (isset($r['national_number'])) $r['national_number'] = $encryptionHelper->decryptData($r['national_number']);
if (isset($r['maritalStatus'])) $r['maritalStatus'] = $encryptionHelper->decryptData($r['maritalStatus']);
if (isset($r['sosPhone'])) $r['sosPhone'] = $encryptionHelper->decryptData($r['sosPhone']);
if (isset($r['car_plate'])) $r['car_plate'] = $encryptionHelper->decryptData($r['car_plate']);
if (isset($r['owner'])) $r['owner'] = $encryptionHelper->decryptData($r['owner']);
if (isset($r['address'])) $r['address'] = $encryptionHelper->decryptData($r['address']);
if (isset($r['vin'])) $r['vin'] = $encryptionHelper->decryptData($r['vin']);
unset($r['password']);
}
jsonSuccess($row);
} else {
// يمكنك تعديل الرسالة لتكون "No driver found" بدلاً من wallet record
jsonError("No record found for this national number");
}
?>

View File

@@ -0,0 +1,119 @@
<?php
require_once __DIR__ . '/../connect.php';
$phone = filterRequest("phone");
$encryptedPhone = $encryptionHelper->encryptData($phone); // تشفير الهاتف
$sql = "SELECT
COALESCE(
(
SELECT COUNT(*) FROM `ride` WHERE `ride`.`driver_id` = d.id
),
0) AS countRide,
COALESCE(
(
SELECT AVG(`ratingDriver`.`rating`)
FROM ratingDriver
WHERE `ratingDriver`.`driver_id` = d.id
),
0) AS rating,
COALESCE(
(
SELECT SUM(pd.amount)
FROM `payments` pd
WHERE pd.driverID = d.id
),
0) AS totalPayment,
COALESCE(
(
SELECT SUM(dw.amount)
FROM `driverWallet` dw
WHERE dw.driverID = d.id
),
0) AS totalDriverWallet,
COALESCE(
(
SELECT COUNT(*)
FROM complaint
WHERE complaint.driver_id = d.id
),
0) AS countComplaint,
COALESCE(
(
SELECT COUNT(*)
FROM driver_ride_scam scam
WHERE scam.driverID = d.id
),
0) AS countScam,
COALESCE(
(
SELECT complaint.description
FROM complaint
WHERE complaint.driver_id = d.id
ORDER BY complaint.date_resolved DESC
LIMIT 1
),
''
) AS complaint,
COALESCE(
(
SELECT COUNT(*)
FROM ratingPassenger
WHERE ratingPassenger.driverID = d.id
),
0) AS DRatingPassengersCount,
COALESCE(
(
SELECT AVG(ratingPassenger.rating)
FROM ratingPassenger
WHERE ratingPassenger.driverID = d.id
),
0) AS avgDRatingPassenger,
cr.*,
d.*
FROM driver d
LEFT JOIN CarRegistration cr ON cr.driverID = d.id
WHERE d.phone = :phone;
";
$stmt = $con->prepare($sql);
$stmt->bindParam(':phone', $encryptedPhone);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك تشفير الحقول المهمة
foreach ($row as &$r) {
if (isset($r['phone'])) $r['phone'] = $encryptionHelper->decryptData($r['phone']);
if (isset($r['email'])) $r['email'] = $encryptionHelper->decryptData($r['email']);
if (isset($r['first_name'])) $r['first_name'] = $encryptionHelper->decryptData($r['first_name']);
if (isset($r['last_name'])) $r['last_name'] = $encryptionHelper->decryptData($r['last_name']);
if (isset($r['gender'])) $r['gender'] = $encryptionHelper->decryptData($r['gender']);
if (isset($r['birthdate'])) $r['birthdate'] = $encryptionHelper->decryptData($r['birthdate']);
if (isset($r['site'])) $r['site'] = $encryptionHelper->decryptData($r['site']);
if (isset($r['name_arabic'])) $r['name_arabic'] = $encryptionHelper->decryptData($r['name_arabic']);
if (isset($r['national_number'])) $r['national_number'] = $encryptionHelper->decryptData($r['national_number']);
if (isset($r['maritalStatus'])) $r['maritalStatus'] = $encryptionHelper->decryptData($r['maritalStatus']);
if (isset($r['sosPhone'])) $r['sosPhone'] = $encryptionHelper->decryptData($r['sosPhone']);
if (isset($r['car_plate'])) $r['car_plate'] = $encryptionHelper->decryptData($r['car_plate']);
if (isset($r['owner'])) $r['owner'] = $encryptionHelper->decryptData($r['owner']);
if (isset($r['address'])) $r['address'] = $encryptionHelper->decryptData($r['address']);
if (isset($r['vin'])) $r['vin'] = $encryptionHelper->decryptData($r['vin']);
unset($r['password']);
}
jsonSuccess($row);
} else {
jsonError("No wallet record found");
}
?>

View File

@@ -0,0 +1,45 @@
<?php
require_once __DIR__ . '/../connect.php';
$driverId = filterRequest("driverId");
$sql = "SELECT d.*, cr.*
FROM `driver` d
JOIN `CarRegistration` cr ON cr.driverID = d.id
WHERE d.id = :driverId ";
$stmt = $con->prepare($sql);
$stmt->execute([':driverId' => $driverId]);
if ($stmt->rowCount() > 0) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// فك التشفير للحقول المطلوبة
$fieldsToDecrypt = [
'phone','email','gender','national_number','first_name','last_name',
'name_arabic','address','site','vin','car_plate','owner'
];
foreach ($fieldsToDecrypt as $field) {
if (isset($row[$field]) && $row[$field] !== '') {
try {
$row[$field] = $encryptionHelper->decryptData($row[$field]);
} catch (Exception $e) {
$row[$field] = "Decryption Failed";
}
}
}
// ✅ إزالة الحقول الحسّاسة من الاستجابة
$fieldsToRemove = ['password', 'password_hash', 'salt', 'reset_token'];
foreach ($fieldsToRemove as $f) {
if (array_key_exists($f, $row)) {
unset($row[$f]);
}
}
// إرسال الاستجابة
jsonSuccess([$row]);
} else {
jsonError("No data found for the specified driver ID");
}

View File

@@ -0,0 +1,45 @@
<?php
require_once __DIR__ . '/../connect.php';
$sql = "SELECT
phone_verification.*,
notesForDriverService.note
FROM
phone_verification
INNER JOIN -- نستخدم INNER JOIN لضمان جلب من لديهم ملاحظات فقط
`notesForDriverService`
ON
`notesForDriverService`.`phone` = `phone_verification`.`phone_number`
WHERE
`notesForDriverService`.`note` != 'delete'
ORDER BY
`phone_verification`.`created_at` DESC -- الترتيب حسب تاريخ التحقق لأنه العمود الموجود
LIMIT 400;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك تشفير أرقام الهواتف فقط للإخراج
foreach ($rows as &$row) {
if (!empty($row['phone'])) {
$row['phone'] = $encryptionHelper->decryptData($row['phone']);
}
if (!empty($row['email'])) {
$row['email'] = $encryptionHelper->decryptData($row['email']);
}
if (isset($row['phone_number'])) {
$row['phone_number'] = $encryptionHelper->decryptData($row['phone_number']);
}
}
jsonSuccess($rows);
} else {
jsonError("No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,56 @@
<?php
require_once __DIR__ . '/../connect.php';
/*
المطلوب:
- جلب كل أرقام الهاتف من phone_verification
والتي غير موجودة في جدول driver
- فك تشفير الهاتف والإيميل
- فقط السجلات خلال آخر 5 أيام
*/
$sql = "
SELECT
pv.id,
pv.phone_number,
pv.created_at
FROM
phone_verification pv
LEFT JOIN driver d
ON pv.phone_number = d.phone
LEFT JOIN notesForDriverService n
ON pv.phone_number = n.phone
WHERE
d.phone IS NULL -- لم يقم بالتسجيل كسائق بعد
AND n.phone IS NULL -- لم يتم التواصل معه سابقاً (لا يوجد ملاحظات)
AND pv.created_at >= (NOW() - INTERVAL 6 DAY) -- تم الإنشاء خلال آخر 3 أيام
ORDER BY RAND()
LIMIT 1;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك تشفير أرقام الهاتف والإيميل
foreach ($rows as &$r) {
if (isset($r['phone_number']) && $r['phone_number'] != null) {
$r['phone_number'] = $encryptionHelper->decryptData($r['phone_number']);
}
if (isset($r['email']) && $r['email'] != null) {
$r['email'] = $encryptionHelper->decryptData($r['email']);
}
}
jsonSuccess($rows);
} else {
jsonError("No phone numbers found in the last 5 days");
}
?>

View File

@@ -0,0 +1,32 @@
<?php
require_once __DIR__ . '/../connect.php';
$sql = "SELECT id as driverId, first_name, last_name,phone as phone_number, status FROM driver WHERE status != 'actives'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك تشفير أرقام الهواتف فقط للإخراج
foreach ($rows as &$row) {
if (!empty($row['phone_number'])) {
$row['phone_number'] = $encryptionHelper->decryptData($row['phone_number']);
}
if (!empty($row['first_name'])) {
$row['first_name'] = $encryptionHelper->decryptData($row['first_name']);
}
if (isset($row['last_name'])) {
$row['last_name'] = $encryptionHelper->decryptData($row['last_name']);
}
}
jsonSuccess($rows);
} else {
jsonError("No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,50 @@
<?php
require_once __DIR__ . '/../connect.php';
error_reporting(0);
header('Content-Type: application/json');
// 1. استقبال التواريخ
if (isset($_POST['start_date']) && isset($_POST['end_date'])) {
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
} else {
// Fallback: الافتراضي هو الشهر الحالي
$current_month = isset($_POST['month']) ? str_pad($_POST['month'], 2, "0", STR_PAD_LEFT) : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
$start_date = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$end_date = date('Y-m-t', strtotime($start_date));
}
// 2. الاستعلام: تجميع عدد الملاحظات لكل موظف في كل يوم
// نستخدم DATE(createdAt) لتوحيد التوقيت لليوم فقط
$sql = "
SELECT
DATE(createdAt) as date,
editor as NAME,
COUNT(*) as count
FROM
notesForDriverService
WHERE
createdAt BETWEEN '$start_date' AND '$end_date 23:59:59'
GROUP BY
DATE(createdAt), editor
ORDER BY
date ASC
";
try {
$stmt = $con->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($data) {
echo json_encode(array("status" => "success", "message" => $data));
} else {
echo json_encode(array("status" => "success", "message" => []));
}
} catch (PDOException $e) {
echo json_encode(array("status" => "failure", "message" => $e->getMessage()));
}
?>

View File

@@ -0,0 +1,62 @@
<?php
require_once __DIR__ . '/../connect.php';
/**
* منطق تحديد التواريخ:
* 1. إذا تم إرسال start_date و end_date في الطلب، سيتم استخدامهما (للبحث في رينج مخصص).
* 2. إذا لم يتم إرسالهما، سيتم الاعتماد على month و year (للبحث في شهر كامل).
* 3. إذا لم يتم إرسال أي شيء، سيتم استخدام الشهر الحالي كافتراضي.
*/
if (isset($_POST['start_date']) && isset($_POST['end_date'])) {
// الحالة الأولى: البحث بنطاق تاريخ محدد (من يوم كذا إلى يوم كذا)
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
} else {
// الحالة الثانية: البحث بالشهر (مثل السكربت القديم)
$current_month = isset($_POST['month']) ? $_POST['month'] : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
// تنسيق الشهر ليكون خانتين
$current_month = str_pad($current_month, 2, "0", STR_PAD_LEFT);
// حساب أول وآخر يوم في الشهر
$start_date = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$end_date = date('Y-m-t', strtotime($start_date));
}
// الاستعلام: جلب عدد السائقين لكل نوع توظيف خلال الفترة المحددة
$sql = "SELECT
employmentType,
COUNT(*) AS `count`
FROM
`driver`
WHERE
DATE(created_at) >= '$start_date'
AND DATE(created_at) <= '$end_date'
GROUP BY
employmentType";
try {
$stmt = $con->prepare($sql);
$stmt->execute();
$stats_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($stats_data) {
// طباعة البيانات كـ JSON مع إضافة التواريخ المستخدمة للعلم
printSuccess([
"data" => $stats_data,
"period" => [
"start" => $start_date,
"end" => $end_date
]
]);
} else {
jsonError("No data found for the selected period");
}
} catch (PDOException $e) {
// في حال حدوث خطأ في قاعدة البيانات
jsonError("Database error: " . $e->getMessage());
}
?>

View File

@@ -0,0 +1,43 @@
<?php
require_once __DIR__ . '/../connect.php';
// استقبال الشهر والسنة، أو استخدام الحالي كافتراضي
$current_month = isset($_POST['month']) ? $_POST['month'] : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
// التأكد من أن صيغة الشهر خانتين (مثلاً 5 تصبح 05)
$current_month = str_pad($current_month, 2, "0", STR_PAD_LEFT);
// حساب أول يوم وآخر يوم بناءً على الشهر والسنة المستلمة
$first_day_of_month = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$last_day_of_month = date('Y-m-t', strtotime($first_day_of_month));
// تم تعديل الاستعلام ليستخدم المتغيرات $first_day_of_month و $last_day_of_month
$sql = "SELECT
DATE(d.created_at) AS `date`,
d.`maritalStatus` AS NAME,
COUNT(*) AS `count`
FROM
`driver` d
WHERE
d.`maritalStatus` IN ('mayar','masa', 'shahd', 'rama2','rama1')
AND DATE(d.created_at) >= '$first_day_of_month'
AND DATE(d.created_at) <= '$last_day_of_month'
GROUP BY
`date`, d.`maritalStatus`
ORDER BY
`date` ASC;
";
$stmt = $con->prepare($sql);
$stmt->execute();
$passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($passenger_data) {
// طباعة البيانات كـ JSON
jsonSuccess($data = $passenger_data);
} else {
// طباعة رسالة فشل
jsonError($message = "No data found");
}
?>

89
serviceapp/getJsonFile.php Executable file
View File

@@ -0,0 +1,89 @@
<?php
require_once __DIR__ . '/../get_connect.php';
// اسم الملف النصي الذي سيتم حفظ البيانات فيه
$filename = "drivers_list.txt";
/*
المطلوب:
- جلب أرقام الهاتف من phone_verification غير الموجودة في driver
- فك تشفير الهاتف (والإيميل إن لزم)
- حفظ النتيجة في ملف نصي (رقم الهاتف والملاحظة)
*/
$sql = "
SELECT
pv.id,
pv.phone_number,
pv.email,
pv.token_code,
pv.created_at,
n.note
FROM
phone_verification pv
LEFT JOIN
driver d ON pv.phone_number = d.phone
LEFT JOIN
notesForDriverService n ON pv.phone_number = n.phone
WHERE
d.phone IS NULL
AND (n.note != 'delete' OR n.note IS NULL)
-- تمت إضافة هذا الشرط بناءً على طلبك (آخر 5 أيام)
-- AND pv.created_at >= DATE_SUB(NOW(), INTERVAL 5 DAY)
ORDER BY
pv.created_at DESC;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فتح الملف للكتابة (Mode 'w' يقوم بإنشاء الملف أو مسح محتواه السابق والكتابة من جديد)
$fileHandle = fopen($filename, 'w');
// التحقق من أن الملف فُتح بنجاح
if ($fileHandle) {
foreach ($rows as $r) {
$phone = "";
$note = "No Note"; // القيمة الافتراضية إذا لم توجد ملاحظة
// 1. فك تشفير رقم الهاتف
if (isset($r['phone_number']) && $r['phone_number'] != null) {
$phone = $encryptionHelper->decryptData($r['phone_number']);
}
// 2. تجهيز نص الملاحظة
if (isset($r['note']) && $r['note'] != null) {
$note = $r['note'];
}
// 3. تنسيق السطر الذي سيتم حفظه
// الشكل: Phone: 0123456789 | Note: مهتم بالتسجيل
$line = "Phone: " . $phone . " | Note: " . $note . PHP_EOL;
// 4. الكتابة داخل الملف
fwrite($fileHandle, $line);
}
// إغلاق الملف بعد الانتهاء
fclose($fileHandle);
// طباعة رسالة نجاح مع رابط للملف (اختياري)
echo json_encode([
"status" => "success",
"message" => "File created successfully",
"file" => $filename,
"count" => count($rows)
]);
} else {
jsonError("Unable to open file for writing.");
}
} else {
jsonError("No phone numbers found in the last 5 days");
}
?>

View File

@@ -0,0 +1,73 @@
<?php
require_once __DIR__ . '/../connect.php';
$sql = "SELECT
d.id,
d.phone,
d.email,
d.gender,
d.license_type,
d.national_number,
d.name_arabic,
d.issue_date,
d.expiry_date,
d.license_categories,
d.address,
d.status,
d.birthdate,
d.site,
d.first_name,
d.last_name,
d.accountBank,
d.bankCode,
d.employmentType,
d.maritalStatus,
d.fullNameMaritial,
d.expirationDate,
d.created_at,
d.updated_at,
wdc.id AS welcomId,
wdc.isCall,
wdc.notes,
wdc.createdAt AS welcomeCreatedAt
FROM
driver d
LEFT JOIN welcomeDriverCall wdc ON
wdc.driverId = d.id
WHERE
d.status='actives' and
d.created_at BETWEEN DATE_SUB(CURDATE(), INTERVAL 2 DAY) AND CURDATE() + INTERVAL 2 DAY
ORDER BY
d.created_at DESC;
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the records
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك التشفير للحقول الحساسة
foreach ($rows as &$row) {
$row['phone'] = $encryptionHelper->decryptData($row['phone']);
$row['email'] = $encryptionHelper->decryptData($row['email']);
$row['gender'] = $encryptionHelper->decryptData($row['gender']);
$row['birthdate'] = $encryptionHelper->decryptData($row['birthdate']);
$row['national_number'] = $encryptionHelper->decryptData($row['national_number']);
$row['site'] = $encryptionHelper->decryptData($row['site']);
$row['first_name'] = $encryptionHelper->decryptData($row['first_name']);
$row['last_name'] = $encryptionHelper->decryptData($row['last_name']);
// $row['employmentType'] = $encryptionHelper->decryptData($row['employmentType']);
// $row['maritalStatus'] = $encryptionHelper->decryptData($row['maritalStatus']);
}
jsonSuccess($rows);
} else {
// Print a failure message
jsonError($message = "No Phone verified yet found");
}
?>

View File

@@ -0,0 +1,38 @@
<?php
require_once __DIR__ . '/../connect.php';
// استقبال التاريخ المُراد عرض الملاحظات له
// إذا لم يتم إرسال تاريخ، نستخدم تاريخ اليوم الحالي
$filter_date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d');
// الاستعلام: جلب كافة الملاحظات لليوم المحدد مرتبة من الأحدث للأقدم
$sql = "SELECT * FROM `notesForDriverService`
WHERE DATE(`createdAt`) = '$filter_date'
ORDER BY `createdAt` DESC";
try {
$stmt = $con->prepare($sql);
$stmt->execute();
$notes_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($notes_data) {
// التصحيح: استخدام حلقة التكرار وتمرير الصف كمرجع (&) لتعديل البيانات الأصلية
foreach ($notes_data as &$row) {
// التأكد من وجود عمود الهاتف قبل فك التشفير
if (isset($row['phone'])) {
// استخدام دالة فك التشفير (تأكد أن الدالة decrypt موجودة في connect.php)
// أو استخدم $encryptionHelper->decryptData($row['phone']) إذا كنت تستخدم كلاس
$row['phone'] = $encryptionHelper->decryptData($row['phone']);
}
}
unset($row); // كسر الارتباط بالمتغير الأخير لضمان سلامة الكود
jsonSuccess($notes_data);
} else {
jsonError("No notes found for this date");
}
} catch (PDOException $e) {
jsonError("Database error: " . $e->getMessage());
}
?>

18
serviceapp/getPackages.php Executable file
View File

@@ -0,0 +1,18 @@
<?php
require_once __DIR__ . '/../connect.php';
$sql = "
SELECT * FROM `packageInfo`
";
$stmt = $con->prepare($sql);
$stmt->execute();
$passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($passenger_data) {
// Print the passenger data as JSON
jsonSuccess($data = $passenger_data);
} else {
// Print a failure message
jsonError($message = "No passenger data found");
}
?>

View File

@@ -0,0 +1,80 @@
<?php
require_once __DIR__ . '/../connect.php';
// استلام الرقم وتشفيره
$phone = filterRequest("phone");
$phoneEncrypted = $encryptionHelper->encryptData($phone);
$sql = "SELECT
p.*,
COALESCE(r.id, 0) AS ride_id,
COALESCE(r.start_location, '') AS start_location,
COALESCE(r.end_location, '') AS end_location,
COALESCE(r.date, '1970-01-01') AS ride_date,
COALESCE(r.time, '00:00:00') AS ride_time,
COALESCE(r.endtime, '00:00:00') AS ride_endtime,
COALESCE(r.price, 0) AS price,
COALESCE(r.passenger_id, 0) AS ride_passenger_id,
COALESCE(r.driver_id, 0) AS driver_id,
COALESCE(r.status, '') AS ride_status,
COALESCE(r.paymentMethod, '') AS ride_payment_method,
COALESCE(r.carType, '') AS car_type,
COALESCE(r.created_at, '1970-01-01 00:00:00') AS ride_created_at,
COALESCE(r.updated_at, '1970-01-01 00:00:00') AS ride_updated_at,
COALESCE(r.DriverIsGoingToPassenger, 0) AS driver_is_going_to_passenger,
COALESCE(r.rideTimeStart, '1970-01-01 00:00:00') AS ride_time_start,
COALESCE(r.rideTimeFinish, '1970-01-01 00:00:00') AS ride_time_finish,
COALESCE(r.price_for_driver, 0) AS price_for_driver,
COALESCE(r.price_for_passenger, 0) AS price_for_passenger,
COALESCE(r.distance, 0) AS distance,
COALESCE(pw.balance, 0) AS passenger_wallet_balance,
COALESCE(pay.amount, 0) AS passenger_payment_amount,
COALESCE(pay.payment_method, '') AS passenger_payment_method,
COALESCE(dw.amount, 0) AS driver_payment_amount,
COALESCE(dw.paymentMethod, '') AS driver_payment_method
FROM
passengers p
LEFT JOIN
ride r ON p.id = r.passenger_id
LEFT JOIN
passengerWallet pw ON p.id = pw.passenger_id
LEFT JOIN
payments pay ON r.id = pay.rideId
LEFT JOIN
driverWallet dw ON r.driver_id = dw.driverID AND pay.id = dw.paymentID
WHERE
p.phone = :phone
AND r.id = (
SELECT id
FROM ride
WHERE passenger_id = p.id
ORDER BY date DESC, time DESC
LIMIT 1
)";
$stmt = $con->prepare($sql);
$stmt->bindParam(':phone', $phoneEncrypted);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك التشفير للحقول الحساسة
foreach ($rows as &$row) {
if (isset($row['phone'])) $row['phone'] = $encryptionHelper->decryptData($row['phone']);
if (isset($row['email'])) $row['email'] = $encryptionHelper->decryptData($row['email']);
if (isset($row['gender'])) $row['gender'] = $encryptionHelper->decryptData($row['gender']);
if (isset($row['birthdate'])) $row['birthdate'] = $encryptionHelper->decryptData($row['birthdate']);
if (isset($row['site'])) $row['site'] = $encryptionHelper->decryptData($row['site']);
if (isset($row['first_name'])) $row['first_name'] = $encryptionHelper->decryptData($row['first_name']);
if (isset($row['last_name'])) $row['last_name'] = $encryptionHelper->decryptData($row['last_name']);
if (isset($row['employmentType']))$row['employmentType'] = $encryptionHelper->decryptData($row['employmentType']);
if (isset($row['maritalStatus'])) $row['maritalStatus'] = $encryptionHelper->decryptData($row['maritalStatus']);
unset($r['password']);
}
jsonSuccess($rows);
} else {
jsonError("No wallet record found");
}
?>

View File

@@ -0,0 +1,44 @@
<?php
require_once __DIR__ . '/../connect.php';
// استعلام رئيسي مع ربط صحيح وتشفير رقم الهاتف
$sql = "SELECT
phone_verification_passenger.*,
notesForPassengerService.note,
notesForPassengerService.editor,
notesForPassengerService.createdAt AS note_created_at
FROM
phone_verification_passenger
LEFT JOIN notesForPassengerService
ON notesForPassengerService.phone = phone_verification_passenger.phone_number
WHERE
phone_verification_passenger.phone_number NOT IN (
SELECT phone FROM passengers WHERE phone IS NOT NULL
)
AND phone_verification_passenger.created_at >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
ORDER BY
phone_verification_passenger.created_at DESC
LIMIT 25;
";
$stmt = $con->prepare($sql);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك التشفير إذا كان مطلوباً (مثلاً إذا phone_number مشفّر)
foreach ($rows as &$row) {
if (isset($row['phone_number'])) {
$row['phone_number'] = $encryptionHelper->decryptData($row['phone_number']);
}
if (isset($row['note'])) {
$row['note'] = $encryptionHelper->decryptData($row['note']); // إذا كانت مضافة مشفّرة
}
}
if ($rows) {
jsonSuccess($rows);
} else {
jsonError("No phone verified passengers found");
}
?>

View File

@@ -0,0 +1,63 @@
<?php
require_once __DIR__ . '/../connect.php';
// منع الأخطاء النصية وضبط الترويسة
error_reporting(0);
header('Content-Type: application/json');
// 1. استقبال التواريخ
if (isset($_POST['start_date']) && isset($_POST['end_date'])) {
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
} else {
// Fallback: استخدام الشهر والسنة الحالية أو المرسلة
$current_month = isset($_POST['month']) ? str_pad($_POST['month'], 2, "0", STR_PAD_LEFT) : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
$start_date = date('Y-m-d', strtotime("$current_year-$current_month-01"));
$end_date = date('Y-m-t', strtotime($start_date));
}
// 2. جملة SQL المعدلة
$sql = "
WITH RECURSIVE date_series AS (
SELECT '$start_date' AS date
UNION ALL
SELECT DATE_ADD(date, INTERVAL 1 DAY)
FROM date_series
WHERE date < '$end_date'
)
SELECT
date_series.date AS day,
-- (passengers) عدد الركاب اليومي
COALESCE((SELECT COUNT(id) FROM passengers WHERE DATE(passengers.created_at) = date_series.date), 0) AS totalPassengers,
-- (passengers) الإجمالي للفترة المحددة
(
SELECT COUNT(*)
FROM passengers
WHERE passengers.created_at BETWEEN '$start_date' AND '$end_date 23:59:59'
) AS totalMonthly
FROM
date_series
GROUP BY date_series.date
ORDER BY date_series.date ASC;
";
// ملاحظة: جعلت الترتيب ASC (تصاعدي) لأن الرسم البياني يحتاج الأيام من البداية للنهاية
try {
$stmt = $con->prepare($sql);
$stmt->execute();
$passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($passenger_data) {
echo json_encode(array("status" => "success", "message" => $passenger_data));
} else {
echo json_encode(array("status" => "success", "message" => []));
}
} catch (PDOException $e) {
echo json_encode(array("status" => "failure", "message" => $e->getMessage()));
}
?>

64
serviceapp/getRidesStatic.php Executable file
View File

@@ -0,0 +1,64 @@
<?php
require_once __DIR__ . '/../connect.php';
// 1. استقبال تواريخ البداية والنهاية بدلاً من الشهر والسنة فقط
if (isset($_POST['start_date']) && isset($_POST['end_date'])) {
// إذا أرسل التطبيق تواريخ محددة (الوضع الجديد)
$start_date = $_POST['start_date']; // Format: YYYY-MM-DD
$end_date = $_POST['end_date']; // Format: YYYY-MM-DD
} else {
// (Fallback) إذا لم يرسل تواريخ، نستخدم منطق الشهر والسنة القديم
$current_month = isset($_POST['month']) ? $_POST['month'] : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
// التأكد من أن صيغة الشهر خانتين
$current_month = str_pad($current_month, 2, "0", STR_PAD_LEFT);
$start_date = date('Y-m-d', strtotime($current_year . '-' . $current_month . '-01'));
$end_date = date('Y-m-t', strtotime($start_date));
}
// 2. جملة الـ SQL المعدلة لتعمل مع النطاق الزمني
$sql = "
WITH RECURSIVE date_series AS (
SELECT '$start_date' AS date
UNION ALL
SELECT DATE_ADD(date, INTERVAL 1 DAY)
FROM date_series
WHERE date < '$end_date'
)
SELECT
date_series.date AS day,
-- حساب الرحلات المنتهية في هذا اليوم
COALESCE(SUM(ride.status = 'Finished'), 0) AS totalRides,
-- حساب الإجمالي للفترة المحددة كاملة (وليس للشهر فقط)
(SELECT COUNT(*) FROM ride
WHERE ride.created_at >= '$start_date'
AND ride.created_at <= '$end_date 23:59:59'
AND ride.status = 'Finished') AS totalMonthly
FROM
date_series
LEFT JOIN
ride ON DATE(ride.created_at) = date_series.date
AND ride.status = 'Finished'
WHERE
date_series.date >= '$start_date'
AND date_series.date <= '$end_date'
GROUP BY
date_series.date
ORDER BY
date_series.date ASC;
";
$stmt = $con->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($data) {
jsonSuccess($data);
} else {
jsonError("No data found");
}
?>

View File

@@ -0,0 +1,30 @@
<?php
require_once __DIR__ . '/../connect.php';
$phoneNumber = filterRequest("phone_number");
$sql = "SELECT
d.id, d.name_arabic, d.phone, d.created_at
FROM
`driver` d
WHERE
d.id NOT IN (SELECT driverID FROM CarRegistration)
ORDER BY `d`.`created_at` DESC
";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك التشفير للحقول الحساسة
foreach ($rows as &$row) {
$row['phone'] = $encryptionHelper->decryptData($row['phone']);
$row['name_arabic'] = $encryptionHelper->decryptData($row['name_arabic']);
}
jsonSuccess($rows);
} else {
jsonError("No Car verified yet found");
}

View File

@@ -0,0 +1,101 @@
<?php
require_once __DIR__ . '/../connect.php';
// منع الأخطاء النصية وضبط الترويسة
error_reporting(0);
header('Content-Type: application/json');
// 1. استقبال التواريخ
if (isset($_POST['start_date']) && isset($_POST['end_date'])) {
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
} else {
// Fallback
$current_month = isset($_POST['month']) ? str_pad($_POST['month'], 2, "0", STR_PAD_LEFT) : date('m');
$current_year = isset($_POST['year']) ? $_POST['year'] : date('Y');
$start_date = date('Y-m-d', strtotime("$current_year-$current_month-01"));
$end_date = date('Y-m-t', strtotime($start_date));
}
// 2. جملة SQL المعدلة
$sql = "
WITH RECURSIVE date_series AS (
SELECT '$start_date' AS DATE
UNION ALL
SELECT DATE_ADD(DATE, INTERVAL 1 DAY)
FROM date_series
WHERE DATE < '$end_date'
)
SELECT
date_series.date AS day,
-- [1] إجمالي السائقين (الكلي في النظام)
(SELECT COUNT(*) FROM driver) AS totalDrivers,
-- [2] يومي: عدد السائقين المسجلين
(
SELECT COUNT(*)
FROM driver
WHERE DATE(driver.created_at) = date_series.date
) AS dailyTotalDrivers,
-- [3] يومي: عدد السائقين المتصل بهم (notesForDriverService)
(
SELECT COUNT(*)
FROM notesForDriverService
WHERE DATE(notesForDriverService.createdAt) = date_series.date
) AS dailyTotalCallingDrivers,
-- [4] يومي: Matching Notes (Join with driver on phone)
(
SELECT COUNT(*)
FROM notesForDriverService n
JOIN driver d ON n.phone = d.phone
WHERE DATE(n.createdAt) = date_series.date
) AS dailyMatchingNotes,
-- [5] إجمالي الفترة: سائقين
(
SELECT COUNT(*)
FROM driver
WHERE driver.created_at BETWEEN '$start_date' AND '$end_date 23:59:59'
) AS totalMonthlyDrivers,
-- [6] إجمالي الفترة: Calling Drivers
(
SELECT COUNT(*)
FROM notesForDriverService
WHERE notesForDriverService.createdAt BETWEEN '$start_date' AND '$end_date 23:59:59'
) AS totalMonthlyCallingDrivers,
-- [7] إجمالي الفترة: Matching Notes
(
SELECT COUNT(*)
FROM notesForDriverService n
JOIN driver d ON n.phone = d.phone
WHERE n.createdAt BETWEEN '$start_date' AND '$end_date 23:59:59'
) AS totalMonthlyMatchingNotes
FROM
date_series
GROUP BY
date_series.date
ORDER BY
date_series.date ASC;
";
try {
$stmt = $con->prepare($sql);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($data) {
echo json_encode(array("status" => "success", "message" => $data));
} else {
echo json_encode(array("status" => "success", "message" => []));
}
} catch (PDOException $e) {
echo json_encode(array("status" => "failure", "message" => $e->getMessage()));
}
?>

57
serviceapp/login.php Executable file
View File

@@ -0,0 +1,57 @@
<?php
require_once __DIR__ . '/../connect.php';
// Get email and password from the request
$email = filterRequest('email');
$password = filterRequest('password');
// Check if email and password are provided
if (empty($email) || empty($password)) {
echo json_encode([
"status" => "failure",
"message" => "Email and password are required."
]);
exit();
}
// SQL to check for user with provided email
$sql = "SELECT * FROM `users` WHERE `email` = :email";
$stmt = $con->prepare($sql);
$stmt->bindParam(':email', $email);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
header('Content-Type: application/json'); // Ensure the response is JSON
if ($user) {
// Verify the password
if ($password=== $user['password']) {
// Password is correct
unset($user['password']); // Remove password from the response
echo json_encode([
"status" => "success",
"message" => "Login successful",
"data" => $user
]);
} else {
// Password is incorrect
echo json_encode([
"status" => "failure",
"message" => "Incorrect password",
"password"=>$password,
"password1"=>$user['password'],
]);
}
} else {
// User not found
echo json_encode([
"status" => "failure",
"message" => "User not found"
]);
}
$stmt = null; // Close the statement
$con = null; // Close the connection
exit(); // Ensure no further output

View File

@@ -0,0 +1,237 @@
<?php
// --- 1. Dependencias y Conexión ---
require_once __DIR__ . '/../connect.php';
// دالة مساعدة لتسجيل الخطوات في ملف الـ LOG
function logStep($step, $message) {
error_log("[DriverReg] Step $step: $message");
}
try {
// --- بدء المعاملة ---
$con->beginTransaction();
logStep(1, "Transaction started via beginTransaction()");
// --- 2. Recolección de Datos (Conductor + Coche) ---
$phone = filterRequest("phone");
$password = filterRequest("password");
$firstName = filterRequest("first_name");
$lastName = filterRequest("last_name");
// تسجيل البيانات المبدئية (بدون كلمات المرور) للتأكد من وصولها
logStep(2, "Inputs received -> Phone: $phone, Name: $firstName $lastName");
// التحقق من الحقول الإجبارية
if (empty($phone) || empty($password) || empty($firstName) || empty($lastName)) {
throw new Exception("Required fields missing (phone, password, first_name, last_name).");
}
// --- 3. Generar ID de Conductor ---
$driverId = substr(md5($phone), 0, 20);
logStep(3, "Driver ID generated: $driverId");
// --- 4. Procesamiento de Datos del Conductor ---
$password_hashed = password_hash($password, PASSWORD_DEFAULT);
$email = filterRequest("email");
if (empty($email) || $email === 'Not specified') {
$email = $phone . '@intaleqapp.com';
}
$nameArabic = $firstName . ' ' . $lastName;
$site = filterRequest("site");
$address = $site;
// بيانات إضافية
$gender = filterRequest("gender");
$license_type = filterRequest("license_type");
$nationalNumber = filterRequest("national_number");
$issue_date = filterRequest("issue_date");
$expiry_date = filterRequest("expiry_date");
$licenseCategories = filterRequest("license_categories");
$licenseIssueDate = filterRequest("license_issue_date");
$birthdate = filterRequest("birthdate");
$maritalStatus = filterRequest("maritalStatus");
// --- 5. Recolección de Datos del Coche ---
$owner = filterRequest("owner");
$color = filterRequest("color");
$colorHex = filterRequest("color_hex");
$model = filterRequest("model");
$carPlate = filterRequest("car_plate");
$make = filterRequest("make");
$fuel = filterRequest("fuel");
$year = filterRequest("year");
$vin = filterRequest("vin");
if (empty($vin)) {
$vin = 'unknown';
}
$carExpirationDate = filterRequest("expiration_date");
logStep(4, "Data processing completed. Car Plate: $carPlate, VIN: $vin");
// --- 6. Cifrado de Datos ---
try {
$encryptedPhone = $encryptionHelper->encryptData($phone);
$encryptedEmail = $encryptionHelper->encryptData($email);
$encryptedFirstName = $encryptionHelper->encryptData($firstName);
$encryptedLastName = $encryptionHelper->encryptData($lastName);
$encryptedNameArabic = $encryptionHelper->encryptData($nameArabic);
$encryptedGender = $encryptionHelper->encryptData($gender);
$encryptedNationalNumber = $encryptionHelper->encryptData($nationalNumber);
$encryptedAddress = $encryptionHelper->encryptData($address);
$encryptedSite = $encryptionHelper->encryptData($site);
$encryptedBirthdate = $encryptionHelper->encryptData($birthdate);
$encryptedOwner = $encryptionHelper->encryptData($owner);
$encryptedCarPlate = $encryptionHelper->encryptData($carPlate);
logStep(5, "Encryption successful for sensitive fields.");
} catch (Exception $encEx) {
throw new Exception("Encryption Error: " . $encEx->getMessage());
}
// --- 7. Comprobación de Duplicados ---
// ملاحظة: إذا كان التشفير عشوائياً، فلن يجد التكرار هنا.
$dup = $con->prepare("SELECT id FROM driver WHERE phone = :phone OR email = :email OR national_number = :national_number");
$dup->execute([':phone' => $encryptedPhone, ':email' => $encryptedEmail, ':national_number' =>$encryptedNationalNumber]);
if ($dup->rowCount() > 0) {
logStep(6, "Duplicate found! Phone or Email or encryptedNationalNumber already exists.");
throw new Exception("Phone or email already registered.");
}
logStep(6, "No duplicates found. Proceeding.");
// --- 8. INSERCIÓN 1: Tabla 'driver' ---
$sqlDriver = "
INSERT INTO driver (
id, phone, email, password, gender, license_type, national_number,
name_arabic, issue_date, expiry_date, license_categories,
address, licenseIssueDate, status, birthdate, site,
first_name, last_name, accountBank, bankCode,
employmentType, maritalStatus, fullNameMaritial, expirationDate,
created_at, updated_at
) VALUES (
:id, :phone, :email, :pwd, :gender, :license_type, :national_number,
:name_arabic, :issue_date, :expiry_date, :license_categories,
:address, :licenseIssueDate, :status, :birthdate, :site,
:first_name, :last_name, :accountBank, :bankCode,
:employmentType, :maritalStatus, :fullNameMaritial, :expirationDate,
NOW(), NOW()
)
";
$stmtDriver = $con->prepare($sqlDriver);
// تم توحيد المفاتيح لتشمل النقطتين (:)
$driverData = [
':id' => $driverId,
':phone' => $encryptedPhone,
':email' => $encryptedEmail,
':pwd' => $password_hashed,
':gender' => $encryptedGender,
':license_type' => $license_type,
':national_number' => $encryptedNationalNumber,
':name_arabic' => $encryptedNameArabic,
':issue_date' => $issue_date,
':expiry_date' => $expiry_date,
':license_categories' => $licenseCategories ?? 'B',
':address' => $encryptedAddress,
':licenseIssueDate' => $licenseIssueDate,
':status' => 'actives',
':birthdate' => $encryptedBirthdate,
':site' => $encryptedSite,
':first_name' => $encryptedFirstName,
':last_name' => $encryptedLastName,
':accountBank' => 'yet',
':bankCode' => 'yet',
':employmentType' => $maritalStatus ?? 'yet',
':maritalStatus' => $maritalStatus ?? 'yet',
':fullNameMaritial' => 'yet',
':expirationDate' => 'yet',
];
if (!$stmtDriver->execute($driverData)) {
// تسجيل خطأ SQL بالتفصيل
$errInfo = $stmtDriver->errorInfo();
throw new Exception("Driver Insert Failed: " . $errInfo[2]);
}
logStep(7, "Driver table insert successful.");
// --- 9. INSERCIÓN 2: Tabla 'CarRegistration' ---
$sqlCar = "
INSERT INTO CarRegistration (
driverID, vin, owner, color, color_hex, model, car_plate,
make, fuel, `year`, expiration_date, created_at
) VALUES (
:driverId, :vin, :owner, :color, :color_hex, :model, :car_plate,
:make, :fuel, :year, :expiration_date, NOW()
)
";
$stmtCar = $con->prepare($sqlCar);
$carData = [
':driverId' => $driverId,
':vin' => $vin,
':owner' => $encryptedOwner,
':color' => $color,
':color_hex' => $colorHex,
':model' => $model,
':car_plate' => $encryptedCarPlate,
':make' => $make,
':fuel' => $fuel,
':year' => $year,
':expiration_date' => $carExpirationDate
];
if (!$stmtCar->execute($carData)) {
$errInfo = $stmtCar->errorInfo();
throw new Exception("Car Insert Failed: " . $errInfo[2]);
}
logStep(8, "CarRegistration insert successful.");
// --- 10. Confirmar Transacción ---
$con->commit();
logStep(9, "COMMIT successful. Sending Success Response.");
jsonSuccess(["driverId" => $driverId, "message" => "Driver and car registered successfully."]);
// --- 11. Enviar Notificación (خارج المعاملة يفضل، ولكن هنا كما في الكود الأصلي) ---
try {
$supportPhones = ['0952475740', '0952475742'];
$randomIndex = array_rand($supportPhones);
$phoneToUse = $supportPhones[$randomIndex];
$randomNumber = rand(1000, 999999);
$messageBody = "أهلاً وسهلاً كابتن $firstName 👋\n"
. "تم تفعيل حسابك على تطبيق *انطلق*.\n"
. "يمكنك الآن تسجيل الدخول والبدء بالعمل مباشرة.\n"
. "للمساعدة تواصل معنا على الرقم: $phoneToUse\n"
. "نتمنى لك عمل موفق 🚖\n\n"
. "معرف الرسالة: $randomNumber";
sendWhatsAppFromServer($phone, $messageBody);
logStep(10, "WhatsApp notification sent.");
} catch (Exception $waError) {
// لا نوقف العملية إذا فشل الواتساب، فقط نسجل الخطأ
logStep(10, "WhatsApp Warning: " . $waError->getMessage());
}
} catch (PDOException $e) {
$con->rollBack();
$errorMsg = "Database Error (PDO): " . $e->getMessage();
logStep("ERROR-PDO", $errorMsg);
// إظهار رسالة عامة للمستخدم، وتسجيل التفاصيل في السيرفر
jsonError("System error during registration. Please contact support.");
} catch (Exception $e) {
// إذا كانت المعاملة مفتوحة، قم بإلغائها
if ($con->inTransaction()) {
$con->rollBack();
}
$errorMsg = "General Error: " . $e->getMessage();
logStep("ERROR-GEN", $errorMsg);
jsonError($e->getMessage());
}
?>

92
serviceapp/updateDriver.php Executable file
View File

@@ -0,0 +1,92 @@
<?php
require_once __DIR__ . '/../connect.php';
// Retrieve driverID (allow 'id' or 'driverID')
$driverID = filterRequest("id") ?? filterRequest("driverID");
if (!$driverID) {
jsonError("Driver ID is required");
exit;
}
/* ---------------------------------------------------------
DRIVER TABLE
--------------------------------------------------------- */
$driverFieldsAllowed = [
"idn", "phone", "email", "password", "gender", "license_type",
"national_number", "name_arabic", "issue_date", "expiry_date",
"license_categories", "address", "licenseIssueDate", "status",
"birthdate", "site", "first_name", "last_name", "accountBank",
"bankCode", "employmentType", "maritalStatus", "fullNameMaritial",
"expirationDate", "created_at", "updated_at"
];
// Fields that must be encrypted
$encryptedDriverFields = [
"phone", "email", "password", "national_number","gender", "name_arabic", "first_name",
"last_name", "birthdate", "site", "maritalStatus", "employmentType"
];
$driverSet = [];
$driverParams = [":id" => $driverID];
foreach ($driverFieldsAllowed as $field) {
if (isset($_POST[$field]) && $_POST[$field] !== "") {
$value = filterRequest($field);
if (in_array($field, $encryptedDriverFields)) {
$value = $encryptionHelper->encryptData($value);
}
$driverSet[] = "`$field` = :$field";
$driverParams[":$field"] = $value;
}
}
// Execute Driver Update
$driverUpdated = false;
if (!empty($driverSet)) {
$driverSql = "UPDATE `driver` SET " . implode(", ", $driverSet) . " WHERE `id` = :id";
$stmt = $con->prepare($driverSql);
$stmt->execute($driverParams);
$driverUpdated = $stmt->rowCount() > 0;
}
/* ---------------------------------------------------------
CAR REGISTRATION TABLE
--------------------------------------------------------- */
$carFieldsAllowed = [
"id", "vin", "car_plate", "make", "model", "year",
"expiration_date", "color", "owner", "color_hex", "fuel",
"isDefault", "created_at", "status"
];
$carSet = [];
$carParams = [":driverID" => $driverID];
foreach ($carFieldsAllowed as $field) {
if ($field === "id") continue; // skip primary key in SET
if (isset($_POST[$field]) && $_POST[$field] !== "") {
$value = filterRequest($field);
$carSet[] = "`$field` = :$field";
$carParams[":$field"] = $value;
}
}
// Execute Car Update
$carUpdated = false;
if (!empty($carSet)) {
$carSql = "UPDATE `CarRegistration` SET " . implode(", ", $carSet) . " WHERE `driverID` = :driverID";
$stmtCar = $con->prepare($carSql);
$stmtCar->execute($carParams);
$carUpdated = $stmtCar->rowCount() > 0;
}
/* ---------------------------------------------------------
RESPONSE
--------------------------------------------------------- */
if ($driverUpdated || $carUpdated) {
jsonSuccess(null, "Driver & Car updated successfully");
} else {
jsonError("No changes were applied");
}
?>

View File

@@ -0,0 +1,150 @@
<?php
// --- تضمين الملفات الأساسية ---
require_once __DIR__ . '/../connect.php'; // يفترض أن يحتوي على الاتصال ومساعد التشفير
// --- استقبال البيانات من التطبيق ---
$driverId = filterRequest("driverId");
$phone = filterRequest("phone"); // استقبال رقم الهاتف مباشرة
// --- بيانات جدول السائق (driver) ---
$firstName = filterRequest("first_name");
$lastName = filterRequest("last_name");
$site = filterRequest("site"); // مكان القيد/الولادة
$nationalNumber = filterRequest("national_number");
$licenseCategories = filterRequest("license_categories"); // فئة الرخصة
$expiryDate = filterRequest("expiry_date"); // تاريخ انتهاء رخصة السائق
$licenseIssueDate = filterRequest("license_issue_date");
$gender = filterRequest("gender"); // الحقل الجديد
$birthdate = filterRequest("birthdate"); // الحقل الجديد
$maritalStatus=filterRequest("maritalStatus");
// --- بيانات جدول السيارة (CarRegistration) ---
$owner = filterRequest("owner");
$color = filterRequest("color");
$colorHex = filterRequest("color_hex");
$model = filterRequest("model"); // الموديل
$carPlate = filterRequest("car_plate");
$make = filterRequest("make"); // الصانع
$fuel = filterRequest("fuel");
$year = filterRequest("year");
$carExpirationDate = filterRequest("expiration_date"); // تاريخ انتهاء رخصة السيارة
// --- بدء المعاملة لضمان سلامة البيانات ---
$con->beginTransaction();
try {
// --- 1. معالجة وتشفير البيانات ---
$nameArabic = $firstName . ' ' . $lastName;
$address = $site;
// تشفير الحقول الحساسة
$encryptedFirstName = $encryptionHelper->encryptData($firstName);
$encryptedLastName = $encryptionHelper->encryptData($lastName);
$encryptedSite = $encryptionHelper->encryptData($site);
$encryptedAddress = $encryptionHelper->encryptData($address);
$encryptedNameArabic = $encryptionHelper->encryptData($nameArabic);
$encryptedNationalNumber = $encryptionHelper->encryptData($nationalNumber);
$encryptedOwner = $encryptionHelper->encryptData($owner);
$encryptedCarPlate = $encryptionHelper->encryptData($carPlate);
$encryptedBirthdate = $encryptionHelper->encryptData($birthdate);
$encryptedGender = $encryptionHelper->encryptData($gender);
// --- 2. تحديث جدول السائق ---
$sqlDriver = "UPDATE `driver` SET
`first_name` = :first_name,
`last_name` = :last_name,
`site` = :site,
`address` = :address,
`national_number` = :national_number,
`license_categories` = :license_categories,
`expiry_date` = :expiry_date,
`issue_date` = :issue_date,
`gender` = :gender,
`birthdate` = :birthdate,
`name_arabic` = :name_arabic,
`maritalStatus` = :maritalStatus,
`status` = 'actives'
WHERE `id` = :driverId";
$stmtDriver = $con->prepare($sqlDriver);
$stmtDriver->execute([
':first_name' => $encryptedFirstName,
':last_name' => $encryptedLastName,
':site' => $encryptedSite,
':address' => $encryptedAddress,
':national_number' => $encryptedNationalNumber,
':license_categories' => $licenseCategories,
':expiry_date' => $expiryDate,
':issue_date' => $licenseIssueDate,
':gender' => $encryptedGender,
':birthdate' => $encryptedBirthdate,
':name_arabic' => $encryptedNameArabic,
':driverId' => $driverId,
':maritalStatus' =>$maritalStatus
]);
// --- 3. تحديث جدول السيارة ---
$sqlCar = "UPDATE `CarRegistration` SET
`owner` = :owner,
`color` = :color,
`color_hex` = :color_hex,
`model` = :model,
`car_plate` = :car_plate,
`make` = :make,
`fuel` = :fuel,
`year` = :year,
`expiration_date` = :expiration_date
WHERE `driverID` = :driverId";
$stmtCar = $con->prepare($sqlCar);
$stmtCar->execute([
':owner' => $encryptedOwner,
':color' => $color,
':color_hex' => $colorHex,
':model' => $model,
':car_plate' => $encryptedCarPlate,
':make' => $make,
':fuel' => $fuel,
':year' => $year,
':expiration_date' => $carExpirationDate,
':driverId' => $driverId
]);
// --- 4. تأكيد المعاملة ---
$con->commit();
jsonSuccess(["message" => "Driver and car data updated successfully."]);
// --- 5. إرسال رسالة واتساب مبسطة وآمنة (باختيار رقم عشوائي) ---
// 5.1. تعريف الأرقام
$supportPhones = ['0952475740', '0952475742']; // يمكنك إضافة المزيد من الأرقام هنا
// 5.2. اختيار رقم عشوائي من القائمة
$randomIndex = array_rand($supportPhones); // يختار "مفتاح" عشوائي (index)
$phoneToUse = $supportPhones[$randomIndex]; // يحصل على الرقم من المفتاح
// --- !!! التعديل: إضافة رقم عشوائي ---
// هذا يضيف رقم عشوائي (4-6 خانات) لجعل الرسالة فريدة
$randomNumber = rand(1000, 999999);
// 5.5. إعداد نص الرسالة بالرقم المتغير
$messageBody = "أهلاً وسهلاً كابتن $firstName 👋\n"
. "تم تفعيل حسابك على تطبيق *انطلق*.\n"
. "يمكنك الآن تسجيل الدخول والبدء بالعمل مباشرة.\n"
. "للمساعدة تواصل معنا على الرقم: $phoneToUse\n" // <-- تم استخدام المتغير العشوائي هنا
. "نتمنى لك عمل موفق 🚖\n\n"
. "معرف الرسالة: $randomNumber"; // <-- إضافة الرقم العشوائي
// 5.6. إرسال الرسالة
sendWhatsAppFromServer($phone, $messageBody);
} catch (Exception $e) {
// --- 6. التراجع في حال الخطأ ---
$con->rollBack();
jsonError("An error occurred: " . $e->getMessage());
}
?>

26
serviceapp/updatePackages.php Executable file
View File

@@ -0,0 +1,26 @@
<?php
require_once __DIR__ . '/../connect.php';
// Get 'id' and 'version' from the request
$id = filterRequest("id");
$version = filterRequest("version");
$sql = "UPDATE `packageInfo` SET `version` ='$version' WHERE `id` = '$id'";
// Prepare and execute the statement
$stmt = $con->prepare($sql);
$stmt->execute();
error_log("Updating package: ID = $sql, Version = $version");
// Debugging: Check if the query affected any rows
if ($stmt->rowCount() > 0) {
// If rows were affected, print success
echo json_encode(['status' => 'success', 'message' => "Package version updated successfully for ID $id"]);
} else {
// If no rows were affected, print failure and debug the query
echo json_encode(['status' => 'failure', 'message' => "Failed to update package version. No rows affected. ID: $id, Version: $version"]);
}
?>

307
serviceapp/web/drivers.html Executable file
View File

@@ -0,0 +1,307 @@
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>نظام إدارة المركبات</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body { font-family: 'Cairo', sans-serif; background-color: #f8fafc; }
.skeleton {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: loading 1.5s infinite;
}
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
</style>
</head>
<body class="bg-slate-50 text-slate-800">
<nav class="bg-white shadow-sm border-b border-slate-200 sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between h-16 items-center">
<div class="flex items-center gap-2">
<i class="fas fa-car-side text-blue-600 text-2xl"></i>
<h1 class="text-xl font-bold text-slate-800">لوحة المركبات</h1>
</div>
<div class="flex items-center gap-3">
<span class="text-xs bg-green-50 text-green-600 px-2 py-1 rounded-full border border-green-200">
<i class="fas fa-circle text-[8px] ml-1"></i> متصل
</span>
</div>
</div>
</div>
</nav>
<main class="max-w-7xl mx-auto px-4 py-8">
<!-- Search Section -->
<div class="max-w-2xl mx-auto text-center mb-10">
<h2 class="text-2xl font-bold mb-6 text-slate-700">الاستعلام عن بيانات السائق والمركبة</h2>
<div class="relative group">
<input type="text" id="searchInput" placeholder="أدخل رقم الهاتف (مثال: 963...)"
onkeypress="handleEnter(event)"
class="w-full pl-4 pr-14 py-4 border-2 border-slate-200 rounded-2xl focus:border-blue-500 focus:ring-0 outline-none transition text-lg shadow-sm group-hover:border-slate-300">
<button onclick="fetchData()" class="absolute inset-y-2 left-2 bg-blue-600 hover:bg-blue-700 text-white px-6 rounded-xl transition font-medium">
بحث
</button>
<div class="absolute inset-y-0 right-0 flex items-center pr-5 pointer-events-none text-slate-400">
<i class="fas fa-search text-xl"></i>
</div>
</div>
</div>
<div id="statusMessage" class="hidden max-w-2xl mx-auto mb-6"></div>
<!-- Results Grid -->
<div id="resultsGrid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"></div>
<!-- Empty State -->
<div id="emptyState" class="hidden text-center py-20">
<div class="inline-flex bg-slate-100 p-6 rounded-full mb-4">
<i class="fas fa-fingerprint text-4xl text-slate-300"></i>
</div>
<p class="text-slate-500">أدخل رقم الهاتف للبدء</p>
</div>
</main>
<!-- Modal -->
<div id="detailsModal" class="fixed inset-0 bg-black/60 z-50 hidden flex items-center justify-center p-4 backdrop-blur-sm transition-opacity duration-300 opacity-0">
<div class="bg-white rounded-3xl shadow-2xl w-full max-w-md overflow-hidden transform scale-95 transition-all duration-300" id="modalContent">
<div class="relative bg-slate-800 p-6 text-center text-white overflow-hidden">
<div class="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500"></div>
<h3 id="modalTitle" class="text-2xl font-bold mb-1"></h3>
<p id="modalYear" class="text-slate-400 text-sm"></p>
<button onclick="closeModal()" class="absolute top-4 right-4 text-white/50 hover:text-white transition">
<i class="fas fa-times text-xl"></i>
</button>
</div>
<div class="p-6 space-y-6">
<!-- Owner Info -->
<div class="flex items-center gap-4">
<div class="w-12 h-12 rounded-full bg-blue-50 text-blue-600 flex items-center justify-center text-xl">
<i class="fas fa-user"></i>
</div>
<div>
<p class="text-xs text-slate-400 uppercase tracking-wider">المالك / السائق</p>
<p id="modalOwner" class="font-bold text-slate-800 text-lg"></p>
</div>
</div>
<!-- Car Plate & Color -->
<div class="grid grid-cols-2 gap-4">
<div class="bg-slate-50 p-3 rounded-xl border border-slate-100 text-center">
<p class="text-xs text-slate-400 mb-1">رقم اللوحة</p>
<p id="modalPlate" class="font-mono font-bold text-slate-800 text-lg dir-ltr"></p>
</div>
<div class="bg-slate-50 p-3 rounded-xl border border-slate-100 text-center">
<p class="text-xs text-slate-400 mb-1">اللون</p>
<div class="flex items-center justify-center gap-2">
<span id="modalColorDot" class="w-4 h-4 rounded-full shadow-sm border border-slate-200"></span>
<span id="modalColor" class="font-bold text-slate-800"></span>
</div>
</div>
</div>
<!-- Details List -->
<div class="space-y-3 pt-2">
<div class="flex justify-between items-center text-sm border-b border-slate-100 pb-2">
<span class="text-slate-500">الشركة المصنعة</span>
<span id="modalMake" class="font-medium text-slate-800"></span>
</div>
<div class="flex justify-between items-center text-sm border-b border-slate-100 pb-2">
<span class="text-slate-500">رقم الهاتف</span>
<span id="modalPhone" class="font-medium text-slate-800 dir-ltr"></span>
</div>
<div class="flex justify-between items-center text-sm border-b border-slate-100 pb-2">
<span class="text-slate-500">رقم الهيكل (VIN)</span>
<span id="modalVin" class="font-mono text-xs text-slate-600 bg-slate-100 px-2 py-1 rounded"></span>
</div>
<div class="flex justify-between items-center text-sm pt-1">
<span class="text-slate-500">حالة الصلاحية</span>
<span id="modalExpiry"></span>
</div>
</div>
</div>
<div class="p-4 bg-slate-50 border-t border-slate-100">
<button onclick="closeModal()" class="w-full py-3 bg-white border border-slate-200 text-slate-600 rounded-xl hover:bg-slate-50 transition font-medium">
إغلاق
</button>
</div>
</div>
</div>
<script>
const API_URL = "https://api.intaleq.xyz/intaleq/serviceapp/web/getDrivers.php";
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('emptyState').classList.remove('hidden');
});
function handleEnter(e) { if(e.key === 'Enter') fetchData(); }
async function fetchData() {
const grid = document.getElementById('resultsGrid');
const emptyState = document.getElementById('emptyState');
const statusMsg = document.getElementById('statusMessage');
const searchInput = document.getElementById('searchInput').value.trim();
statusMsg.classList.add('hidden');
if (!searchInput) {
showError("الرجاء إدخال رقم الهاتف");
return;
}
grid.innerHTML = generateSkeletons(1);
emptyState.classList.add('hidden');
try {
const url = `${API_URL}?phone_number=${encodeURIComponent(searchInput)}`;
const response = await fetch(url);
const textResponse = await response.text();
let rows = [];
try {
const json = JSON.parse(textResponse);
if (Array.isArray(json)) rows = json;
else if (json.status === "success" && json.data) rows = Array.isArray(json.data) ? json.data : [json.data];
else if (json.data) rows = [json.data]; // fallback
} catch (e) {
throw new Error("بيانات غير صالحة من السيرفر");
}
if (!rows || rows.length === 0) {
throw new Error("لم يتم العثور على بيانات لهذا الرقم");
}
renderCards(rows);
} catch (error) {
console.error(error);
grid.innerHTML = '';
showError(error.message);
}
}
function renderCards(data) {
const grid = document.getElementById('resultsGrid');
grid.innerHTML = '';
data.forEach(item => {
// منطق العرض: إذا كانت الماركة موجودة نعرضها، وإلا نعرض "لا توجد سيارة"
const hasCar = item.make && item.model;
const displayTitle = hasCar ? `${item.make} ${item.model}` : 'لا توجد مركبة مسجلة';
const displayOwner = item.owner || item.driverName || 'مجهول';
const displayPlate = item.car_plate || '---';
const displayYear = item.year || '';
// Expiry Logic
let expiryBadge = '<span class="text-slate-400 text-xs">غير محدد</span>';
if (item.expiration_date) {
const isExpired = new Date(item.expiration_date) < new Date();
expiryBadge = isExpired
? `<span class="bg-red-100 text-red-600 text-xs px-2 py-1 rounded font-bold">منتهي</span>`
: `<span class="bg-green-100 text-green-600 text-xs px-2 py-1 rounded font-bold">ساري</span>`;
}
const cardHTML = `
<div class="bg-white rounded-2xl shadow-sm border border-slate-100 hover:shadow-md transition duration-300 overflow-hidden group">
<div class="h-2 w-full" style="background-color: ${item.color_hex || '#cbd5e1'}"></div>
<div class="p-5">
<div class="flex justify-between items-start mb-4">
<div>
<h3 class="font-bold text-lg text-slate-800">${displayTitle}</h3>
${displayYear ? `<span class="text-xs bg-slate-100 text-slate-500 px-2 py-0.5 rounded mt-1 inline-block">${displayYear}</span>` : ''}
</div>
${expiryBadge}
</div>
<div class="flex items-center gap-3 mb-4 p-3 bg-slate-50 rounded-xl border border-slate-100">
<div class="w-10 h-10 rounded-full bg-white text-blue-500 flex items-center justify-center shadow-sm">
<i class="fas fa-user"></i>
</div>
<div class="overflow-hidden">
<p class="text-xs text-slate-400">الاسم</p>
<p class="font-bold text-slate-700 truncate">${displayOwner}</p>
</div>
</div>
<div class="flex justify-between items-center">
<div class="text-sm text-slate-500">
<i class="fas fa-barcode ml-1 opacity-50"></i>
<span class="font-mono dir-ltr">${displayPlate}</span>
</div>
<button onclick='openModal(${JSON.stringify(item)})' class="text-blue-600 hover:text-blue-700 font-bold text-sm">
التفاصيل <i class="fas fa-arrow-left mr-1"></i>
</button>
</div>
</div>
</div>`;
grid.innerHTML += cardHTML;
});
}
function openModal(item) {
const modal = document.getElementById('detailsModal');
const content = document.getElementById('modalContent');
// Populate Data
const hasCar = item.make && item.model;
document.getElementById('modalTitle').innerText = hasCar ? `${item.make} ${item.model}` : 'لا توجد مركبة';
document.getElementById('modalYear').innerText = item.year || '';
document.getElementById('modalOwner').innerText = item.owner || item.driverName || '---';
document.getElementById('modalPlate').innerText = item.car_plate || '---';
document.getElementById('modalColor').innerText = item.color || 'غير محدد';
document.getElementById('modalColorDot').style.backgroundColor = item.color_hex || '#e2e8f0';
document.getElementById('modalMake').innerText = item.make || '-';
document.getElementById('modalPhone').innerText = item.phone || '-';
document.getElementById('modalVin').innerText = item.vin || '---';
const expiryEl = document.getElementById('modalExpiry');
if (item.expiration_date) {
const isExpired = new Date(item.expiration_date) < new Date();
expiryEl.innerHTML = isExpired
? `<span class="text-red-600 font-bold">${item.expiration_date} (منتهي)</span>`
: `<span class="text-green-600 font-bold">${item.expiration_date} (ساري)</span>`;
} else {
expiryEl.innerText = 'غير محدد';
}
// Animation
modal.classList.remove('hidden');
setTimeout(() => {
modal.classList.remove('opacity-0');
content.classList.remove('scale-95');
content.classList.add('scale-100');
}, 10);
}
function closeModal() {
const modal = document.getElementById('detailsModal');
const content = document.getElementById('modalContent');
modal.classList.add('opacity-0');
content.classList.remove('scale-100');
content.classList.add('scale-95');
setTimeout(() => modal.classList.add('hidden'), 300);
}
function showError(msg) {
const el = document.getElementById('statusMessage');
el.innerHTML = `<div class="bg-red-50 text-red-600 p-4 rounded-xl border border-red-100 flex items-center gap-3"><i class="fas fa-exclamation-circle text-xl"></i><span>${msg}</span></div>`;
el.classList.remove('hidden');
}
function generateSkeletons(count) {
return `<div class="bg-white p-5 rounded-2xl border border-slate-100"><div class="h-4 bg-slate-100 w-1/3 mb-4 rounded skeleton"></div><div class="h-20 bg-slate-100 rounded-xl skeleton"></div></div>`;
}
</script>
</body>
</html>

0
serviceapp/web/f.html Executable file
View File

87
serviceapp/web/getDrivers.php Executable file
View File

@@ -0,0 +1,87 @@
<?php
// إعدادات الإنتاج (إخفاء الأخطاء عن المستخدم)
ini_set('display_errors', 0);
error_reporting(E_ALL);
// ضبط الترويسة والترميز UTF-8 هام جداً للنصوص العربية
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/../../get_connect.php';
// ضمان خروج النصوص العربية من قاعدة البيانات بشكل سليم
if (isset($con)) {
$con->exec("set names utf8mb4");
}
$phone = "";
if (isset($_GET['phone_number'])) {
$phone = htmlspecialchars(strip_tags($_GET['phone_number']));
} elseif (isset($_POST['phone_number'])) {
$phone = htmlspecialchars(strip_tags($_POST['phone_number']));
} else {
$phone = filterRequest("phone_number");
}
if (empty($phone)) {
jsonError("Phone number is required");
exit;
}
// تشفير الرقم للبحث
$phoneEncrypted = $encryptionHelper->encryptData($phone);
// الاستعلام: نختار الحقول بدقة لتجنب التضارب
$sql = "SELECT
d.id as driver_id,
d.name_arabic as driver_name_encrypted, -- الاسم من جدول السائق
d.phone as phone_encrypted,
d.gender as gender_encrypted
FROM
`driver` d
WHERE
d.phone = ?
LIMIT 1";
try {
$stmt = $con->prepare($sql);
$stmt->execute([$phoneEncrypted]);
if ($stmt->rowCount() > 0) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as &$item) {
// ============================================
// 1. فك تشفير الحقول المشفرة فقط (حسب ملف CSV)
// ============================================
// بيانات السائق
if (!empty($item['driver_name_encrypted'])) {
$item['driverName'] = $encryptionHelper->decryptData($item['driver_name_encrypted']);
}
if (!empty($item['phone_encrypted'])) {
$item['phone'] = $encryptionHelper->decryptData($item['phone_encrypted']);
}
if (!empty($item['gender_encrypted'])) {
$item['gender'] = $encryptionHelper->decryptData($item['gender_encrypted']);
}
}
jsonSuccess($rows);
} else {
jsonError("No driver found with this phone number");
}
} catch (PDOException $e) {
error_log("SQL Error: " . $e->getMessage());
jsonError("Database error");
} catch (Exception $e) {
error_log("General Error: " . $e->getMessage());
jsonError("System error");
}
?>

View File

@@ -0,0 +1,65 @@
<?php
require_once __DIR__ . '/../../connect.php';
header('Content-Type: application/json; charset=utf-8');
// دوال مساعدة لو لم تكن موجودة
// جلب بيانات السيارة من الطلب
$owner_name = $encryptionHelper->encryptData(filterRequest("owner_name"));
$phone = $encryptionHelper->encryptData(filterRequest("phone")); // 🔒
$car_number = $encryptionHelper->encryptData(filterRequest("car_number"));
$manufacture_year = filterRequest("manufacture_year");
$car_model = filterRequest("car_model");
$car_type = filterRequest("car_type");
$site = filterRequest("site");
$registration_date = filterRequest("registration_date");
// تحقق بسيط من القيم المطلوبة
if (empty($owner_name) || empty($phone)) {
jsonError("Missing required fields", 422);
}
// SQL مع bind parameters
$sql = "INSERT INTO `carsToWork`(
`owner_name`,
`phone`,
`car_number`,
`manufacture_year`,
`car_model`,
`car_type`,
`site`,
`registration_date`
) VALUES (
:owner_name,
:phone,
:car_number,
:manufacture_year,
:car_model,
:car_type,
:site,
:registration_date
)";
try {
$stmt = $con->prepare($sql);
$stmt->bindParam(':owner_name', $owner_name);
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':car_number', $car_number);
$stmt->bindParam(':manufacture_year', $manufacture_year);
$stmt->bindParam(':car_model', $car_model);
$stmt->bindParam(':car_type', $car_type);
$stmt->bindParam(':site', $site);
$stmt->bindParam(':registration_date', $registration_date);
if ($stmt->execute()) {
printSuccess("Car data saved successfully", ["insert_id" => $con->lastInsertId()]);
} else {
$err = $stmt->errorInfo();
jsonError("Failed to save car data: " . ($err[2] ?? 'unknown error'), 500);
}
} catch (Exception $e) {
jsonError("Exception: " . $e->getMessage(), 500);
}
?>

View File

@@ -0,0 +1,45 @@
<?php
require_once __DIR__ . '/../../connect.php';
// جلب البيانات من الطلب
$driver_name = filterRequest("driver_name");
$national_id = filterRequest("national_id");
$birth_date = filterRequest("birth_date");
$license_type = filterRequest("license_type");
$phone = filterRequest("phone");
$site = filterRequest("site");
// إعداد استعلام آمن باستخدام bind parameters
$sql = "INSERT INTO `driversWantWork`(
`driver_name`,
`phone`,
`national_id`,
`birth_date`,
`license_type`,
`site`
) VALUES (
:driver_name,
:phone,
:national_id,
:birth_date,
:license_type,
:site
)";
$stmt = $con->prepare($sql);
// ربط القيم
$stmt->bindParam(':driver_name', $driver_name);
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':national_id', $national_id);
$stmt->bindParam(':birth_date', $birth_date);
$stmt->bindParam(':license_type', $license_type);
$stmt->bindParam(':site', $site);
// تنفيذ الاستعلام
if ($stmt->execute()) {
jsonSuccess(null, "Driver data saved successfully");
} else {
jsonError("Failed to save driver data");
}
?>