{% extends "helpdesk/base.html" %}

{% load i18n %}

{% block helpdesk_title %}{% trans "Add Ticket CC" %}{% endblock %}

{% block helpdesk_breadcrumb %}
    <li class="breadcrumb-item">
        <a href="{% url 'helpdesk:list' %}">{% trans "Tickets" %}</a>
    </li>
    <li class="breadcrumb-item">
        <a href="{% url 'helpdesk:list' %}{{ ticket.id }}/">{{ ticket.queue.slug }}-{{ ticket.id }}</a>
    </li>
    <li class="breadcrumb-item">
        <a href="{% url 'helpdesk:ticket_cc' ticket.id %}">{% trans "CC Settings" %}</a>
    </li>
    <li class="breadcrumb-item active">{% trans "Add CC" %}</li>
{% endblock %}

{% block helpdesk_body %}
    <h2>{% trans 'Add Ticket CC' %}</h2>

    <div class="card mb-3">
        <div class="card-header">
            <i class="fas fa-hand-pointer"></i>
            {% trans 'To automatically send an email to a user or e-mail address when this ticket is updated, select the user or enter an e-mail address below.' %}
        </div>
        <div class="card-body">
            <!-- Nav tabs -->
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link{% if not form.errors.user %} active{% endif %}" href="#EmailCC" data-toggle="tab">
                        {% trans 'Email' %}
                    </a>
                </li>
                <li class="divider"></li>
                <li class="nav-item">
                    <a class="nav-link{% if form.errors.user %} active{% endif %}" href="#UserCC" data-toggle="tab">
                        {% trans 'User' %}
                    </a>
                </li>
            </ul>

            {% if form.errors %}
                {% include 'helpdesk/include/alert_form_errors.html' %}
                <ul>{{ form.non_field_errors }}</ul>
            {% endif %}

            <!-- Tab panes -->
            <div class="tab-content">
                <div class="tab-pane{% if not form.errors.user %} in active{% endif %}" id="EmailCC">
                    <h4>{% trans 'Add Email' %}</h4>
                    <form method='post'>
                        {% csrf_token %}
                        <fieldset>
                            <dl>
                                {% for field in form_email %}
                                    <dt>{{ field.label_tag }}</dt>
                                    <dd>{{ field }}</dd>
                                    {% if field.name == 'email' and form.errors.email %}
                                        <dd class='error'>{{ form.errors.email }}</dd>
                                    {% endif %}
                                    {% if field.help_text %}
                                        <dd class='form_help_text'>{{ field.help_text }}</dd>
                                    {% endif %}
                                {% endfor %}
                            </dl>
                        </fieldset>
                        <button class="btn btn-primary" type='submit'>{% trans "Save Ticket CC" %}</button>
                    <a href="{% url 'helpdesk:ticket_cc' ticket.id %}" class="btn btn-secondary">
                        {% trans "Cancel" %}
                    </a>
                    </form>
                </div>
                <div class="tab-pane{% if form.errors.user %} in active{% endif %}" id="UserCC">
                    <h4>{% trans 'Add User' %}</h4>
                    <form method='post'>
                        {% csrf_token %}
                        <fieldset>
                            <dl>
                                {% for field in form_user %}
                                    <dt>{{ field.label_tag }}</dt>
                                    <dd>{{ field }}</dd>
                                    {% if field.name == 'user' and form.errors.user %}
                                        <dd class='error'>{{ form.errors.user }}</dd>
                                    {% endif %}
                                    {% if field.help_text %}
                                        <dd class='form_help_text'>{{ field.help_text }}</dd>
                                    {% endif %}
                                {% endfor %}
                            </dl>
                        </fieldset>
                        <button class="btn btn-primary" type='submit'>{% trans "Save Ticket CC" %}</button>
                    <a href="{% url 'helpdesk:ticket_cc' ticket.id %}" class="btn btn-secondary">
                        {% trans "Cancel" %}
                    </a>
                    </form>
                </div>
            </div>
        </div>
        <!-- /.card-body -->
    </div>
    <!-- /.card -->
{% endblock %}
