<?php 
} else {
    if ($message !== null) {
        ?>
      <div class="alert alert-info">
        <a href="" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></a>
        <?php 
        echo htmlspecialchars($message);
        ?>
      </div>
<?php 
    } else {
        ?>
      <form method="POST">
        <h3 style="font-family: monospace; white-space: pre;"><?php 
        echo htmlspecialchars(formatUniqueIdHex($unique_id));
        ?>
</h3>
        <div class="form-group">
          <label for="inputEmail" class="sr-only">Email address</label>
          <input type="email" name="email" id="inputEmail" class="form-control input-sm" placeholder="Email address" required/>
        </div>
        <button type="submit" name="transfer" class="btn btn-sm btn-primary btn-block"><span class="glyphicon glyphicon-send"></span> Transfer</button>
      </form>
<?php 
    }
}
?>
    </div>
  </body>
</html>
                throw new UserException('A previous unique id range request is still pending approval.');
            }
            $person = $user;
        }
        $unique_id = array('person_id' => $person['person_id'], 'uniqueid_url' => $_POST['url'], 'uniqueid_user_comment' => $_POST['comment']);
        $dal->insertUniqueId($unique_id);
        $subject = "OpenLCB Unique ID Range Requested";
        $body = "Hi " . formatPersonName($person) . ",\r\n\r\nYou were assigned an OpenLCB unique ID range of:\r\n" . formatUniqueIdHex($unique_id) . "\r\n\r\nDelegating organization or person: " . formatPersonName($person) . "\r\nURL: " . $unique_id['uniqueid_url'] . "\r\nComment: " . $unique_id['uniqueid_user_comment'] . "\r\n\r\nThe OpenLCB Group";
        if (!mail_abstraction(array(formatPersonEmail($person)), $subject, $body)) {
            throw new UserError('Failed to send email.');
        }
        $body = "A new OpenLCB unique ID range has been assigned.\r\nYou have been notified as you are a moderator.\r\n\r\n" . formatUniqueIdHex($unique_id) . "\r\n\r\nDelegating organization or person: " . formatPersonName($person) . "\r\nURL: " . $unique_id['uniqueid_url'] . "\r\nComment: " . $unique_id['uniqueid_user_comment'] . "\r\n\r\nUID: " . 'http://' . $_SERVER['HTTP_HOST'] . '/uniqueidrange?uniqueid_id=' . $unique_id['uniqueid_id'] . "\r\nAll pending UIDs: " . "http://" . $_SERVER['HTTP_HOST'] . '/uniqueidranges?pending';
        if (!mail_abstraction(array_map('formatPersonEmail', $dal->selectModerators()), $subject, $body, array(EMAIL_FROM))) {
            throw new UserError('Failed to send email.');
        }
        $message = 'Your assigned range is: ' . formatUniqueIdHex($unique_id);
    } else {
        if ($user !== null && $user['person_unapproved_uniqueid_count'] > 0) {
            $message = 'A previous unique id range request is still pending approval.';
        }
    }
    $dal->commit();
} catch (UserException $e) {
    $dal->rollback();
    $error = $e->getMessage();
} catch (Exception $e) {
    $dal->rollback();
    throw $e;
}
?>
<!DOCTYPE html>