{% extends '@CpCreationVitiCore/admin/base.html.twig' %}

{% block content %}
    <div class="panel panel-default">
        <div class="panel-heading">
            {{ 'admin_client_import.history.details_title'|trans }}
            <div class="pull-right">
                <a href="{{ path('admin_imported_client') }}" class="btn btn-default btn-xs">
                    {{ 'admin_client_import.back_to_base'|trans }}
                </a>
            </div>
        </div>
        <div class="panel-body">
            <dl class="dl-horizontal">
                <dt>{{ 'admin_client_import.history.date'|trans }}</dt>
                <dd>{{ item.createdAt|date('d-m-Y H:i:s') }}</dd>
                <dt>{{ 'admin_client_import.history.filename'|trans }}</dt>
                <dd>{{ item.originalFilename }}</dd>
                <dt>{{ 'admin_client_import.history.file_size'|trans }}</dt>
                <dd>{{ (item.fileSize / 1024)|number_format(1, ',', ' ') }} Ko</dd>
            </dl>

            <a href="{{ path('admin_imported_client_import_download', {id: item.id}) }}" class="btn btn-default">
                <i class="fas fa-download"></i> {{ 'admin_client_import.history.download'|trans }}
            </a>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">{{ 'admin_client_import.history.statistics'|trans }}</div>
        <div class="table-responsive">
            <table class="table table-bordered">
                <tbody>
                <tr><th>{{ 'admin_client_import.analysis.total_rows'|trans }}</th><td>{{ item.totalRows }}</td></tr>
                <tr><th>{{ 'admin_client_import.history.created'|trans }}</th><td>{{ item.createdCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.history.updated'|trans }}</th><td>{{ item.updatedCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.history.unchanged'|trans }}</th><td>{{ item.unchangedCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.history.ignored'|trans }}</th><td>{{ item.ignoredCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.history.duplicates'|trans }}</th><td>{{ item.duplicateCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.analysis.invalid_emails'|trans }}</th><td>{{ item.invalidEmailCount }}</td></tr>
                <tr><th>{{ 'admin_client_import.analysis.missing_groups'|trans }}</th><td>{{ item.missingGroupCount }}</td></tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">{{ 'admin_client_import.history.group_mapping'|trans }}</div>
        <div class="table-responsive">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>{{ 'admin_client_import.mapping.source_group'|trans }}</th>
                    <th>{{ 'admin_client_import.mapping.target_group'|trans }}</th>
                    <th>{{ 'admin_client_import.history.rows'|trans }}</th>
                </tr>
                </thead>
                <tbody>
                {% for group in item.groupSummary %}
                    <tr>
                        <td>{{ group.source_group }}</td>
                        <td>
                            {% if group.ignored %}
                                <span class="label label-default">{{ 'admin_client_import.mapping.ignore'|trans }}</span>
                            {% else %}
                                {{ group.target_group }}
                            {% endif %}
                        </td>
                        <td>{{ group.rows }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
{% endblock %}
