<?php

require_once __DIR__ . '/db_config.php';
require_once __DIR__ . '/notify.php';

$r = array();

if (isset($_POST["report_id"]) ) {
 
$report_id=$_POST["report_id"];
$cname=$_POST["cname"];
$user_id=$_POST["email"];
$emp_id=$_POST["emp_id"];

$reason="NA";
if(isset($_POST["reason"])){
    $reason = $_POST["reason"];
}

date_default_timezone_set("Asia/Calcutta");   //India time (GMT+5:30)
$datetime=date('Y-m-d H:i:s');

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

$query="UPDATE defect_report 
    SET resubmission_DT='$datetime',resubmission_user_id='$user_id',resubmission=1 
    WHERE report_id='$report_id' AND companyname='$cname'";

    $result=mysqli_query($con,$query) ;
    if($result){
        $r["s"] = 1;
        $noity=new notify();
        $message=$report_id.' '.' - Re Submit Report';
        $noity->send($con,$emp_id,$report_id,$message);
    }else{
        $r["s"] = 0;
    }

mysqli_close($con);

}

echo json_encode($r,JSON_UNESCAPED_SLASHES);


?>