{{ bc([
  {text: "admin_title"|lang, url: '/admin/'},
  {text: "admin_errors"|lang}
]) }}

{% if list %}
  <form action="/admin/errors/" method="get" class="admin_common_query_form">
    {% if ip %}
      <input type="hidden" name="ip" value="{{ ip }}" />
    {% endif %}
    <input type="text" name="query" placeholder="text_like" value="{{ query }}" />
    <input type="text" name="url_query" placeholder="url_like" value="{{ url_query }}" />
    <input type="text" name="file_query" placeholder="file" value="{{ file_query }}" />
    <input type="text" name="line_query" placeholder="line" value="{{ line_query }}" style="width: 50px" />
    <input class="blue" type="submit" value="query" />
  </form>

  <table border="1" width="100%" cellpadding="0" cellspacing="0" class="admin-error-log">
    <thead>
    <tr>
      <th width="5%">Time</th>
      <th width="20%">Source</th>
      <th>Error</th>
    </tr>
    </thead>
    <tbody>
    {% for item in list %}
      <tr>
        <td>{{ item.date }}</td>
        <td>
          {% if item.is_cli %}
            <span class="admin-error-log-num">cmd</span>
          {% else %}
            <span class="admin-error-log-num">
              <a href="/admin/errors/?ip={{ item.ip }}">{{ item.ip_s }}</a></span>
            <a class="admin-error-log-link" href="{{ item.full_url }}">{{ item.url }}</a><br/>
            {{ item.ua }}
          {% endif %}
        </td>
        <td class="admin_error_log_ms">
          {% if item.admin_id %}
            <span class="admin-error-log-num">admin={{ item.admin_id }}</span>
          {% endif %}

          {% if item.custom %}
            <span class="admin-error-log-num">{{ item.num }}, {{ item.time }}</span> <b>{{ item.file }}</b>:{{ item.line }}<br/>
            <span class="admin-error-log-num">{{ item.errtype }}</span> {{ item.text|nl2br }}
          {% else %}
            <span class="admin-error-log-num">{{ item.num }}, {{ item.time }}</span> {{ item.text|nl2br }}
          {% endif %}

          {% if item.stacktrace %}
            <div class="admin-error-log-stacktrace-wrap">
              <a href="javascript:void(0)" onclick="toggle(ge('admin_error_log_stacktrace{{ item.id }}'))">Show/hide stacktrace</a>
              <div id="admin_error_log_stacktrace{{ item.id }}" style="display: none">{{ item.stacktrace|nl2br }}</div>
            </div>
          {% endif %}
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>

  {% if pn_pages > 1 %}
    {{ pageNav(pn_page, pn_pages, url~'page={page}') }}
  {% endif %}
{% else %}
  <div class="empty">Error log is empty.</div>
{% endif %}
