if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'view':
            $action = $_GET['action'];
    }
}
?>

<div class="wrap">

	<?php 
if ($action == 'view') {
    ?>

		<?php 
    $entry = new \OutSpokane\MurderMysteryEntry(isset($_GET['id']) ? $_GET['id'] : 0);
    ?>

		<?php 
    if ($entry->getCreatedAt() === NULL) {
        ?>

			<div class="alert alert-danger">
				Entry Not Found
			</div>

		<?php 
    } else {
        ?>

			<h1>
<?php

if (isset($_GET['txid'])) {
    ?>

	<?php 
    $entry = new \OutSpokane\MurderMysteryEntry();
    $timestamp = '';
    $parts = explode('-', $_GET['txid']);
    if (count($parts) == 2) {
        if (is_numeric($parts[1])) {
            $timestamp = $parts[0];
            $entry = new \OutSpokane\MurderMysteryEntry($parts[1]);
        }
    }
    $stripe_keys = \OutSpokane\Entry::getStripeKeys();
    ?>

	<a name="confirmation-payment"></a>
	<h2>Confirmation and Payment</h2>

	<?php 
    if (isset($_POST['form'])) {
        ?>
		<div class="alert alert-danger">
			There was a problem processing your credit card. Please try again.
		</div>
	<?php 
    }
    ?>
        break;
    case 'donation':
        $form_title = 'Donation';
        $back_page = 'outspokane_donation';
        $entry = new \OutSpokane\Donation($_GET['id']);
        break;
    case 'sponsorship':
        $form_title = 'Sponsorship';
        $back_page = 'outspokane_sponsorship';
        $entry = new \OutSpokane\Sponsorship($_GET['id']);
        unset($fields[10]);
        break;
    default:
        $form_title = 'Murder Mystery';
        $back_page = 'outspokane_murder_mystery';
        $entry = new \OutSpokane\MurderMysteryEntry($_GET['id']);
}
?>

<div class="wrap">

	<h1>
		Edit <?php 
echo $form_title;
?>
 Entry
		<a href="?page=<?php 
echo $back_page;
?>
&action=view&id=<?php 
echo $entry->getId();