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

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

{% block meta_title %}{{ helpdesk.name }}{% endblock %}

{% set active_menu = 'system' %}

{% block breadcrumbs %}
    <ol 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">
            <a href="{{ 'extension/settings/support'|alink }}#tab-helpdesks">{{ 'Support'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ 'Helpdesk -'|trans }} {{ helpdesk.name }}</li>
    </ol>
{% endblock %}

{% block content %}

<div class="card">
    <div class="card-header">
        <div>
            <h1 class="card-title">{{ 'Helpdesk'|trans }} - {{ helpdesk.name }}</h1>
            <p class="card-subtitle">{{ 'Helpdesk name will be visible for clients when submitting a new ticket.'|trans }}</p>
        </div>
    </div>
    <form method="post" action="{{ 'api/admin/support/helpdesk_update'|link }}" class="api-form" data-api-msg="{{ 'Helpdesk Updated'|trans }}">
        <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
        <div class="card-body">
            <div class="mb-3 row">
                <label class="col-md-3 col-form-label">{{ 'Title'|trans }}</label>
                <div class="col-md-6">
                    <input class="form-control" type="text" name="name" value="{{ helpdesk.name }}" required>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-md-3 col-form-label">{{ 'Email'|trans }}</label>
                <div class="col-md-6">
                    <input class="form-control" type="email" name="email" value="{{ helpdesk.email }}" required>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-md-3 col-form-label">{{ 'Signature'|trans }}</label>
                <div class="col-md-6">
                    <textarea class="form-control" name="signature" rows="2">{{ helpdesk.signature }}</textarea>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-md-3 col-form-label">{{ 'Close tickets after (in hours)'|trans }}</label>
                <div class="col-md-6">
                    <input class="form-control" type="text" size="3" name="close_after" value="{{ helpdesk.close_after }}" required>
                    <small class="form-hint">{{ 'Define a very large number of hours to disable auto close ticket option.'|trans }}</small>
                </div>
            </div>
            <div class="row">
                <label class="col-md-3 form-label">{{ 'Tickets can be reopened?'|trans }}</label>
                <div class="col-md-6">
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" id="radioCanReopenYes" type="radio" name="can_reopen" value="1"{% if helpdesk.can_reopen %} checked{% endif %}>
                        <label class="form-check-label" for="radioCanReopenYes">{{ 'Yes'|trans }}</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" id="radioCanReopenNo" type="radio" name="can_reopen" value="0"{% if not helpdesk.can_reopen %} checked{% endif %}>
                        <label class="form-check-label" for="radioCanReopenNo">{{ 'No'|trans }}</label>
                    </div>
                </div>
            </div>
        </div>

        <input type="hidden" name="id" value="{{ helpdesk.id }}">

        <div class="card-footer d-flex justify-content-between">
            <div>
                <a href="{{ 'extension/settings/support'|alink }}" class="btn btn-secondary">
                    <svg class="icon">
                        <use xlink:href="#arrow-sm-left" />
                    </svg>
                    {{ 'Go Back'|trans }}
                </a>
                <a class="btn btn-icon btn-danger api-link"
                   href="{{ 'api/admin/support/helpdesk_delete'|link({ 'id': helpdesk.id, 'CSRFToken': CSRFToken }) }}"
                   data-api-type="danger"
                   data-api-confirm-btn="{{ 'Delete'|trans }}"
                   data-api-confirm="{{ 'Are you sure?'|trans }}"
                   data-api-redirect="{{ 'extension/settings/support'|alink }}">
                    <svg class="icon">
                        <use xlink:href="#delete" />
                    </svg>
                </a>
            </div>

            <button class="btn btn-primary" type="submit">{{ 'Update'|trans }}</button>
        </div>
    </form>
</div>
{% endblock %}
