{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% import "macro_functions.phtml" as mf %}
{% block meta_title %}Help desks{% endblock %}
{% set active_menu = 'system' %}
{% block content %}
<div class="widget simpleTabs nomargin">

    <ul class="tabs">
        <li><a href="#tab-index">{% trans 'Support help desks' %}</a></li>
        <li><a href="#tab-new">{% trans 'New help desk' %}</a></li>
    </ul>

    <div class="tabs_container">
        <div class="fix"></div>
        <div class="tab_content nopadding" id="tab-index">

            {{ mf.table_search }}
            <table class="tableStatic wide">
                <thead>
                    <tr>
                        <th style="width: 40%">{% trans 'Title' %}</th>
                        <th>{% trans 'Email' %}</th>
                        <th>{% trans 'Close tickets after' %}</th>
                        <th style="width: 13%">&nbsp;</th>
                    </tr>
                </thead>

                <tbody>
                {% for helpdesk in admin.support_helpdesk_get_list({"per_page":50, "page":request.page}|merge(request)).list %}
                <tr>
                    <td>{{ helpdesk.name }}</td>
                    <td>{{ helpdesk.email }}</td>
                    <td>{{ helpdesk.close_after }} hour(s)</td>
                    <td class="actions">
                        <a class="bb-button btn14" href="{{ '/support/helpdesk'|alink }}/{{helpdesk.id}}"><img src="images/icons/dark/pencil.png" alt=""></a>
                        <a class="bb-button btn14 bb-rm-tr api-link" data-api-confirm="Are you sure?" data-api-redirect="support/helpdesks" href="admin/support/helpdesk_delete?id={{helpdesk.id}}"><img src="images/icons/dark/trash.png" alt=""></a>
                    </td>
                </tr>
                </tbody>

                {% else %}
                <tbody>
                    <tr>
                        <td colspan="4">
                            {% trans 'The list is empty' %}
                        </td>
                    </tr>
                </tbody>
                {% endfor %}
            </table>

        </div>

        <div class="tab_content nopadding" id="tab-new">

            <form method="post" action="admin/support/helpdesk_create" class="mainForm save api-form" data-api-redirect="support/helpdesks">
                <fieldset>
                    <div class="rowElem">
                        <label>{% trans 'Title' %}</label>
                        <div class="formRight noborder">
                            <input type="text" name="name" value="{{ helpdesk.name }}" required="required"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    <div class="rowElem">
                        <label>{% trans 'Email' %}</label>
                        <div class="formRight">
                            <input type="text" name="email" value="{{ helpdesk.email }}" required="required"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    <div class="rowElem">
                        <label>{% trans 'Signature' %}</label>
                        <div class="formRight">
                            <textarea name="signature" cols="5" rows="3">{{ helpdesk.signature }}</textarea>
                        </div>
                        <div class="fix"></div>
                    </div>
                    <div class="rowElem">
                        <label>{% trans 'Close after' %}</label>
                        <div class="formRight">
                            <input type="text" name="close_after" value="{{ helpdesk.close_after|default('48') }}" required="required"/>
                        </div>
                        <div class="fix"></div>
                    </div>
                    <div class="rowElem">
                        <label>{% trans 'Can reopen' %}</label>
                        <div class="formRight">
                            <input type="radio" name="can_reopen" value="1" checked="checked"/><label>{% trans 'Yes' %}</label>
                            <input type="radio" name="can_reopen" value="0"/><label>{% trans 'No' %}</label>
                        </div>
                        <div class="fix"></div>
                    </div>

                    <input type="submit" value="{% trans 'Create' %}" class="greyishBtn submitForm" />
                    <input type="hidden" name="id" value="{{ helpdesk.id }}"/>
                </fieldset>
            </form>

        </div>
    </div>

</div>

{% endblock %}
