<div class="settingsPage">

    <div class="left-column">
           <?php include('settingsSideBar.php');?>
    </div>

    <div class="right-column">

        <div class="pageTitle">
           <h1>
            <span>Active tokens
              <?php
                  echo "(".count($activeSessions)." user";
                    if (count($activeSessions) > 1) {
                      echo "s";
                    }
                  echo ")";
                ?>
            </span></h1>
        </div>

          <div class="max-table">
              <?php foreach($activeSessions as $sessions) {

                $allTokens = array_map(function($element){return $element['access_token'];}, $sessions['details']);
                $commaSeparatedTokens = implode('|',$allTokens);
               ?>
               <div class="row-fluid float-left">

                <div class="span3">
                <table class="table table-horizontal no-hover borderLesstable">
                    <thead>
                      <tr class="border-bottom">
                        <th>User</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr>
                        <td><?php  echo $sessions['user_id']; ?></td>
                      </tr>
                    </tbody>
                </table>

                </div>
                <div class="span9">
                  <table class="table table-horizontal borderLesstable table-hover">
                    <thead>
                      <tr class="border-bottom">
                        <th></th>
                        <th class="fill">Expires</th>
                        <th class="right"><a href="<?php echo site_url('settings/revoke_token/').'/'. htmlspecialchars($commaSeparatedTokens) ?>">Revoke all</a></th>
                      </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($sessions['details'] as $key=>$details) { ?>
                      <tr>
                        <td class="muted"><?php echo $key+1 ?></td>
                        <td class="fill"><?= htmlspecialchars($details['expires']) ?></td>
                        <td class="right"><a href="<?= site_url('settings/revoke_token/').'/'. htmlspecialchars($details['access_token']) ?>">Revoke</a></td>
                      </tr>
                    <?php  } ?>
                    </tbody>
                  </table>

                  </div>
                </div>
              <?php } ?>

           </div>
    </div>
</div>