<div id='entityEditContainer'>
    <table class="dataTable entityTable">
        <thead>
        <tr>
            <th class="first">{{ 'General_Description'|translate }}</th>
            <th>{{ 'ScheduledReports_EmailSchedule'|translate }}</th>
            <th>{{ 'ScheduledReports_ReportFormat'|translate }}</th>
            <th>{{ 'ScheduledReports_SendReportTo'|translate }}</th>
            <th>{{ 'General_Download'|translate }}</th>
            <th>{{ 'General_Edit'|translate }}</th>
            <th>{{ 'General_Delete'|translate }}</th>
        </tr>
        </thead>

    {% if userLogin == 'anonymous' %}
        <tr>
            <td colspan='7'>
                <br/>
                {{ 'ScheduledReports_MustBeLoggedIn'|translate }}
                <br/>&rsaquo; <a href='index.php?module={{ loginModule }}'>{{ 'Login_LogIn'|translate }}</a>
                <br/><br/>
            </td>
        </tr>
    {% elseif reports is empty %}
        <tr>
            <td colspan='7'>
                <br/>
                {{ 'ScheduledReports_ThereIsNoReportToManage'|translate(siteName)|raw }}.
                <br/><br/>
            </td>
        </tr>
    {% else %}
    {% for report in reports %}
        <tr>
            <td class="first">
                {{ report.description | raw }}
                {% if segmentEditorActivated and report.idsegment %}
                    <div class="entityInlineHelp" style="font-size: 9pt;">
                        {{ savedSegmentsById[report.idsegment] }}
                    </div>
                {% endif %}
            </td>
            <td>{{ periods[report.period] }}
                <!-- Last sent on {{ report.ts_last_sent }} -->
            </td>
            <td>
                {% if report.format is not empty %}
                    {{ report.format|upper }}
                {% endif %}
            </td>
            <td>
                {# report recipients #}
                {% if report.recipients|length == 0 %}
                    {{ 'ScheduledReports_NoRecipients'|translate }}
                {% else %}
                    {% for recipient in report.recipients %}
                        {{ recipient }}
                        <br/>
                    {% endfor %}
                    {# send now link #}
                    <a href="#" idreport="{{ report.idreport }}" name="linkSendNow" class="link_but withIcon" style="margin-top:3px;">
                        <img border=0 src='{{ reportTypes[report.type] }}'/>
                        {{ 'ScheduledReports_SendReportNow'|translate }}
                    </a>
                {% endif %}
            </td>
            <td>
                {# download link #}
                <a href="{{ linkTo({'module':'API', 'segment': null, 'token_auth':token_auth,
                            'method':'ScheduledReports.generateReport', 'idReport':report.idreport,
                            'outputType':downloadOutputType, 'language':language,
                            'format': (report.format in ['html', 'csv']) ? report.format : false
                       }) }}"
                   rel="noreferrer"  target="_blank" name="linkDownloadReport" id="{{ report.idreport }}" class="link_but withIcon">
                    <img src='{{ reportFormatsByReportType[report.type][report.format] }}' border="0"/>
                    {{ 'General_Download'|translate }}
                </a>
            </td>
            <td>
                {# edit link #}
                <a href='#' name="linkEditReport" id="{{ report.idreport }}" class="link_but withIcon">
                    <img src='plugins/Morpheus/images/ico_edit.png' border="0"/>
                    {{ 'General_Edit'|translate }}
                </a>
            </td>
            <td>
                {# delete link #}
                <a href='#' name="linkDeleteReport" id="{{ report.idreport }}" class="link_but withIcon">
                    <img src='plugins/Morpheus/images/ico_delete.png' border="0"/>
                    {{ 'General_Delete'|translate }}
                </a>
            </td>
        </tr>
    {% endfor %}
    {% endif %}

    </table>
    {% if userLogin != 'anonymous' %}
        <br/>
        <div id='linkAddReport' class="addrow"><img src='plugins/Morpheus/images/add.png'/> {{ 'ScheduledReports_CreateAndScheduleReport'|translate }}</div>
        <br/>
        <br/>
    {% endif %}

</div>
