<?php
require_once 'db/config.php';

if (isset($_POST['edit'])) {
    $id = $_POST['id'];
    $name = $_POST['name'];
    $color = $_POST['color'];
    $display_order = $_POST['display_order'];
    
    $pdo = db();
    $stmt = $pdo->prepare("UPDATE event_types SET name = ?, color = ?, display_order = ? WHERE id = ?");
    $stmt->execute([$name, $color, $display_order, $id]);
    
    session_start();
    $_SESSION['success_message'] = 'Event type updated successfully.';
    header('Location: event_types.php');
    exit;
}
?>