Mini Shell
<?php
session_start();
$rootPath = dirname(__FILE__);
require_once $rootPath . '/config/config.php';
// Set header to return JSON
header('Content-Type: application/json');
// Check if complaint_id is provided
if (!isset($_POST['complaint_id']) || empty($_POST['complaint_id'])) {
echo json_encode(['error' => 'No complaint ID provided']);
exit;
}
$complaintId = mysqli_real_escape_string($conn, $_POST['complaint_id']);
// Query to check if there are any responses for this complaint
$query = "SELECT COUNT(*) as response_count FROM responce_trend WHERE ComplaintID = '$complaintId'";
$result = mysqli_query($conn, $query);
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$responseCount = (int)$row['response_count'];
echo json_encode([
'has_responses' => $responseCount > 0,
'response_count' => $responseCount
]);
} else {
echo json_encode([
'has_responses' => false,
'response_count' => 0
]);
}
?>