<?php
include 'config.php';
if($_SESSION['user_role'] != 'SuperAdmin') exit();

if (isset($_POST['add_group'])) {
    $type       = $_POST['trip_type'];
    $airline_id = $_POST['airline_id'];
    $route      = $_POST['route'];
    $t_date     = $_POST['travel_date'];
    $r_date     = !empty($_POST['return_date']) ? $_POST['return_date'] : null;
    $seats      = $_POST['seats'];
    $price      = $_POST['price'];
    $dep_bag    = $_POST['dep_baggage'];
    $ret_bag    = !empty($_POST['ret_baggage']) ? $_POST['ret_baggage'] : null;

    $stmt = $conn->prepare("INSERT INTO group_tickets (trip_type, airline_id, route, travel_date, return_date, total_seats, available_seats, price_per_seat, dep_baggage, ret_baggage) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->bind_param("sisssiddss", $type, $airline_id, $route, $t_date, $r_date, $seats, $seats, $price, $dep_bag, $ret_bag);

    if ($stmt->execute()) {
        header("Location: admin_group_tickets.php?success=1");
    } else {
        echo "Error: " . $conn->error;
    }
}
?>