<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>TAW Subscription Packages</title>
    <link rel="stylesheet" href="/css/global.css" type="text/css">
  </head>
  <body>
      <pre><?=$user_subscription_info?></pre>
    <?php
    $current_sub = array();
    $new_sub = array();
    ?>
    <?php
        foreach($subscriptions['subscriptions'] as $subscription):
            if($subscription['current_plan']) {
                $current_sub = $subscription;
            }
            if($subscription['id'] == $_GET['sub']) {
                $new_sub = $subscription;
            }
        endforeach;
    ?>

    <h1>Please confirm your new subscription</h1>
     <div class="sub_box">
         <h3>Current</h3>
         <p><strong>Current Plan:</strong> <?=$current_sub['name']?><br />
         <strong>Current Price:</strong> £<?=$current_sub['price']?> a month.<br />
         <strong>Details:</strong> <em><?=$current_sub['description']?></em><br />
         <strong>Expires:</strong> <em><?=$subscriptions['user']['subscriptions'][0]['subscription_expiry']?></em></p>
     </div>

     <?= if($new_sub): ?>
         <div class="sub_box">
             <h3>New</h3>
             <p><strong>New Plan:</strong> <?=$new_sub['name']?><br />
             <strong>New Price:</strong> £<?=$new_sub['price']?> a month.<br />
             <strong>New Details:</strong> <em><?=$new_sub['description']?></em><br />
             <strong>Start Date:</strong> My date is set to 2029 so I need to create a few test users with upcoming expiry dates.</p>
         </div>
     <?= else: ?>
         <div class="sub_box">
             <h3>New</h3>
             <p>No plan with that ID</p>
         </div>

     <div style="clear:both">&nbsp;</div>

    <div id="dropin-container"></div>
    <form id="payment-form" action="/checkout/customer/create" method="post">
    <script src="https://js.braintreegateway.com/web/dropin/1.18.0/js/dropin.min.js"
        data-braintree-dropin-authorization="sandbox_x6mxm269_2xx4kytt4pjt9q7f"
        data-paypal.flow="vault"
        data-paypal.currency="GBP">
    </script>
    <input type="submit" value="Complete Purchase"></input>
    </form>




</body>
