{% extends "helpdesk/inner.html" %}
{% load i18n %}
{% load url from future %}

{% block helpdesk_widgets %}

    {% if helpdesk_settings.HELPDESK_SHOW_KB_ON_HOMEPAGE %}
        <div class="dk-widget">
            <h3>{% trans "Knowledgebase Articles" %}</h3>
            <hr />
            <table width='100%'>
                <tr class='row_tablehead'><td>{% trans "Knowledgebase Categories" %}</td></tr>
                <tr class='row_columnheads'><th>{% trans "Category" %}</th></tr>
                
                {% for category in kb_categories %}
                <tr class='row_even row_hover'><th><a href='{{ category.get_absolute_url }}'>{{ category.title }}</a></th></tr>
                <tr class='row_odd'><td>{{ category.description }}</td></tr>
                {% endfor %}
            </table>
        </div>
    {% endif %}
    
    {% if helpdesk_settings.HELPDESK_VIEW_A_TICKET_PUBLIC %}
        <div class="dk-widget">
            <h3>{% trans "View a Ticket" %}</h3>
            <hr />
            <form method='get' action='{% url 'helpdesk_public_view' %}'>
                <fieldset>
                    <dl>
                        <dt><label for='id_ticket'>{% trans "Ticket" %}</label></dt>
                        <dd><input type='text' name='ticket' /></dd>
                
                        <dt><label for='id_email'>{% trans "Your E-mail Address" %}</label></dt>
                        <dd><input type='text' name='email' /></dd>
                    </dl>
                
                    <input type='submit' value='{% trans "View Ticket" %}' />
                </fieldset>
                {% csrf_token %}
            </form>
        </div>
    {% endif %}
    
    {% if show_submit_form %}
        <div class="dk-widget">
            <h3>{% trans "Submit a Ticket" %}</h3>
            <hr/>
            <p>{% trans "All fields are required. Please provide as descriptive a title and description as possible." %}</p>
            <form method='post' action='./#submit' enctype='multipart/form-data'>
                <fieldset>
                    <dl>
                        {% for field in form %}
                            {% if field.is_hidden %}
                                {{ field }}
                            {% else %}
                                <dt><label for='id_{{ field.name }}'>{{ field.label }}</label>{% if not field.field.required %} <span class='form_optional'>{% trans "(Optional)" %}</span>{% endif %}</dt>
                                <dd>{{ field }}</dd>
                                {% if field.errors %}<dd class='error'>{{ field.errors }}</dd>{% endif %}
                                {% if field.help_text %}<dd class='form_help_text'>{{ field.help_text }}</dd>{% endif %}
                            {% endif %}
                        {% endfor %}
                    </dl>
                    
                    <div class='buttons'>
                        <input type='submit' value='{% trans "Submit Ticket" %}' />
                    </div>
                </fieldset>
                {% csrf_token %}
            </form>
        </div>
    {% endif %}
    
    {% if not helpdesk_settings.HELPDESK_VIEW_A_TICKET_PUBLIC and not helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC %}
        <h2>{% trans "Please use button at upper right to login first." %}</h2>
    {% endif %}

{% endblock %}
