  [% META title = 'Admin &raquo; Users List' -%]

<!-- BEGIN [% template.name %] -->
    [% # INCLUDE dumper.tt dump = users %]
    [% # INCLUDE dumper.tt dump = cgi_pager %]

  <h2 align="center">Registered Users</h2>

	[% IF users.size; # only empty if new db
		PROCESS site/page_count.tt;
        PROCESS site/cgi_pager.tt;

        DEFAULT cgi_pager.page_len = 0; # in case cgi_pager not called
        i = cgi_pager.offset || 0; # can't use loop.count with next()
    %]
		<table class="indent">
			<tr>
				<th>id</th>
				<th>
					<a href="[% url_with_path %]?sort_by=username">
						Username
					</a>
				</th>
				<th>
					<a href="[% url_with_path %]?sort_by=last_name">
						LastName
					</a>
				</th>
				<th>FirstName</th>
				<th>E-mail</th>
				<th>
					<a href="[% url_with_path %]?sort_by=designation">
						Designation
					</a>
				</th>
				<th>
					<a href="[% url_with_path %]?sort_by=user_location.location_name">
						Location
					</a>
				</th>
				<th>
					<a href="[% url_with_path %]?sort_by=group.group_label">
						Group
					</a>
				</th>
				<th>
					<a href="[% url_with_path %]?sort_by=active">
						Active
					</a>
				</th>
				<th>
					<a href="[% url_with_path %]?sort_by=last_login">
						Last Login
					</a>
				</th>
            </tr>
        	[% FOREACH u IN users; i = i + 1; # auto-increment before use %]
			<tr>
				<td>
                    <a href="[% app_url %]/admin/user?id=[% u.id %]">[% i %]</a>
                </td>
				<td>[% u.username.upper %]</td>
				<td>[% u.last_name %]</td>
				<td>[% u.first_name %]</td>
				<td>[% u.email %]</td>
				<td>[% u.designation %]</td>
				<td>[% u.user_location.location_name %]</td>
				<td>[% u.group.group_label %]</td>
				<td>[% u.active %]</td>
				<td>[% u.last_login.strftime('%d.%m.%y %H:%M') %]</td>
            </tr>
            [% END %]
        </table>
       [% IF cgi_pager.page_len > 20; PROCESS site/cgi_pager.tt; END %]
    [% END %]
<!-- END [% template.name %] -->
