80 lines
2.7 KiB
PHP
80 lines
2.7 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
// Ensure admin is logged in
|
|
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
|
header('Location: admin.php');
|
|
exit;
|
|
}
|
|
|
|
// Check for Submission ID
|
|
if (!isset($_GET['id'])) {
|
|
header('Location: admin.php');
|
|
exit;
|
|
}
|
|
$submission_id = $_GET['id'];
|
|
|
|
// Fetch submission details
|
|
$submission_stmt = db()->prepare("SELECT s.name, s.email, s.created_at, sv.title as survey_title FROM feedback_submissions s JOIN surveys sv ON s.survey_id = sv.id WHERE s.id = ?");
|
|
$submission_stmt->execute([$submission_id]);
|
|
$submission = $submission_stmt->fetch();
|
|
if (!$submission) {
|
|
header('Location: admin.php');
|
|
exit;
|
|
}
|
|
|
|
// Fetch answers for the submission
|
|
$answers_stmt = db()->prepare("SELECT q.question_text, a.answer_text FROM survey_answers a JOIN survey_questions q ON a.question_id = q.id WHERE a.submission_id = ? ORDER BY q.created_at ASC");
|
|
$answers_stmt->execute([$submission_id]);
|
|
$answers = $answers_stmt->fetchAll();
|
|
|
|
$pageTitle = "View Submission";
|
|
require_once 'templates/header.php';
|
|
?>
|
|
|
|
<main>
|
|
<section class="survey-section">
|
|
<div class="container">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1>Submission Details</h1>
|
|
<a href="admin.php" class="btn btn-secondary">Back to All Submissions</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3>Survey: <?= htmlspecialchars($submission['survey_title']) ?></h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<p><strong>Submitter:</strong> <?= htmlspecialchars($submission['name']) ?></p>
|
|
<p><strong>Email:</strong> <?= htmlspecialchars($submission['email']) ?></p>
|
|
<p><strong>Submitted At:</strong> <?= $submission['created_at'] ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h3>Answers</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-striped">
|
|
<tbody>
|
|
<?php foreach ($answers as $answer): ?>
|
|
<tr>
|
|
<th style="width: 30%;"><?= htmlspecialchars($answer['question_text']) ?></th>
|
|
<td><?= nl2br(htmlspecialchars($answer['answer_text'])) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<?php
|
|
require_once 'templates/footer.php';
|
|
?>
|