<?php
declare(strict_types=1);

require_once __DIR__ . '/../../security/auth_guard.php';
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../../core/Response.php';

$db = Database::getInstance();
$data = json_decode(file_get_contents('php://input'), true);

if (empty($data['id'])) {
    Response::error('Section ID required', 422);
}

$stmt = $db->prepare("
    UPDATE retail_product_sections
    SET status = 'InActive',
        approval_status = 'Rejected',
        updated_by = :by,
        updated_at = NOW()
    WHERE id = :id
");

$stmt->execute([
    'id' => $data['id'],
    'by' => $_SESSION['employee_id']
]);

Response::success('Section deleted successfully');
