<!DOCTYPE html>
<html lang="ja" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>受診者一覧</title>
    <link rel="stylesheet" type="text/css" th:href="@{/style.css}">
</head>

<body>
    <h1>受診者一覧</h1>
    <input type="button" class="simple_square_btn5" th:onclick="|location.href='@{/persons/register}'|" value="新規受診者登録" />
    <input type="button" class="simple_square_btn5" th:onclick="|location.href='@{/}'|" value="タイトル画面へ" />
    <table class="tablist">
        <tr>
            <th>No.</th>
            <th>受診者氏名</th>
            <th>生年月日</th>
            <th>身長</th>
            <th>体重</th>
            <th>BMI</th>
            <th>肥満度</th>
            <th>コマンド</th>
        </tr>
        <tr th:each="p: ${plist}">
            <td> [[${p.number}]] </td>
            <td> [[${p.name}]] </td>
            <td> [[${p.birthday}]] </td>
            <td> [[${p.height}]] cm </td>
            <td> [[${p.weight}]] kg </td>
            <td> [[${#numbers.formatDecimal(p.bmi == null ? 0 : p.bmi, 0, 1)}]] </td>

            <th:block th:switch="${p.obesity}">
                <td th:case="'低体重'" style="background-color: #7c7cfc;">[[${p.obesity}]]</td>
                <td th:case="'普通体重'" style="background-color: #7cfc7c;">[[${p.obesity}]]</td>
                <td th:case="'肥満 (1度)'" style="background-color: #fcfc7c;">[[${p.obesity}]]</td>
                <td th:case="'肥満 (2度)'" style="background-color: #fcbb91;">[[${p.obesity}]]</td>
                <td th:case="'肥満 (3度)'" style="background-color: #fc9191;">[[${p.obesity}]]</td>
                <td th:case="'肥満 (4度)'" style="background-color: #c08080;">[[${p.obesity}]]</td>
                <td th:case="*">[[${p.obesity}]]</td>
            </th:block>

            <td>
                <a th:href=@{/persons/{num}/update(num=${p.number})}>編集</a> |
                <a th:href=@{/persons/{num}/delete(num=${p.number})}>削除</a>
            </td>
        </tr>
    </table>
</body>