{{!
    @template local_kid/admin_promotions

    * addurl - string
    * haspromotions - bool
    * promotions - array of { id, name, statuslabel, statusclass, cohortlabel,
      studentcount, linkurl, unlinkurl, resyncurl, toggleurl, renameurl,
      deleteurl, candelete, deleteblockedreason,
      cohortoptions (array of {id, name, selected}), islinked }
    * sesskey - string
}}
<div class="fr-scope">
<p class="fr-mb-4w">
    <a class="fr-btn" href="{{addurl}}">{{#str}}promotion_add, local_kid{{/str}}</a>
</p>

{{^haspromotions}}
    {{> local_kid/empty_state}}
{{/haspromotions}}

{{#haspromotions}}
<div class="fr-table">
    <table>
        <caption>{{#str}}promotion_col_name, local_kid{{/str}}</caption>
        <thead>
            <tr>
                <th scope="col">{{#str}}promotion_col_name, local_kid{{/str}}</th>
                <th scope="col">{{#str}}promotion_col_cohort, local_kid{{/str}}</th>
                <th scope="col">{{#str}}promotion_col_students, local_kid{{/str}}</th>
                <th scope="col">{{#str}}promotion_col_status, local_kid{{/str}}</th>
                <th scope="col">{{#str}}promotion_col_actions, local_kid{{/str}}</th>
            </tr>
        </thead>
        <tbody>
            {{#promotions}}
            <tr>
                <td>{{name}}</td>
                <td>{{cohortlabel}}</td>
                <td>{{studentcount}}</td>
                <td><span class="{{statusclass}}">{{statuslabel}}</span></td>
                <td>
                    <a class="fr-link" href="{{renameurl}}">{{#str}}action_rename, local_kid{{/str}}</a>
                    {{#islinked}}
                        · <a class="fr-link" href="{{resyncurl}}">{{#str}}action_resync, local_kid{{/str}}</a>
                        · <a class="fr-link" href="{{unlinkurl}}">{{#str}}action_unlink, local_kid{{/str}}</a>
                    {{/islinked}}
                    {{^islinked}}
                        · <a class="fr-link" href="{{linkurl}}">{{#str}}action_link, local_kid{{/str}}</a>
                    {{/islinked}}
                    · <a class="fr-link" href="{{toggleurl}}">{{#str}}action_toggle_active, local_kid{{/str}}</a>
                    {{#candelete}}
                    · <form class="kid-inline-form" method="post" action="{{deleteurl}}" onsubmit="return confirm('{{#str}}promotion_delete_confirm, local_kid{{/str}}');">
                        <input type="hidden" name="sesskey" value="{{sesskey}}">
                        <button type="submit" class="fr-link">{{#str}}action_delete, local_kid{{/str}}</button>
                    </form>
                    {{/candelete}}
                    {{^candelete}}
                    · <span class="fr-text--sm" title="{{deleteblockedreason}}">{{#str}}action_delete, local_kid{{/str}}</span>
                    {{/candelete}}
                </td>
            </tr>
            {{/promotions}}
        </tbody>
    </table>
</div>
{{/haspromotions}}
</div>
