|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/public_html/js/../pms/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
http_response_code(401);
exit;
}
require_once '../config/config.php';
require_once '../config/db.php';
header('Content-Type: application/json');
$current_user_role = $_SESSION['role'] ?? 'Employee';
$current_user_id = $_SESSION['admin_id'];
try {
// Get tasks due in next 30 DAYS (not completed, not on hold)
if ($current_user_role === 'Employee') {
// Employees see only their tasks
$query = "SELECT t.*,
u.fname as employee_name
FROM tbl_tasks t
LEFT JOIN tbl_user u ON t.employee_id = u.uid
WHERE t.employee_id = ?
AND t.deadline_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 30 DAY)
AND t.status NOT IN ('Completed', 'On Hold')
ORDER BY t.deadline_date ASC, t.priority DESC
LIMIT 10";
$stmt = mysqli_prepare($con, $query);
mysqli_stmt_bind_param($stmt, "i", $current_user_id);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
} else {
// CEO and Manager see all tasks
$query = "SELECT t.*,
u.fname as employee_name
FROM tbl_tasks t
LEFT JOIN tbl_user u ON t.employee_id = u.uid
WHERE t.deadline_date BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 30 DAY)
AND t.status NOT IN ('Completed', 'On Hold')
ORDER BY t.deadline_date ASC, t.priority DESC
LIMIT 10";
$result = mysqli_query($con, $query);
}
$tasks = [];
while ($row = mysqli_fetch_assoc($result)) {
$tasks[] = $row;
}
echo json_encode([
'success' => true,
'tasks' => $tasks,
'count' => count($tasks)
]);
} catch (Exception $e) {
echo json_encode([
'success' => false,
'message' => $e->getMessage()
]);
}
?>