{% set fontStyle = "color:#0d0d0d;font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Cantarell, 'Helvetica Neue', sans-serif;"%}
{% set styleTableHeader = "border-bottom:1px solid rgb(231,231,231);font-size: 15px;text-align: left;font-weight:normal;padding:13px 0 13px 10px;" ~ fontStyle %}
{% set styleTableCell = "border-bottom:1px solid rgb(231,231,231);font-size: 15px;padding:17px 15px;" ~ fontStyle %}

<h2 id="{{ reportId }}" style=" {{fontStyle}} font-size: {{ reportTitleTextSize }}pt; font-weight:normal; margin:45px 0 30px 0;">
    {{ reportName }}
</h2>

{% if reportRows is empty %}
    {{ 'CoreHome_ThereIsNoDataForThisReport'|translate }}
{% else %}
    {% if displayGraph %}
        <img alt=""
                {% if renderImageInline %}
                    src="data:image/png;base64,{{ generatedImageGraph }}"
                {% else %}
                    src="cid:{{ reportId }}"
                {% endif %}
                height="{{ graphHeight }}"
                width="{{ graphWidth }}"
                margin="0 auto"/>
    {% endif %}

    {% if displayGraph and displayTable %}
        <br/>
        <br/>
    {% endif %}

    {% if displayTable %}
        <table style="border-collapse:collapse; border:1px solid rgb(231,231,231); padding:5px;">
            <thead style="background-color: rgb({{tableBgColor}});">
            {% for columnId, columnName in reportColumns %}
                <th style="{{ styleTableHeader }}{% if columnId == 'label' %}{%  else %} text-align:right;{% endif %}">
                    &nbsp;{{ columnName }}&nbsp;&nbsp;
                </th>
            {% endfor %}
            </thead>
            <tbody>
            {% set cycleValues=['background-color: rgb('~tableBgColor~')',''] %}
            {% set cycleIndex=1 %}
            {% for rowId,row in reportRows %}
                {% set rowMetrics=row.columns %}

                {% if reportRowsMetadata[rowId] is defined %}
                    {% set rowMetadata=reportRowsMetadata[rowId].columns %}
                {% else %}
                    {% set rowMetadata=null %}
                {% endif %}
                <tr style="{{ cycle(cycleValues, cycleIndex) }};">
                    {% set cycleIndex=cycleIndex+1 %}
                    {% for columnId, columnName in reportColumns %}
                        <td style="padding:17px 15px;{% if columnId == 'label' %}{%  else %} text-align:right;{% endif %};{{styleTableCell}}">
                            {% if columnId == 'label' %}
                                {% if rowMetrics[columnId] is defined %}
                                    {% if rowMetadata.logo is defined %}
                                        <img height="16px" src='{{ currentPath }}{{ rowMetadata.logo }}'
                                            {%- if 'plugins/Morpheus/icons/dist/flags' in rowMetadata.logo %} style="border: 1px solid lightgray; "{% endif -%}
                                        >
                                        &nbsp;
                                    {% endif %}
                                    {% if rowMetadata.url is defined %}
                                        <a style="color: rgb({{ reportTextColor }});" href='{% if rowMetadata.url|slice(0,4) not in ['http','ftp:'] %}http://{% endif %}{{ rowMetadata.url }}'>
                                    {% endif %}
                                    {{ rowMetrics[columnId] | raw }}{# labels are escaped by SafeDecodeLabel filter in core/API/Response.php #}
                                    {% if rowMetadata.url is defined %}
                                        </a>
                                    {% endif %}
                                {% endif %}
                            {% else %}
                                {% if rowMetrics[columnId] is empty %}
                                    0
                                {% else %}
                                    {{ rowMetrics[columnId]|number(2) }}
                                {% endif %}
                            {% endif %}
                        </td>
                    {% endfor %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endif %}
    <p style="width: 100%; text-align:center;">
      <a style="text-decoration:none; font-size: 9pt;" href="#reportTop">
          {{ 'ScheduledReports_TopOfReport'|translate }} &#8593;
    </a></p>
{% endif %}
