<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:py="http://genshi.edgewall.org/"
  xmlns:xi="http://www.w3.org/2001/XInclude">
  
<py:def function="show_table(start=0, end=len(rows))">
  <table class="listing tickets mailarchivereport">
    <thead>
      <tr>
        <th>関連メール</th>
        <py:for each="col_idx, col in enumerate(columns)">
          <th py:if="not is_hidden(col_idx)">
            ${col}
          </th>
        </py:for>
      </tr>
    </thead>
    <tbody>
      <py:for each="idx, (row, ticket_id) in enumerate(rows[start:end])">
        <tr class="${idx % 2 == 0 and 'odd' or 'even'} ${has_mail_ids(ticket_id) and 'collapsed' or ''}">
          <td>
            <a py:if="has_mail_ids(ticket_id)" class="expander thread_from" style="">
              <py:if test="len(mail_ids[ticket_id]) > 1">[${mail_ids[ticket_id][0]},&nbsp;..]</py:if>
              <py:if test="len(mail_ids[ticket_id]) == 1">[${mail_ids[ticket_id][0]}]</py:if>
            </a>
          </td>
          <?python wrote = False?>
          <td py:for="col_idx, data in enumerate(row)" py:if="not is_hidden(col_idx)">
            <?python wrote = True?>
            <py:choose>
              <py:when test="columns[col_idx] in ('time', 'date', 'created', 'modified')">
                ${data != None and format_time(int(data)) or '--'}
              </py:when>
              <py:when test="columns[col_idx] == 'datetime' or u'日付' in columns[col_idx]">
                ${data != None and format_datetime(int(data)) or '--'}
              </py:when>
              <py:when test="columns[col_idx].lower() in ('ticket', 'id', u'チケット')">
                <a href="${req.href.ticket(str(data))}" title="View Ticket" class="ticket">#${str(data)}</a>
              </py:when>
              <py:otherwise test="">
                ${data}
              </py:otherwise>
            </py:choose>
          </td>
        </tr>
        <tr class="mail_data" style="display:none;">
          <td colspan="${len([col_idx for col_idx, col in enumerate(columns) if not is_hidden(col_idx)])+1}">
            <div class="mail_id" py:if="ticket_id is not None" style="display:none;">${','.join(mail_ids[ticket_id])}</div>
            <div class="mail_loading" style="display:none;">&nbsp;</div>
            <div class="mailticketreportplaceholder"></div>
          </td>
        </tr>
      </py:for>
    </tbody>
  </table>
</py:def>
  
<div id="mailarchivereporttable_${id}">
  <script type="text/javascript">
    var ajaxmail_base_url = '${req.href()}/';
  </script>
  <h2>
    <a href="${req.href.report(report_id)}" align="left">${title}</a>
    <span class="numrows">(${len(rows)} 件のマッチ)</span>
  </h2>
  <py:if test="not has_group">
    ${show_table()}
  </py:if>
  <py:if test="has_group">
    <div py:for="g in groups">
      <h2 class="report-result">${g.name}<span class="numrows">(${g.end-g.start+1} 件のマッチ)</span></h2>
      ${show_table(g.start, g.end+1)}
    </div>
  </py:if>
  
</div>
</html>
