<?php
require_once __DIR__ . '/../../app/helpers/functions.php';
require_once __DIR__ . '/../../app/middleware/auth.php';

session_boot();
require_login();

$conn = require __DIR__ . '/../../app/config/database.php';
require_admin($conn);

$id = (int)($_GET['id'] ?? 0);
if (!$id) redirect('customers.php');

$st = $conn->prepare("UPDATE users SET banned='no', status='active' WHERE id=?");
$st->bind_param("i", $id);
$st->execute();

flash('msg', 'Customer unbanned.');
redirect('customers.php');
