-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_tasks_projects.php
More file actions
34 lines (29 loc) · 965 Bytes
/
fetch_tasks_projects.php
File metadata and controls
34 lines (29 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
session_start();
include "Connect.php";
if (!isset($_SESSION['emp_id'])) {
echo json_encode(['status'=>'error','message'=>'Access denied']);
exit;
}
$emp_id = $_SESSION['emp_id'];
$type = $_GET['type'] ?? '';
if($type === 'task'){
$stmt = $conn->prepare("SELECT task_name, task_description, status FROM daily_tasks WHERE assigned_to=? ORDER BY id DESC");
$stmt->bind_param("i", $emp_id);
} elseif($type === 'project'){
$stmt = $conn->prepare("SELECT project_name, project_description, start_date, end_date, status FROM projects WHERE assigned_to=? ORDER BY id DESC");
$stmt->bind_param("i", $emp_id);
} else {
echo json_encode(['status'=>'error','message'=>'Invalid type']);
exit;
}
$stmt->execute();
$res = $stmt->get_result();
$data = [];
while($row = $res->fetch_assoc()){
$data[] = $row;
}
echo json_encode(['status'=>'success','data'=>$data]);
$stmt->close();
$conn->close();
?>