<div class="entityAddContainer" style="display:none;">
    <div class='clear'></div>
    <form id='addEditReport'>
        <table class="dataTable entityTable">
            <thead>
            <tr class="first">
                <th colspan="2">{{ 'ScheduledReports_CreateAndScheduleReport'|translate }}</th>
            <tr>
            </thead>
            <tbody>
            <tr>
                <td class="first">{{ 'General_Website'|translate }} </td>
                <td style="width:650px;">
                    {{ siteName|raw }}
                </td>
            </tr>
            <tr>
                <td class="first">{{ 'General_Description'|translate }} </td>
                <td>
                    <textarea cols="30" rows="3" id="report_description" class="inp"></textarea>

                    <div class="entityInlineHelp">
                        {{ 'ScheduledReports_DescriptionOnFirstPage'|translate }}
                    </div>
                </td>
            </tr>
            {% if segmentEditorActivated %}
            <tr>
                <td class="first">{{ 'SegmentEditor_ChooseASegment'|translate }} </td>
                <td>
                    <select id='report_segment'>
                        <option value="">{{ 'SegmentEditor_DefaultAllVisits'|translate }}</option>
                        {% for savedSegmentId, savedSegmentName in savedSegmentsById %}
                            <option value="{{ savedSegmentId }}">{{ savedSegmentName[:50] }}</option>
                        {% endfor %}
                    </select>

                    <div class="entityInlineHelp">
                        {% set SegmentEditor_DefaultAllVisits %}{{ 'SegmentEditor_DefaultAllVisits'|translate }}{% endset %}
                        {% set SegmentEditor_AddNewSegment %}{{ 'SegmentEditor_AddNewSegment'|translate }}{% endset %}
                        {{ 'ScheduledReports_Segment_Help'|translate('<a href="./" rel="noreferrer"  target="_blank">','</a>',SegmentEditor_DefaultAllVisits,SegmentEditor_AddNewSegment)|raw }}
                    </div>
                </td>
            </tr>
            {% endif %}
            <tr>
                <td class="first">{{ 'ScheduledReports_EmailSchedule'|translate }}</td>
                <td>
                    <select id="report_period" class="inp">
                        {% for periodId, period in periods %}
                            <option value="{{ periodId }}">
                                {{ period }}
                            </option>
                        {% endfor %}
                    </select>

                    <div class="entityInlineHelp">
                        {{ 'ScheduledReports_WeeklyScheduleHelp'|translate }}
                        <br/>
                        {{ 'ScheduledReports_MonthlyScheduleHelp'|translate }}
                        <br/>
                        {{ 'ScheduledReports_ReportHour'|translate('<input type="text" id="report_hour" class="inp" size="2">')|raw }}
                    </div>
                </td>
            </tr>

            <tr {% if reportTypes|length == 1 %}style="display:none;"{% endif %}>
                <td class="first">
                    {{ 'ScheduledReports_ReportType'|translate }}
                </td>
                <td>
                    <select id="report_type">
                        {% for reportType, reportTypeIcon in reportTypes %}
                            <option value="{{ reportType }}">{{ reportType|upper }}</option>
                        {% endfor %}
                    </select>
                </td>
            </tr>

            <tr>
                <td class="first">
                    {{ 'ScheduledReports_ReportFormat'|translate }}
                </td>

                <td>
                    {% for reportType, reportFormats in reportFormatsByReportType %}
                        <select name='report_format' class='{{ reportType }}'>
                            {% for reportFormat, reportFormatIcon in reportFormats %}
                                <option value="{{ reportFormat }}">{{ reportFormat|upper }}</option>
                            {% endfor %}
                        </select>
                    {% endfor %}
                </td>
            </tr>

            {{ postEvent("Template.reportParametersScheduledReports") }}

            <tr class='email' id="row_report_display_options">
                <td class="first">
                    {# ScheduledReports_AggregateReportsFormat should be named ScheduledReports_DisplayFormat #}
                    {{ 'ScheduledReports_AggregateReportsFormat'|translate }}
                </td>
                <td>
                    <select id="display_format">
                        {% for formatValue, formatLabel in displayFormats %}
                            <option {% if formatValue==1 %}selected{% endif %} value="{{ formatValue }}">{{ formatLabel }}</option>
                        {% endfor %}
                    </select>

                    <div class='report_evolution_graph'>
                        <br/>
                        <input type="checkbox" id="report_evolution_graph"/>
                        <label for="report_evolution_graph"><em>{{ 'ScheduledReports_EvolutionGraph'|translate(5) }}</em></label>
                    </div>
                </td>
            </tr>

            <tr>
                <td class="first">{{ 'ScheduledReports_ReportsIncluded'|translate }}</td>
                <td>
                    {% for reportType, reportsByCategory in reportsByCategoryByReportType %}
                        <div name='reportsList' class='{{ reportType }}'>

                            {% if allowMultipleReportsByReportType[reportType] %}
                                {% set reportInputType='checkbox' %}
                            {% else %}
                                {% set reportInputType='radio' %}
                            {% endif %}

                            {% set countCategory=0 %}

                            {% set newColumnAfter=(reportsByCategory|length + 1)//2 %}

                            <div id='leftcolumn'>
                                {% for category, reports in reportsByCategory %}
                                {% if countCategory >= newColumnAfter and newColumnAfter != 0 %}
                                {% set newColumnAfter=0 %}
                            </div>
                            <div id='rightcolumn'>
                                {% endif %}
                                <div class='reportCategory'>{{ category }}</div>
                                <ul class='listReports'>
                                    {% for report in reports %}
                                        <li>
                                            <input type='{{ reportInputType }}' id="{{ reportType }}{{ report.uniqueId }}" report-unique-id='{{ report.uniqueId }}'
                                                   name='{{ reportType }}Reports'/>
                                            <label for="{{ reportType }}{{ report.uniqueId }}">
                                                {{ report.name|raw }}
                                                {% if report.uniqueId=='MultiSites_getAll' %}
                                                    <div class="entityInlineHelp">{{ 'ScheduledReports_ReportIncludeNWebsites'|translate(countWebsites)
                                                        }}</div>
                                                {% endif %}
                                            </label>
                                        </li>
                                    {% endfor %}
                                    {% set countCategory=countCategory+1 %}
                                </ul>
                                <br/>
                                {% endfor %}
                            </div>
                        </div>
                    {% endfor %}
                </td>
            </tr>

            </tbody>
        </table>

        <input type="hidden" id="report_idreport" value="">
        <input type="submit" id="report_submit" name="submit" class="submit"/>

    </form>
    <div class='entityCancel'>
        {{ 'General_OrCancel'|translate("<a class='entityCancelLink'>","</a>")|raw }}
    </div>
</div>
