first commit
This commit is contained in:
43
backend/serviceapp/getEmployeeStatic.php
Executable file
43
backend/serviceapp/getEmployeeStatic.php
Executable 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");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user