<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/css/main.css">
    <link rel="stylesheet" href="/static/css/print.css">
    <title>&#9742; Telefonbuch &#9742;</title>
    <link rel="icon" type="image/x-icon" href="/static/images/favicon.ico">
    <link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png"> 
    <script src="/static/js/phonebook.js" defer></script>
</head>
<body>
    <div class="header-container">
        <img src="/static/images/logo.svg" alt="MKN Raute" class="logo">
        <h1>&#9742; Telefonbuch &#9742;</h1>
        <img src="/static/images/logo.svg" alt="MKN Raute" class="logo">
    </div>
    <input type="text" id="searchInput" onkeyup="searchTable()" placeholder="Suche nach Namen, Telefonnummern, Abteilung oder E-Mail...">
    <div class="dynamic-table-container">
        <table id="phonebookTable" class="dynamic-table">
            <thead>
                <tr>
                    <th class="desc" aria-sort="descending">Nachname</th>
                    <th class="min-width-cell">Vorname</th>
                    <th class="min-width-cell dynamic-width">Telefonnummer</th>
                    <th class="min-width-cell">Interne Rufnummer</th>
                    <th class="min-width-cell">E-Mail</th>
                    <th class="min-width-cell dynamic-width">Abteilung</th>
                </tr>
            </thead>
            <tbody>
                {{range .}}
                <tr>
                    <td class="min-width-cell">{{.LastName}}</td>
                    <td class="min-width-cell">{{.FirstName}}</td>
                    <td class="min-width-cell dynamic-width">
                        {{range .Phones}}
                        ({{.Type}}) <a href="tel:{{.PhoneNumber}}">{{.PhoneNumber}}</a><br>
                        {{else}}-{{end}}
                    </td>
                    <td class="min-width-cell">{{if .InternalPhone}}<a href="tel:{{.InternalPhone}}">{{.InternalPhone}}</a>{{else}}-{{end}}</td>
                    <td class="min-width-cell"><a href="mailto:{{.Email}}">{{.Email}}</a></td>
                    <td class="min-width-cell dynamic-width">{{if .Department}}{{.Department}}{{else}}-{{end}}</td>
                </tr>
                {{end}}
            </tbody>
        </table>
    </div>
    <div class="print-date">Stand der Liste: <span id="currentDate"></span></div>
    <footer>
        <div class="footer-container">
            <div class="developer">
                Entwickelt von Steffen Probst
            </div>
            <div class="license">
                <a href="https://www.gnu.org/licenses/gpl-3.0.html" target="_blank">GPL-3.0 Lizenz</a>
            </div>
        </div>
    </footer>

    <script>
        document.getElementById('currentDate').textContent = new Date().toLocaleDateString('de-DE');
    </script>
</body>
</html>