{{!
    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:
    * none

    Data attributes required for JS:
    * none

    Context variables required for this template:
    * none

    Example context (json):
    {
        "invites": array_values($DB->get_records('local_treestudyplan_invit', ['user_id' => $USER->id]));
        "hasinvites": true,
    }
}}
<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>
            <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>
            <th>&nbsp;</th>
        </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>
                <td data-field='control'>
                    <a  class='m-action-view '
                        href='{{globals.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='{{globals.config.wwwroot}}/local/treestudyplan/edit-invite.php?resend={{id}}'
                        title='{{#str}} invite_tooltip_resend, local_treestudyplan {{/str}}'
                    ><i class='fa fa-envelope'></i></a>

                    <a  href='{{globals.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='{{globals.config.wwwroot}}/local/treestudyplan/edit-invite.php?delete={{id}}'
                        title='{{#str}} invite_tooltip_delete, local_treestudyplan {{/str}}'
                    ><i class='fa fa-trash'></i></a>
                </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-info' 
        href='{{globals.config.wwwroot}}/local/treestudyplan/edit-invite.php?add=true' class='btn btn-primary' id='add_invite'>
        <i class='fa fa-plus'></i> {{#str}} invite_button_new, local_treestudyplan {{/str}}
    </a>
</div>