<?php

require_once __DIR__ . '/db_config.php';

$response = array();
$response["activities"] = array();

if ( isset($_POST["cname"]) ) {
 
$cname=$_POST["cname"];
$id=$_POST["id"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());

$employeeQuery="SELECT ta.project_id,ta.milestone_id,ta.tasklist_id,ta.task_id,ta.assign_id,ta.request_id,ta.project_id,ta.created_by,ta.responsible_person,ta.act_description,ta.act_datetime,DATE(ta.act_datetime) as act_date,ta.act_tag_id,ta.act_dependence_id,t1.task_name,ta.act_p_status,ta.project_id,p.project_name,ta.milestone_id,m.milestone_name,ta.tasklist_id,l.listtask_name,ta.task_id,t1.task_name,ta.assign_id,a.employee_id as aemployee,ta.request_id,r.employee_id as remployee FROM task_activity ta LEFT JOIN task_task t1 ON t1.task_id=ta.task_id LEFT JOIN task_project p ON p.project_id =ta.project_id LEFT JOIN task_milestone m ON m.milestone_id=ta.milestone_id LEFT JOIN task_listtask l ON l.listtask_id=ta.tasklist_id LEFT JOIN task_assign a ON a.assign_id=ta.assign_id LEFT JOIN task_progress pr ON pr.id=ta.progress_id LEFT JOIN task_request r ON r.id=ta.request_id WHERE ta.project_id='$id' ORDER BY ta.id desc";

$employeeResult=mysqli_query($con,$employeeQuery);
if(!empty($employeeResult) && mysqli_num_rows($employeeResult) > 0){
    while ($row = mysqli_fetch_array($employeeResult,MYSQLI_ASSOC)) {
        array_push($response["activities"], $row);
    }
}
mysqli_close($con);

}

echo json_encode($response);


?>