{{!
    @template local_kid/admin_export

    * hasnosession - bool
    * promotionid, sessionid - int
    * sessionoptions - [{id, label, selected}]
    * promotionname, sessioncode - string
    * niveauxrowcount, commentairesrowcount - int
    * haserrors - bool
    * errors - string[]
    * norows - bool
    * canexport - bool
    * downloadniveauxurl, downloadcommentairesurl - string
}}
<div class="fr-scope">
{{#hasnosession}}
    {{> local_kid/empty_state}}
{{/hasnosession}}

{{^hasnosession}}
<p class="fr-text--sm">{{#str}}adesi_help, local_kid{{/str}}</p>

<form method="get" class="fr-grid-row fr-grid-row--gutters fr-grid-row--bottom fr-mb-4w">
    <input type="hidden" name="tab" value="export">
    <input type="hidden" name="promotionid" value="{{promotionid}}">
    <div class="fr-col-12 fr-col-md-4">
        <div class="fr-select-group fr-mb-0">
            <label class="fr-label" for="adesi-session">{{#str}}capp_col_code, local_kid{{/str}}</label>
            <select name="sessionid" id="adesi-session" class="fr-select" onchange="this.form.submit()">
                {{#sessionoptions}}<option value="{{id}}" {{#selected}}selected{{/selected}}>{{label}}</option>{{/sessionoptions}}
            </select>
        </div>
    </div>
    <noscript><div class="fr-col"><button type="submit" class="fr-btn fr-btn--secondary">{{#str}}promotion_switch_go, local_kid{{/str}}</button></div></noscript>
</form>

<div class="fr-card">
    <div class="fr-card__body">
        <div class="fr-card__content">
            <h3 class="fr-card__title">{{#str}}adesi_preview_heading, local_kid{{/str}}</h3>
            <p>{{promotionname}} — {{sessioncode}}</p>

            {{#norows}}
            <p>{{#str}}adesi_error_norows, local_kid{{/str}}</p>
            {{/norows}}

            {{^norows}}
            <div class="fr-grid-row fr-grid-row--gutters fr-mb-2w">
                <div class="fr-col-6 fr-col-md-3">
                    <div class="fr-card">
                        <div class="fr-card__body">
                            <div class="fr-card__content fr-py-2w">
                                <p class="fr-display--xs fr-mb-0">{{niveauxrowcount}}</p>
                                <p class="fr-text--sm fr-mb-0">{{#str}}adesi_rows_niveaux, local_kid{{/str}}</p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="fr-col-6 fr-col-md-3">
                    <div class="fr-card">
                        <div class="fr-card__body">
                            <div class="fr-card__content fr-py-2w">
                                <p class="fr-display--xs fr-mb-0">{{commentairesrowcount}}</p>
                                <p class="fr-text--sm fr-mb-0">{{#str}}adesi_rows_commentaires, local_kid{{/str}}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {{/norows}}

            {{#haserrors}}
            <div class="fr-alert fr-alert--error fr-mb-2w">
                <p class="fr-alert__title">{{#str}}adesi_errors_heading, local_kid{{/str}}</p>
                <ul>
                    {{#errors}}<li>{{.}}</li>{{/errors}}
                </ul>
            </div>
            {{/haserrors}}

            {{#canexport}}
            <ul class="fr-btns-group fr-btns-group--inline-md fr-mb-0">
                <li><a class="fr-btn" href="{{downloadniveauxurl}}">{{#str}}adesi_download_niveaux, local_kid{{/str}}</a></li>
                <li><a class="fr-btn" href="{{downloadcommentairesurl}}">{{#str}}adesi_download_commentaires, local_kid{{/str}}</a></li>
            </ul>
            {{/canexport}}
        </div>
    </div>
</div>
{{/hasnosession}}
</div>
