<!DOCTYPE document SYSTEM "rml.dtd">

{% load assessments i18n staticfiles %}

<document filename="{{ view.get_filename }}.pdf">

    <docinit>
        <registerTTFont faceName="Istok" fileName="{{ settings.STATIC_ROOT }}/pdf_reporting/fonts/istok/Istok-Regular.ttf"/>
        <registerTTFont faceName="IstokBold" fileName="{{ settings.STATIC_ROOT }}/pdf_reporting/fonts/istok/Istok-Bold.ttf"/>
        <registerTTFont faceName="IstokBoldItalic" fileName="{{ settings.STATIC_ROOT }}/pdf_reporting/fonts/istok/Istok-BoldItalic.ttf"/>
        <registerTTFont faceName="IstokItalic" fileName="{{ settings.STATIC_ROOT }}/pdf_reporting/fonts/istok/Istok-Italic.ttf"/>
        <registerFontFamily normal="Istok" bold="IstokBold" italic="IstokItalic" boldItalic="IstokBoldItalic"/>
    </docinit>

    <template title="{{ view.get_filename }}" author="Magency">
        <pageTemplate id="main">
            <pageGraphics>
                <setFont name="Istok" size="12"/>
                <drawCentredString x="292" y="1cm">Page <pageNumber/> / <getName id="lastPage" default="0" /></drawCentredString>
            </pageGraphics>
            <frame id="first" x1="60" y1="60" width="475" height="698"/>
        </pageTemplate>
    </template>

    <stylesheet>
        <paraStyle name="default" fontName="Istok" alignment="center" />
        <paraStyle name="header" textColor="{{ theme.text_on_main }}" parent="default" />
        <blockTableStyle id="genericTable">
            <blockFont name="Istok" />
            <lineStyle kind="GRID" colorName="black"/>
            <blockAlignment value="center" start="0,0" stop="-1,-1" />
            <blockAlignment value="center" start="0,0" stop="-1,-1" />
            <blockValign value="middle" start="0,0" stop="-1,-1" />
        </blockTableStyle>
        <blockTableStyle id="headerTable" parent="genericTable">
            <blockTextColor colorName="{{ theme.text_on_main }}" start="0,0" stop="-1,0" />
            <blockBackground colorName="{{ theme.main }}" start="0,0" stop="-1,0"/>
        </blockTableStyle>
        <blockTableStyle id="resumeTable" parent="genericTable" />
        <blockTableStyle id="competenciesTable" parent="headerTable">
            <blockSpan start="0,0" stop="1,0"/>
        </blockTableStyle>
        <blockTableStyle id="globalTable" parent="headerTable">
            <blockSpan start="1,2" stop="2,2"/>
        </blockTableStyle>
        <blockTableStyle id="recommendationsTable" parent="headerTable" />
    </stylesheet>

    <story>
        <imageFigure imageName="{{ theme.brand_logo.path }}" imageHeight="50" preserveAspectRatio="yes" pdfBoxType="MediaBox" align="CENTER"/>
        <spacer length="0.5cm" />
        <title>{% trans 'Certification Results' %}</title>
        <spacer length="1cm" />
        <blockTable style="resumeTable" colWidths="4cm,100%">
            <tr>
                <td>{% trans 'Participant' %}</td>
                <td>{{ trainee.get_full_name }}</td>
            </tr>
            <tr>
                <td>{% trans 'Job Profile' %}</td>
                <td>{{ certificationprogramuserstatus.program.tree.job_profile.name }}</td>
            </tr>
            <tr>
                <td>{% trans 'Training' %}</td>
                <td>{{ certificationprogramuserstatus.session.training.name }}</td>
            </tr>
            <tr>
                <td>{% trans 'Graduation date' %}</td>
                <td>{{ certificationprogramuserstatus.date_reached|date:"SHORT_DATE_FORMAT" }}</td>
            </tr>
        </blockTable>
        <spacer length="1cm" />
        <blockTable style="competenciesTable" colWidths="3.5cm, 100%, 3cm, 3cm">
            <tr>
                <td><para style="header">{% trans 'Competencies' %}</para></td>
                <td />
                <td><para style="header">{% trans 'Your score' %}</para></td>
                <td><para style="header">{% trans 'Minimum score' %}</para></td>
            </tr>
            {% for competency_score in competency_scores %}
            <tr>
                <td>{% trans 'Competency' %} {{ forloop.counter }}</td>
                <td>
                    <para style="default">{{ competency_score.competency|get_localized_name:business_unit }}</para>
                </td>
                <td>{{ competency_score.score }}%</td>
                <td>{{ competency_score.reference_certification_threshold.threshold|default:"0" }}%</td>
            </tr>
            {% endfor %}
        </blockTable>
        <spacer length="1cm" />
        <blockTable style="globalTable" colWidths="100%, 3cm, 3cm">
            <tr>
                <td><para style="header">{% trans 'Global result' %}</para></td>
                <td><para style="header">{% trans 'Your score' %}</para></td>
                <td><para style="header">{% trans 'Minimum score' %}</para></td>
            </tr>
            <tr>
                <td>{% trans 'Global score' %}</td>
                <td>{{ certificationprogramuserstatus.score }}%</td>
                <td>{{ certificationprogramuserstatus.program.reference_status.global_threshold|default:"0" }}%</td>
            </tr>
            <tr>
                <td>{% trans 'Based on his score the participant is' %}</td>
                <td>{{ certificationprogramuserstatus.status.name }}</td>
                <td />
            </tr>
        </blockTable>
        <nextFrame/>
        {% if recommendations %}
            <spacer length="1cm" />
            <blockTable style="recommendationsTable" colWidths="100%, 100%, 100%, 2cm, 2cm, 100%">
                <tr>
                    <td><para style="header">{% trans 'Module' %}</para></td>
                    <td><para style="header">{% trans 'Formation type' %}</para></td>
                    <td><para style="header">{% trans 'Formation duration' %}</para></td>
                    <td><para style="header">{% trans 'Your score' %}</para></td>
                    <td><para style="header">{% trans 'Minimum score' %}</para></td>
                    <td><para style="header">{% trans 'Recommendation' %}</para></td>
                </tr>
                {% for topic, recommendations in recommendations_by_topic.items %}
                    <tr>
                        <td colspan="6" background="{{ theme.gray }}">{{ topic.name }}</td>
                    </tr>
                    {% for recommendation in recommendations %}
                        <tr>
                            <td><para style="default">{{ recommendation.lesson.name }}</para></td>
                            <td><para style="default">{{ recommendation.lesson.get_type_display }}</para></td>
                            <td><para style="default">{{ recommendation.lesson.duration }}</para></td>
                            <td><para style="default">{{ recommendation.score }}%</para></td>
                            <td><para style="default">{{ recommendation.lesson.reference_recommendation_threshold.threshold|default:"0" }}%</para></td>
                            <td><para style="default">{{ recommendation.level.name }}</para></td>
                        </tr>
                    {% endfor %}
                {% endfor %}
            </blockTable>
        {% endif %}
        <namedString id="lastPage"><pageNumber/></namedString>
    </story>

</document>
