<?php
error_reporting(1);
ini_set('display_errors', 1);
session_start();
if(!isset($_SESSION['id']) || $_SESSION['id']=='')
{
	http_response_code(401);
    echo json_encode('Authentication Problem');
    exit;
}
if(!isset($_SESSION['user_type']) || ($_SESSION['user_type'] != 'admin'))
{
	//http_response_code(401);
   // echo json_encode('Authentication Problem');
   // exit;
}

require_once 'database.php';
class delete extends database
{
    public function index($id)
    {
        $data['deleted_at']=date('Y-m-d H:i:s');
        $where['id'] = $id;
        return $this->update('submission', $data, $where);
    }
	
  
}

if(!isset($_POST['id']) || !is_numeric($_POST['id']))
{
    http_response_code(400);
    echo json_encode('Submission Not Found');
    exit;
}
$id = $_POST['id'];

$update = new delete();

$msg = "";
$res = $update->index($id);
if($res)
{
    http_response_code(200);
    echo json_encode('Submission Deleted Successfully');
    exit;
}
                
http_response_code(500);
echo json_encode('Something went wrong');
exit;
?>