{% extends 'base.html' %}
{% load static %}
{% load helpers %}
{% load form_helpers %}

{% block title %} Cable Path Finder {% endblock title %}

{% block content %}
    <form method="post" class="form form-horizontal">
        {% csrf_token %}
        {% for field in form.hidden_fields %}
            {{ field }}
        {% endfor %}
        {% if form.non_field_errors %}
            <div class="row">
                <div class="col-md-6 col-md-offset-3">
                    <div class="panel panel-danger">
                        <div class="panel-heading"><strong>Errors</strong></div>
                        <div class="panel-body">
                            {{ form.non_field_errors }}
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
        <h3>Cable Path Finder</h3>
        <div class="row">
            <div class="col-md-5">
                <div class="panel panel-default">
                    <div class="panel-heading text-center">
                        <strong>A Side</strong>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <label class="col-md-3 control-label required">Site</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_a.device.site }}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label required">Rack</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_a.device.rack }}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label required">Device</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_a.device }}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label required">Type</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_a_type_name }}</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label required">{{ termination_a_type_name }}</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_a }}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-2 text-center" style="padding-top: 90px;">
                <i class="fa fa-exchange fa-4x"></i>
            </div>
            <div class="col-md-5">
                <div class="panel panel-default">
                    <div class="panel-heading text-center">
                        <strong>B Side</strong>
                    </div>
                    <div class="panel-body">
                        {% if 'termination_b_site' in form.fields %}
                            {% render_field form.termination_b_site %}
                        {% endif %}
                        {% if 'termination_b_rack' in form.fields %}
                            {% render_field form.termination_b_rack %}
                        {% endif %}
                        {% if 'termination_b_device' in form.fields %}
                            {% render_field form.termination_b_device %}
                        {% endif %}
                        {% if 'termination_b_type' in form.fields %}
                            {% render_field form.termination_b_type %}
                        {% endif %}
                        <div class="form-group">
                            <label class="col-md-3 control-label required">Type</label>
                            <div class="col-md-9">
                                <p class="form-control-static">{{ termination_b_type_name }}</p>
                            </div>
                        </div>
                        {% render_field form.termination_b_id %}
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="panel panel-default">
                    <div class="panel-heading"><strong>Media</strong></div>
                    <div class="panel-body">
                        {% render_field form.media_type %}
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-12 text-center">
                <button type="submit" name="_update" class="btn btn-primary">Calculate Paths</button>
                <a href="{{ return_url }}" class="btn btn-default">Cancel</a>
            </div>
        </div>
    </form>
{% endblock %}

{% block javascript %}
    <script src="{% static 'js/livesearch.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}
