{{!
    This file is part of Moodle - https://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template local_treestudyplan/invitations

    Template for rendering the invitations page

    Classes required for JS:
    * m-action-resend
    * m-action-confirm
    * m-action-delete
    * m-action-view

    Data attributes required for JS:
    * data-confirmtext
    * data-confirmbtn
    * data-actionhref

    Context variables required for this template:
    * none

    Example context (json):
    {
        "invites": [{
            "id": 1,
            "user_id": 33,
            "name": "Test Recipient",
            "email": "test@test.tst",
            "idate": 1735513200,
            "lock": true,
            "unlocked": false
        }],
        "hasinvites": true,
        "haslocked": true,
        "wwwroot": "https://my.moodle/location"
    }
}}
<div class="local_treestudyplan_invitations">
    <p>{{#str}} invite_description, local_treestudyplan {{/str}}</p>
    <h3>{{#str}} invite_tablecaption, local_treestudyplan {{/str}}</h3>
    <table class='m-manage_invites'>
        <thead>
            <tr>
                <th>&nbsp;{{#str}} invite_name, local_treestudyplan {{/str}} </th>
                <th> {{#str}} invite_email, local_treestudyplan {{/str}} </th>
                <th> {{#str}} invite_date, local_treestudyplan {{/str}} </th>
                {{#haslocked}}
                <th> {{#str}} invite_unlock_date, local_treestudyplan {{/str}} </th>
                {{/haslocked}}
                <th>&nbsp;</th>
            </tr>
        </thead>

        <tbody>
            {{#hasinvites}}
            {{#invites}}
            <tr data-id='{{.id}}'>
                <td data-field='name'>{{name}}</td>
                <td data-field='email'>{{email}}</td>
                <td data-field='date'>{{#userdate}} {{idate}}, %x {{/userdate}}</td>
                {{#haslocked}}
                <td data-field='unlocks' >
                    {{#lock}}
                        <span class='{{#unlocked}}text-success{{/unlocked}}{{^unlocked}}text-danger{{/unlocked}}'>
                        {{#userdate}} {{unlockdate}}, %x {{/userdate}}
                        {{#unlocked}}<i>({{#str}} invite_unlocked, local_treestudyplan {{/str}})</i>{{/unlocked}}
                        </span>
                    {{/lock}}
                    {{^lock}}{{#str}} invite_notlocked, local_treestudyplan {{/str}}{{/lock}}
                </td>
                {{/haslocked}}
                <td data-field='control'>
                    <a  class='m-action-view '
                        href='{{config.wwwroot}}/local/treestudyplan/invited.php?key={{invitekey}}'
                        title='{{#str}} invite_tooltip_testlink, local_treestudyplan {{/str}}'
                        ><i class='fa fa-eye'></i></a>

                    <a  class='m-action-resend m-action-confirm'
                        data-confirmtext='{{#str}} invite_confirm_resend, local_treestudyplan {{/str}}'
                        data-confirmbtn='{{#str}} send, local_treestudyplan {{/str}}'
                        href='#'
                        data-actionhref='{{config.wwwroot}}/local/treestudyplan/edit-invite.php?resend={{id}}'
                        title='{{#str}} invite_tooltip_resend, local_treestudyplan {{/str}}'
                    ><i class='fa fa-envelope'></i></a>

                    {{#unlocked}}
                    <a  href='{{config.wwwroot}}/local/treestudyplan/edit-invite.php?update={{id}}'
                        ><i class='fa fa-pencil' title='{{#str}} invite_tooltip_edit, local_treestudyplan {{/str}}'></i></a>

                    <a  class='m-action-delete m-action-confirm'
                        data-confirmtext='{{#str}} invite_confirm_delete, local_treestudyplan, {{name}} {{/str}}'
                        data-confirmbtn='{{#str}} delete, core {{/str}}'
                        href='#' data-actionhref='{{config.wwwroot}}/local/treestudyplan/edit-invite.php?delete={{id}}'
                        title='{{#str}} invite_tooltip_delete, local_treestudyplan {{/str}}'
                    ><i class='fa fa-trash'></i></a>
                    {{/unlocked}}
                </td>
            </tr>
            {{/invites}}
            {{/hasinvites}}
            {{^hasinvites}}
            <tr><td colspan='6'>{{#str}} invite_table_empty, local_treestudyplan {{/str}}</td></tr>
            {{/hasinvites}}
        </tbody>
    </table>

    <a  class='btn btn-primary'
        href='{{config.wwwroot}}/local/treestudyplan/edit-invite.php?add=true'  id='add_invite'>
        <i class='fa fa-plus'></i> {{#str}} invite_button_new, local_treestudyplan {{/str}}
    </a>
</div>