<?php

require_once __DIR__ . '/db_config.php';

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

if (isset($_POST["mail"]) ) {
 
$cname=$_POST["cname"];
$projectId=$_POST["project_id"];
$mail=$_POST["mail"];
$role=$_POST["role"];

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());
$query="SELECT task_request.id,task_request.increasedays,task_task.task_name,signupdetails.employeename,task_request.r_status FROM `task_request` INNER JOIN task_task ON task_task.task_id=task_request.task_id INNER JOIN signupdetails ON signupdetails.emailid=task_request.employee_id WHERE task_request.r_status!='pending' AND task_request.deleted='no' AND task_task.t_project_id='$projectId'";

if($role=="employee"){
    $query=$query." AND task_request.employee_id='$mail' ";
}




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

}

echo json_encode($response);


?>

