{% extends "SsoBackendBundle:Token:base.html.twig" %}
{% block title %}Update Users - CSV Import{% endblock %}
{% block body %}
    <h1>Update Users - CSV Import</h1>
    <h3>For seamless integration of SSO into your project</h3>
    <p>
        Please select your prepared CSV file. It should fit to your configuration. After import the page will not be
        reloaded, instead you will receive a CSV file containing the result of the import process.</p>
    <p>Maximum upload file size: {{ maxUploadSize }}</p>
    <h3>Configuration</h3>
    <ul>
        <li>Column delimiter: {{ importConfiguration.columnDelimiter }}</li>
        <li>Text enclosure: {{ importConfiguration.textEnclosure }}</li>
        <li>Password encrypt type: {{ importConfiguration.encryptType }}</li>
        <li>Auto create user: {{ importConfiguration.autoCreateUser ? 'yes' : 'no' }}</li>
        <li>Activate created user: {{ importConfiguration.activateCreatedUser ? 'yes' : 'no' }}</li>
    </ul>
    <h3>Mapping</h3>
    <table class="table table-condensed">
        <thead>
        <tr>
            <th>Column</th>
            <th>User</th>
            <th>Application</th>
            <th>Attribute</th>
            <th>Role</th>
        </tr>
        </thead>
        <tbody>
        {% for col in importConfiguration.rows %}
            <tr>
                <td>{{ col.rowId }}</td>
                <td>
                    {% if col.targetEntity == 'user' %}
                        {{ col.user.userProperty }}
                        {{ col.user.primaryKey ? '(primary)' }}
                    {% else %}
                        %
                    {% endif %}
                </td>
                <td>
                    {% if col.targetEntity == 'attribute' %}
                        {{ col.applicationAttribute.application.name }}
                    {% elseif col.targetEntity == 'role' %}
                        {{ col.applicationRole.application.name }}
                    {% else %}
                        %
                    {% endif %}
                </td>
                <td>
                    {% if col.targetEntity == 'attribute' %}
                        {{ col.applicationAttribute.attribute.name }}
                    {% else %}
                        %
                    {% endif %}
                </td>
                <td>
                    {% if col.targetEntity == 'role' %}
                        {{ col.applicationRole.role.name }}
                    {% else %}
                        %
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    <div class="well clearfix">
        {{ form_start(form) }}
        {{ form_rest(form) }}
        <ul class="record_actions">
            <li>
                <a class="btn btn-success" href="{{ path('_admin_backend_webservice_user') }}">
                    Back to the list
                </a>
            </li>
            <li>
                <a class="btn btn-info"
                   href="{{ path('_admin_backend_webservice_user_configure', {'config_id': importConfiguration.id}) }}">
                    Back to configuration
                </a>
            </li>
            <li>
                <button type="submit" class="btn btn-danger">
                    Start Update Users
                </button>
            </li>
        </ul>
        {{ form_end(form) }}
    </div>
{% endblock %}
