{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}

{% import "macro_functions.html.twig" as mf %}

{% block meta_title %}{{ 'Paid support settings'|trans }}{% endblock %}

{% set active_menu = 'system' %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|alink }}">
                <svg class="icon">
                    <use xlink:href="#home" />
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'system'|alink }}">{{ 'Settings'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ 'Paid support settings'|trans }}</li>
    </ul>
{% endblock %}

{% block content %}
    <div class="card">
        <div class="card-header">
            <h3 class="card-title">{{ 'Paid support settings'|trans }}</h3>
            <div class="card-actions">
                <a href="{{ 'extension/settings/support'|alink }}#tab-new-helpdesk" class="btn btn-primary">
                    <svg class="icon">
                        <use xlink:href="#plus"/>
                    </svg>
                    <span>{{ 'New helpdesk'|trans }}</span>
                </a>
            </div>
        </div>

        {% set params = admin.extension_config_get({ "ext": "mod_paidsupport" }) %}
        <form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="api-form" data-api-msg="Settings updated">
            <div class="card-body">
                <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
                <input type="hidden" name="ext" value="mod_paidsupport" />
                <div class="row mb-3">
                    <label class="col-md-3 col-form-label">{{ 'Ticket price'|trans }}</label>
                    <div class="col-md-6">
                        <input class="form-control" type="text" name="ticket_price" value="{{ params.ticket_price }}" required="required"/>
                    </div>
                </div>
                <div class="row mb-3">
                    <label class="col-md-3 col-form-label">{{ 'Error message'|trans }}</label>
                    <div class="col-md-6">
                        <input class="form-control" type="text" name="error_msg" value="{{ params.error_msg }}" required="required" />
                    </div>
                </div>
            </div>
            <div class="card-body border-bottom">
                <h3 class="card-title">{{ 'Set paid support for helpdesks'|trans }}</h3>
            </div>
            <div class="table-responsive">
                <table class="table card-table table-vcenter table-striped text-nowrap">
                    <thead>
                    <tr>
                        <th class="w-1"></th>
                        <th>{{ 'Helpdesk'|trans }}</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for id, title in admin.support_helpdesk_get_pairs %}
                        <tr>
                            <td>
                                <input type="hidden" name="helpdesk[{{ id }}]" value="0">
                                <input class="form-check-input m-0 align-middle" type="checkbox" name="helpdesk[{{ id }}]" value="1" id="helpdesk_{{ id }}"
                                       {% if params.helpdesk[id] == 1 %}checked="checked"{% endif %}/>
                            </td>
                            <td><label for="helpdesk_{{ id }}">{{ title }}</label></td>
                            <td class="text-end">
                                <a class="btn btn-icon" href="{{ '/support/helpdesk'|alink }}/{{ id }}"
                                data-bs-toggle="tooltip" data-bs-title="{{ 'Edit'|trans }}">
                                    <svg class="icon">
                                        <use xlink:href="#edit"/>
                                    </svg>
                                </a>
                            </td>
                        </tr>
                    {% else %}
                        <tr>
                            <td colspan="3">{{ 'The list is empty'|trans }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <div class="card-footer text-end">
                    <input type="submit" value="{{ 'Update'|trans }}" class="btn btn-primary"/>
                </div>
            </div>
        </form>
    </div>
{% endblock %}
