<?php
error_reporting(1);
ini_set('display_errors', 1);
session_start();
if(!isset($_SESSION['id']) || $_SESSION['id']=='')
{
	http_response_code(401);
    echo json_encode(array('error_text' => 'User Not AUthenticated'));
    exit;
}


//include_once "../ichat/admin/route.php";
require_once 'database.php';
/*if(isset($_SESSION[$elhash]) && $_SESSION[$elhash] != "") { 
    $random_hash = $_SESSION[$elhash];
} else {
    $random_hash = uniqid();
    $_SESSION[$elhash] = $random_hash;
}*/


if(!isset($_POST['id']) || !is_numeric($_POST['id']))
{
	http_response_code(401);
    echo json_encode(array('error_text' => 'Cenas Table Item ID not found'));
    exit;
}

$id = $_POST['id'];

class cenas_delete_item_ajax extends database
{
	public function cenasDeleteItem($id)
	{
        $data['deleted_at'] = date("Y-m-d H:i:s");
        $where['id'] = $id;
		return $this->update('cenas_item', $data, $where);
	}
}


$obj = new cenas_delete_item_ajax();
$res = $obj->cenasDeleteItem($id);
if(!$res)
{
	http_response_code(500);
    echo json_encode(array('error_text' => 'Something Went Wrong'));
    exit;
}

http_response_code(200);
    echo json_encode(array('message' => 'Item Deleted Successfully'));
    exit;
