<?php

$response = array();

// include db connect class
require_once __DIR__ . '/db_config.php';
require_once __DIR__ . '/notify.php';

    
// check for required fields
if (isset($_POST['data']))  {

$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die(mysql_error());
$json=json_decode($_POST['data'],true);
$noity=new notify();

$mail= $json['mail'];
$cname=$json["cname"];
$role=$json["role"];
$taskId=$json["id"];
$assignId=$json["assignId"];
$reason=$json["reason"];
$progress=$json["progress"];
$employee=$json["employee"];

date_default_timezone_set('Asia/Calcutta');
$dt=date('Y-m-d H:i:s');
$date=date('Y-m-d');

$query="UPDATE task_task set t_progress='$progress' where task_id='$taskId'";
$response["s"] =mysqli_query($con,$query);
$query="INSERT INTO task_progress(task_id,progress_by_type,progress_by, employee_id,progress_date,progress,completed_activities,completed_datetime) VALUES ('$taskId','$role','$mail','$employee','$date','$progress','$reason','$dt')";
mysqli_query($con,$query);

if($response["s"]){
    $noity->send($con,$employee,$taskId,"Task Progress Reduced","task");
}


mysqli_close($con);
} 
    echo json_encode($response);

?>