<% lang = @data[:language] %>
<!DOCTYPE html>
<html lang="<%= lang[:html_lang] %>">
<head>
<meta charset="UTF-8">
<title><%= lang[:page_title] %></title>
<link rel="stylesheet" href="styles/my_school_users.css">
<script>
// Localised strings defined before the search code
const STRINGS = {
    "no_matches": "<%= lang[:no_matches] %>",
    "one_match": "<%= lang[:one_match] %>",
    "multiple_matches": "<%= lang[:multiple_matches] %>",
};
</script>
<script type="text/javascript" src="scripts/my_school_users.js"></script>
</head>
<body onload="setupPage()">

<div id="wrapper">

<header>
    <h1><%= @data[:school] %></h1>
    <h2><%= lang[:page_title] %></h2>
</header>

<main>
<div id="searchArea">
    <input type="search" id="searchBox" size="30" maxlength="25" placeholder="<%= lang[:search_placeholder] %>">

    <p id="numMatches"></p>

    <div id="searchResults"></div>

    <table class="users" id="searchResultsTableTemplate" style="display: none;">
        <tr>
            <th><%= lang[:group] %></th>
            <th><%= lang[:last_name] %></th>
            <th><%= lang[:first_names] %></th>
            <th><%= lang[:username] %></th>
            <th><%= lang[:actions] %></th>
        </tr>
    </table>
</div>

<div id="groupsList">
<% @data[:groups].each do |group| %>
<% groupName = (group[:name] == :ungrouped) ? lang[:ungrouped] : group[:name] %>
<div class="groupHeader" data-target="<%= group[:id] %>" data-count="<%= group[:users].count %>" data-name="<%= groupName %>" data-ungrouped="<%= group[:name] == :ungrouped ? '1' : '0' %>">
    <h1><%= groupName %></h1>
    <span class="count">(<%= group[:users].size %> <%= lang[:users] %>)</span>
    <span id="arrow-<%= group[:id] %>">▶</span>
</div>
<div class="tableWrapper" id="table-<%= group[:id] %>">
    <table class="users">
        <tr>
            <th><%= lang[:last_name] %></th>
            <th><%= lang[:first_names] %></th>
            <th><%= lang[:username] %></th>
            <th><%= lang[:actions] %></th>
        </tr>
        <% group[:users].each_with_index do |u, n| %>
        <tr id="row-<%= group[:id] %>-<%= n %>">
            <td><%= u[:last] %></td>
            <td><%= u[:first] %></td>
            <td><%= u[:username] %></td>
            <td>
                <a href="<%= @data[:domain] %>/users/password?changing=<%= @data[:changing] %>&amp;changed=<%= u[:username] %>" class="button" title="<%= lang[:password_tooltip] %>" target="_blank">
                <%= lang[:change_password] %>
                </a>
            </td>
        </tr>
        <% end %>
    </table>
</div>

<% end %>
</div>
</main>

<footer class="public">
<%= manufacturer_logo %>
<p><%= copyright_with_year %></p>
</footer>
</div>

</body>
</html>
