{{!
    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 koperedashboard_requests/my

    Example context (json):
    {
        "newurl": "https://moodle.example.com/local/kopere_dashboard/requests/new.php",

        "rows": [
            {
                "id": 1201,
                "category": "Grade review",
                "subject": "Recheck my assignment grade",
                "status": "Open",
                "created": "2 Mar 2026, 09:12",
                "url": "https://moodle.example.com/local/kopere_dashboard/requests/view.php?id=1201"
            },
            {
                "id": 1194,
                "category": "Contract issues",
                "subject": "Update contract holder details",
                "status": "Waiting for response",
                "created": "27 Feb 2026, 16:40",
                "url": "https://moodle.example.com/local/kopere_dashboard/requests/view.php?id=1194"
            }
        ]
    }
}}

<div class="kopere_dashboard-card">
    <div style="display:flex; justify-content: space-between; align-items:center;">
        <a class="btn btn-primary" href="{{{newurl}}}">{{#str}}new_title, koperedashboard_requests{{/str}}</a>
    </div>

    <table class="table table-striped kopere_dashboard-card-table" style="margin-top: 12px;">
        <thead>
        <tr>
            <th>ID</th>
            <th>{{#str}}request_category, koperedashboard_requests{{/str}}</th>
            <th>{{#str}}request_subject, koperedashboard_requests{{/str}}</th>
            <th>{{#str}}request_status, koperedashboard_requests{{/str}}</th>
            <th>Created</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {{#rows}}
            <tr>
                <td>{{{id}}}</td>
                <td>{{{category}}}</td>
                <td>{{{subject}}}</td>
                <td>{{{status}}}</td>
                <td>{{{created}}}</td>
                <td><a class="btn btn-secondary" href="{{{url}}}">
                    {{#str}}view_request, koperedashboard_requests{{/str}}</a>
                </td>
            </tr>
        {{/rows}}
        {{^rows}}
            <tr>
                <td colspan="6" class="muted">No requests.</td>
            </tr>
        {{/rows}}
        </tbody>
    </table>
</div>
