{% extends "admin/base.html" %}
{% load i18n static %}
{% load botsfilters %}

{% block content %}
<form action="{{ form.action }}" method="post">{% csrf_token %}
    <input onClick="history.back()" type="button" value="{% trans 'Back' %}" />
    <input type="submit" name="2select" value="{% trans 'Change selection' %}" />
    <input type="submit" name="2outgoing" value="{% trans 'Outgoing (same selection)' %}" />
    <input type="submit" name="2process" value="{% trans 'Process Errors (same selection)' %}" />
    <input type="submit" name="2confirm" value="{% trans 'Confirm (same selection)' %}" />
    <input type="submit" name="rereceiveall" value="{% trans 'Rereceive All' %}" />
    {% include "bots/paginator.html" %}

    <table id="botstable">
        {% for hidden in form.hidden_fields %}
            {{ hidden }}
        {% endfor %}
        <thead>
            <tr>
                <th></th>
                <th><button class="botsheader" type="submit" name="order" value="status" >{% trans 'Status' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="retransmit" >{% trans 'Rereceive' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="ts" >{% trans 'Date/time' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="idroute" >{% trans 'Route' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="fromchannel" >{% trans 'FromChannel' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="infilename" >{% trans 'InFile' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="ineditype" >{% trans 'InEditype' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="inmessagetype" >{% trans 'InMessagetype' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="nrmessages" >{% trans '#mes' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="filesize" >{% trans 'Size' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="tochannel" >{% trans 'ToChannel' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="outfilename" >{% trans 'OutFile' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="outeditype" >{% trans 'OutEditype' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="outmessagetype" >{% trans 'OutMessagetype' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="frompartner" >{% trans 'FromPartner' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="topartner" >{% trans 'ToPartner' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="errortext" >{% trans 'Error' %}</button></th>
                <th><button class="botsheader" type="submit" name="order" value="divtext" >{% trans 'MappingScript' %}</button></th>
            </tr>
        </thead>
        <tbody>
        {% for row in queryset.object_list %}
            <tr class="{% cycle 'row1' 'row2' %}">
                <td>
                    <div class="dropdown"><img class="action" src="{% static "images/star.png" %}"/>
                        <ul>
                            <li><button class="botsheader" onclick="document.location.href='/detail/?inidta={{row.idta}}'; return false;" >{% trans 'View detail' %}</button></li>
                            <li><button class="botsheader" type="submit" name="retransmit" value="{{row.idta}}" >{% trans 'Rereceive' %}</button></li>
                            <li><button class="botsheader" type="submit" name="delete" value="{{row.idta}}" >{% trans 'Delete file' %}</button></li>
                        </ul>
                    </div>
                </td>
                <td>{{ row.get_statust_display}}</td>
                <td><input disabled="True" type="checkbox" {% if row.retransmit %}checked{% endif %}/></td>
                <td class="nowrap">{{row.ts|date:"Y-m-d H:i:s" }}</td>
                <td class="nowrap">{{row.idroute}}</td>
                <td class="nowrap">{{row.fromchannel}}</td>
                <td><a href="/filer/?action=this&amp;idta={{row.idta}}" target="_blank" class="botslink" title="{{row.infilename}}" >{{row.infilename|shortpath}}</a></td>
                <td class="nowrap">{{row.ineditype}}</td>
                <td class="nowrap">{{row.inmessagetype}}</td>
                <td>{{row.nrmessages}}</td>
                <td class="nowrap">{% if row.filesize %}{{row.filesize|filesizeformat}}{% endif %}</td>
                <td class="nowrap">{{row.tochannel}}</td>
                <td>{% if row.outfilename == '(several values)' %}
                        <a href="/detail/?inidta={{row.idta}}" class="botslink">{{row.outfilename}}</a>
                    {% else %}
                        <a href="/filer/?action=this&amp;idta={{row.outidta}}" target="_blank" class="botslink" title="{{row.outfilename}}">{{row.outfilename|shortpath}}</a>
                    {% endif %}</td>
                <td class="nowrap">{{row.outeditype}}</td>
                <td class="nowrap">{{row.outmessagetype}}</td>
                <td class="nowrap">{{row.frompartner}}</td>
                <td class="nowrap">{{row.topartner}}</td>
                <td style="white-space: pre;">{{row.errortext}}</td>
                <td class="nowrap">{{row.divtext}}</td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</form>
{% endblock %}

