<?php
session_start();
include("../config/config.php");

if ($_SESSION['role'] != 'admin') die("Access denied");

$fid = $_POST['feedback_id'];
$admin_id = $_SESSION['user_id'];
$status = $_POST['status'];
$remarks = $_POST['remarks'] ?? '';

if ($status == 'accepted') {
    $sql = "UPDATE feedbacks 
            SET status='accepted', admin_id=?, reason=? 
            WHERE feedback_id=?";
    $stmt = $con->prepare($sql);
    $stmt->bind_param("isi", $admin_id, $remarks, $fid);
    $stmt->execute();
}
elseif ($status == 'rejected') {
    $sql = "UPDATE feedbacks 
            SET status='rejected', admin_id=?, reason=? 
            WHERE feedback_id=?";
    $stmt = $con->prepare($sql);
    $stmt->bind_param("isi", $admin_id, $remarks, $fid);
    $stmt->execute();
}

header("Location: ../public/admin/manage_feedback.php");
exit;
?>
