{% extends '@ChillPerson/Person/layout.html.twig' %}

{% set activeRouteKey = '' %}

{% block content %}
    <div class="grid-12">
        <h1>Rapports pour {{ person|chill_entity_render_string }}</h1>

        {% if cvs is defined %}
            <h2>CV</h2>

            {% if cvs|length == 0 %}
                <p>{{ null|chill_print_or_message("Aucun CV enregistré") }}</p>
            {% else %}
                <table>
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for cv in cvs %}
                            <tr>
                                <td>{{ cv.reportDate|format_date('short') }}</td>
                                <td>
                                    <ul class="record_actions">
                                        <li>
                                            <a href="{{ chill_path_add_return_path('chill_crud_cscv_view', {'id': cv.id, 'person_id': person.id}) }}" class="btn btn-show"></a>
                                        </li>
                                        <li>
                                            <a href="{{ chill_path_add_return_path('chill_crud_cscv_edit', {'id': cv.id, 'person_id': person.id}) }}" class="btn btn-edit"></a>
                                        </li>
                                        {% if is_granted('CHILL_JOB_REPORT_DELETE', cv) %}
                                        <li>
                                             <a href="{{ chill_path_add_return_path('chill_crud_cscv_delete', {'id': cv.id, 'person_id': person.id}) }}" class="btn btn-delete"></a>
                                        </li>
                                        {% endif %}
                                    </ul>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% endif %}

            <ul class="record_actions">
                <li>
                    <a href="{{ path('chill_crud_cscv_new', {'person_id' : person.id }) }}" class="btn btn-new">
                        Nouveau CV
                    </a>
                </li>
            </ul>
        {% endif %}

        {% if freins is defined %}
            <h2>Freins</h2>

            {% if freins|length == 0 %}
                <p>{{ null|chill_print_or_message("Aucun rapport enregistré") }}</p>
            {% else %}
                <table>
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Freins identifiés</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for frein in freins %}
                            <tr>
                                <td>{{ frein.reportDate|format_date('short') }}</td>
                                <td>
                                    {% if frein.freinsPerso|merge(frein.freinsEmploi)|length > 0 %}
                                    <ul>
                                    {% for e in frein.freinsPerso %}
                                        <li>{{ ('freins_perso.' ~ e)|trans }}</li>
                                    {% endfor %}
                                    {% for e in frein.freinsEmploi %}
                                        <li>{{ ('freins_emploi.' ~ e)|trans }}</li>
                                    {% endfor %}
                                    </ul>
                                    {% else %}
                                        <p>{{ null|chill_print_or_message("Aucun frein renseigné") }}
                                    {% endif %}
                                </td>
                                <td>
                                    <ul class="record_actions">
                                        <li>
                                            <a href="{{ path('chill_crud_csfrein_view', {'id': frein.id, 'person_id': person.id}) }}" class="btn btn-show"></a>
                                        </li>
                                        <li>
                                            <a href="{{ path('chill_crud_csfrein_edit', {'id': frein.id, 'person_id': person.id}) }}" class="btn btn-edit"></a>
                                        </li>
                                        {% if is_granted('CHILL_JOB_REPORT_DELETE', frein) %}
                                        <li>
                                             <a href="{{ chill_path_add_return_path('chill_crud_csfrein_delete', {'id': frein.id, 'person_id': person.id}) }}" class="btn btn-delete"></a>
                                        </li>
                                        {% endif %}
                                    </ul>
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% endif %}

            <ul class="record_actions">
                <li>
                    <a href="{{ path('chill_crud_csfrein_new', {'person_id' : person.id }) }}" class="btn btn-new">
                        Nouveau rapport "frein"
                    </a>
                </li>
            </ul>

        {% endif %}

        {% if immersions is defined %}
            <h2>Immersions</h2>

            {% if immersions|length == 0 %}
                <p>{{ null|chill_print_or_message("Aucun rapport enregistré") }}</p>
            {% else %}
                <table>
                    <thead>
                        <tr>
                            <th>Date de début de l'immersion</th>
                            <th>Entreprise</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for im in immersions %}
                            <tr>
                                <td>{{ im.debutDate|format_date('short') }}</td>
                                <td>
                                    {{ im.entreprise.name }}
                                </td>
                                <td>
                                    <ul class="record_actions">
                                        <li>
                                            <a href="{{ path('chill_crud_immersion_view', {'id': im.id, 'person_id': person.id}) }}" class="btn btn-show"></a>
                                        </li>
                                        <li>
                                            <a href="{{ path('chill_crud_immersion_edit', {'id': im.id, 'person_id': person.id}) }}" class="btn btn-edit"></a>
                                        </li>
                                        <li>
                                            <a href="{{ path('chill_crud_immersion_bilan', {'id': im.id, 'person_id': person.id}) }}" class="btn btn-misc">
                                               <svg style="height: 1rem;" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="graduation-cap" class="svg-inline--fa fa-graduation-cap fa-w-20" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M622.34 153.2L343.4 67.5c-15.2-4.67-31.6-4.67-46.79 0L17.66 153.2c-23.54 7.23-23.54 38.36 0 45.59l48.63 14.94c-10.67 13.19-17.23 29.28-17.88 46.9C38.78 266.15 32 276.11 32 288c0 10.78 5.68 19.85 13.86 25.65L20.33 428.53C18.11 438.52 25.71 448 35.94 448h56.11c10.24 0 17.84-9.48 15.62-19.47L82.14 313.65C90.32 307.85 96 298.78 96 288c0-11.57-6.47-21.25-15.66-26.87.76-15.02 8.44-28.3 20.69-36.72L296.6 284.5c9.06 2.78 26.44 6.25 46.79 0l278.95-85.7c23.55-7.24 23.55-38.36 0-45.6zM352.79 315.09c-28.53 8.76-52.84 3.92-65.59 0l-145.02-44.55L128 384c0 35.35 85.96 64 192 64s192-28.65 192-64l-14.18-113.47-145.03 44.56z"></path></svg>
                                            </a>
                                        </li>
                                        {% if is_granted('CHILL_JOB_REPORT_DELETE', im) %}
                                        <li>
                                             <a href="{{ chill_path_add_return_path('chill_crud_immersion_delete', {'id': im.id, 'person_id': person.id}) }}" class="btn btn-delete"></a>
                                        </li>
                                        {% endif %}
                                    </ul>
                                </td>
                            </tr>

                        {% endfor %}
                    </tbody>
                </table>
            {% endif %}

            <ul class="record_actions">
                <li>
                    <a href="{{ path('chill_crud_immersion_new', {'person_id' : person.id }) }}" class="btn btn-new">
                        Nouvelle immersion
                    </a>
                </li>
            </ul>
        {% endif %}

        {% if projet_professionnels is defined %}
            <!-- projet professionnel -->
            <h2>Projets professionnels</h2>

            {% if projet_professionnels|length == 0 %}
                <p>{{ null|chill_print_or_message("Aucun rapport enregistré") }}</p>
            {% else %}
                <table>
                    <thead>
                        <tr>
                            <th>Date de création</th>
                            <th>Projet validé ou souhaité</th>
                            <th>Type de contrat</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for pr in projet_professionnels %}
                            <tr>
                                <td>{{ pr.reportDate|format_date('short') }}</td>
                                <td>
                                    {% set romes = [] %}
                                    {% if pr.valide|length > 0 %}
                                        <p>Projet validé&nbsp;:</p>
                                        {% set romes = pr.valide %}
                                    {% elseif pr.souhait|length > 0 %}
                                        <p>Projet souhaité&nbsp;:</p>
                                        {% set romes = pr.souhait %}
                                    {% else %}
                                        <p class="chill-no-data-statement">Aucun souhait rempli</p>
                                    {% endif %}

                                        <ul>
                                            {% for a in romes %}
                                                <li>{{ a.libelle }} ({{ a.metier.code }} - {{ a.metier.libelle }})</li>
                                            {% endfor %}
                                        </ul>
                                </td>
                                <td>
                                    <ul>
                                    {% for type in pr.typeContrat %}
                                        <li>{{ ('projet_prof.type_contrat.' ~ type)|trans }}</li>
                                    {% endfor %}
                                    </ul>
                                </td>
                                <td>
                                    <ul class="record_actions">
                                        <li>
                                            <a href="{{ path('chill_crud_projet_prof_view', {'id': pr.id, 'person_id' : person.id}) }}" class="btn btn-show"></a>
                                        </li>
                                        <li>
                                            <a href="{{ path('chill_crud_projet_prof_edit', {'id': pr.id, 'person_id' : person.id}) }}" class="btn btn-edit"></a>
                                        </li>
                                        {% if is_granted('CHILL_JOB_REPORT_DELETE', pr) %}
                                        <li>
                                             <a href="{{ chill_path_add_return_path('chill_crud_projet_prof_delete', {'id': pr.id, 'person_id' : person.id}) }}" class="btn btn-delete"></a>
                                        </li>
                                        {% endif %}
                                    </ul>
                                </td>
                            </tr>

                        {% endfor %}
                    </tbody>
                </table>
            {% endif %}

            <ul class="record_actions">
                <li>
                    <a href="{{ path('chill_crud_projet_prof_new', {'person_id' : person.id }) }}" class="btn btn-new">
                        Nouveau projet professionnel
                    </a>
                </li>
            </ul>
        {% endif %}
    </div>

{% endblock %}
