<!-- BEGIN resources/active_sessions.tt -->
[% META title = "Resources &raquo; Active sessions" %]
    
    <h3 class="header">Active sessions</h3>

   [% IF sessions.size > 1 # always will have self %]
    <table class="indent">
        <tr>
            <td class="borderless"></td>
            <th scope="col">User</th>
            <th scope="col">Location</th>
            [% IF c.user_can('do_admin') %]
                <th>IP addr</th>
            [% END %]
            <th scope="col">Last Access</th>
            <td class="borderless"></td>
        </tr>
        [% 
            FOREACH sess IN sessions; # PROCESS dumper.tt dump = sess.as_tree;
            NEXT IF sess.user.username == c.authen.username; # skip self (in 'time' order)
        %]
        <tr>
            <td>[% DEFAULT counter = 1; counter; counter = counter + 1 %]</td>
            <td>
                [% sess.user.first_name | ucfirst %]
                [% sess.user.last_name  | ucfirst %]
            </td>
            <td>[% sess.user.user_location.location_name %]</td>
            [% IF c.user_can('do_admin') %]
               <td>[% sess.addr %]</td>
            [% END %]
            <td>
                [% delta = calculate_duration(sess.time).in_units('minutes') %]                
                [%
                    IF ! delta; '< 1 min' | html;
                    ELSIF delta > 1; delta _ ' mins';
                    ELSE; '1 min'; END;
                %] ago            
            </td>
            <td class="borderless">
                <a href="[% app_url %]/resources/user_messages/[% sess.user.id %]">
                    <img class="href" src="/images/pm.jpg" />
                </a>
            </td>
        </tr> 
        [% END %]
    </table>
    [% ELSE %]
        <p class="info indent">No other users logged in</p>
    [% END %]
    <p>[% site.html.back_button %]</p>    
<!-- END resources/active_sessions.tt -->
