{%extends 'cmdb/base.html'%}

{% load bob %}
{% load icons %}
{% load query %}

{% block content %}
    <style type="text/css">
        form.form-inline input[type=text]
        {
            width: 90px;
        }

        form.form-inline select
        {
            width: auto;
        }
    </style>
    <h3>Changes</h3>

    <form class="form-inline well">
    {% for f in form %}
            {{ f.label_tag }}
            {{ f }}
    {% endfor %}
        <button type="submit" class="btn btn-primary">{% icon 'fugue-magnifier' %}&nbsp;Search</button>
    </form>

    <table class="table table-striped table-bordered table-condensed">
        <thead>
            <tr>
                {% table_header columns url_query sort fugue_icons=1 %}
            </tr>
        </thead>
        <tbody>
        {% for change in bob_page %}
            <tr>
                <td>{{ change.time}}</td>
                <td>{{ change.message|truncatechars:40 }}</td>
                <td>
                    <a href="/cmdb/ci/view/{{ change.ci.id }}" target="_noblank">
                        {% if change.1 %}
                        {% icon change.1 %}
                        {% endif %}
                        {{ change.ci.name}}
                    </a>
                </td>
                <td>
                    {% if change.priority == 4 %}
                    {% icon 'fugue-exclamation-red' %}
                    {% elif change.priority == 3 %}
                    {% icon 'fugue-exclamation' %}
                    {% elif change.priority == 2 %}
                    {% icon 'fugue-exclamation-white' %}
                    {% else %}
                    {% endif %}
                    {{ change.get_priority_display}}
                </td>
                <td>
                    {% if change.type == 2  %}
                        {% icon 'fugue-disc--arrow' %}
                    {% elif change.type == 1  %}
                        {% icon 'fugue-blue-document-node' %}
                    {% elif change.type == 3  %}
                        {% icon 'fugue-computer' %}
                    {% endif %}
                    {{ change.get_type_display }}
                </td>
                <td> <a href="{{jira_url}}/{{ change.external_key}}"> {{ change.external_key }} </a></td>
                <td>
                    {% if change.type == 4 %}
                    <a href="{{ZABBIX_URL}}/events.php?triggerid={{ change.content_object.trigger_id }}&nav_time=1340101543"  target="_noblank">
                        {% icon 'fugue-report' %} View in Zabbix
                    </a>
                    {% elif change.type == 5 %}
                    <a href="{{SO_URL}}"  target="_noblank">
                        {% icon 'fugue-report' %} View in SO
                    </a>
                    {% else %}
                    <a href="/cmdb/changes/change/{{ change.id }}" target="_noblank">
                       {% icon 'fugue-report' %}  View
                    </a>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {% pagination bob_page url_query=url_query show_all=0 show_csv=0 fugue_icons=1 %}
{% endblock %}
