<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>任务</title>
    <style>
      table {
        border-collapse: collapse;
        max-width: 100%;
      }
      th,
      td {
        border: 1px solid;
        padding: 2px 6px;
        white-space: nowrap;
        text-align: center;
      }
      .wl {
        white-space: normal;
        text-align: start;
      }
    </style>
  </head>
  <body>
    <table>
      <tr>
        <th>时间</th>
        <th colspan="2">任务</th>
      </tr>
      {% for task in tasks %}
      {% if task.plan or task.type == '释放宿舍空位'%}
      {% for r, p in task.plan.items() %}
      <tr>
        {% if loop.first %}
        <td rowspan="{{ task.plan|length }}">{{ task.time.strftime('%H:%M:%S') }}</td>
        {% endif %}
        {% if task.type == '释放宿舍空位'%}
        <td class="wl">{{ task.meta_data }}在{{ base_scheduler.translate_room(r) }}休息完毕</td>
        {% else %}
        <td>{{ base_scheduler.translate_room(r) }}</td>
        {% endif %}
        <td class="wl">{{ p|join(', ') }}</td>
      </tr>
      {% endfor %}
      {% elif task.type %}
      <tr>
        <td>{{ task.time.strftime('%H:%M:%S') }}</td>
        <td colspan="2">{{ task.type }}</td>
      </tr>
      {% else %}
      <tr>
        <td>{{ task.time.strftime('%H:%M:%S') }}</td>
        <td colspan="2">空任务</td>
      </tr>
      {% endif %}
      {% endfor %}
    </table>
  </body>
</html>
