function swapUsersSeats($eventId, $userId1, $userId2)
{
    $seat1 = getSeatForUser($eventId, $userId1);
    $seat2 = getSeatForUser($eventId, $userId2);
    if (empty($seat1) || empty($seat2)) {
        return;
    }
    //	var_dump($seat1[0]['seat'], $seat2[0]['seat'], $userId1, $userId2); exit;
    removeSeat($eventId, $userId1, false);
    removeSeat($eventId, $userId2, false);
    setUserInSeat($eventId, $seat2[0]['seat'], $userId1);
    setUserInSeat($eventId, $seat1[0]['seat'], $userId2);
}
    echo json_encode(array('type' => 'error', 'message' => $errorMessage));
    exit;
}
function jsonSuccess($message, array $seatChanges)
{
    echo json_encode(array('type' => 'success', 'message' => $message, 'seatChanges' => $seatChanges));
    exit;
}
if (!Session::isLoggedIn()) {
    jsonError('You are not logged in!');
}
$status = getSignupStatus(Session::getUser()->getId(), $event['id']);
if ($status != 'PAID' && $status != 'CONFIRMED' && $status != 'PAYPAL_WAITING' && $status != 'STAFF') {
    jsonError("You haven't paid for a ticket!");
}
if (getUserInSeat($event['id'], $seat)) {
    jsonError("That seat is already occupied!");
}
$seatChanges = array();
$currentSeats = getSeatForUser($event['id']);
foreach ($currentSeats as $itemCurrentSeat) {
    $seatChanges[] = getJsonSeatChange('delete', $itemCurrentSeat['seat'], Session::getUser()->getUsername());
}
deleteSeatsForUser($event['id']);
setUserInSeat($event['id'], $seat);
$seatChanges[] = getJsonSeatChange('set', $seat, Session::getUser()->getUsername());
jsonSuccess('Seat selected!', $seatChanges);
?>