{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}

{% set w = document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork %}

<div class="item-row">
    <!-- evaluation document -->
    <div class="item-two-col-grid" style="width: unset">
        <div class="title">
            {% if document.storedObject.isPending %}
                <div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
            {% elseif document.storedObject.isFailure %}
                <div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
            {% endif %}
            <div>
                <div>
                    <div class="badge-accompanying-work-type-simple">
                        {{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }}
                    </div>
                </div>
            </div>
            <div class="denomination h2">
                {{ document.title|chill_print_or_message("No title") }}
            </div>
            {% if document.storedObject.type is not empty %}
                <div>
                    {{ mm.mimeIcon(document.storedObject.type) }}
                </div>
            {% endif %}
            {% if document.storedObject.hasTemplate %}
                <div>
                    <p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
                </div>
            {% endif %}
        </div>
        {% if document.storedObject.createdAt is not null %}
            <div class="aside">
                <div class="dates row text-end">
                    <span>{{ document.storedObject.createdAt|format_date('short') }}</span>
                </div>
                {% if context == 'person' %}
                    <div class="text-end">
                        <span class="badge bg-primary">
                            <i class="fa fa-random"></i> {{ w.accompanyingPeriod.id }}
                        </span>&nbsp;
                    </div>
                {% endif %}
            </div>
        {% endif %}
    </div>
</div>

{% if show_actions %}
    <div class="item-row separator">
        <div class="item-col item-meta">
            {{ mmm.createdBy(document) }}
        </div>
        <ul class="item-col record_actions flex-shrink-1">
            <li>
                {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
            </li>
            {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %}
                <li>
                    {{ document.storedObject|chill_document_button_group(document.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork)) }}
                </li>
            {% endif %}
            {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
                <li>
                    <form method="post" action="{{ chill_path_add_return_path('chill_person_accompanying_period_work_evaluation_document_duplicate', {id: document.id}) }}">
                        <button type="submit" class="btn btn-duplicate" title="{{ 'crud.view.link_duplicate'|trans }}"></button>
                    </form>
                </li>
            {% endif %}
            {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
                <li>
                    <a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', {'id': w.id, 'docId': document.id}) }}" class="btn btn-edit"></a>
                </li>
            {% endif %}
            {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w)%}
                <li>
                    <a href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_show', {'id': w.id, 'docId': document.id}) }}" class="btn btn-show"></a>
                </li>
            {% endif %}
        </ul>
    </div>
{% endif %}
