{% extends 'base.html' %}
{% load static %}
{% load i18n %}

{% block custom_head_css_js %}
    <link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
{% endblock %}
{% block content %}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="panel-options">
                        <ul class="nav nav-tabs">
                            <li class="active">
                                <a href="{% url 'assets:idc-detail' pk=idc.id %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Detail' %} </a>
                            </li>
                            <li>
                                <a href="{% url 'assets:idc-assets' pk=idc.id %}" class="text-center">
                                <i class="fa fa-bar-chart-o"></i> {% trans 'IDC assets' %}
                                </a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-default" href="{% url 'assets:idc-update' pk=idc.id %}"><i class="fa fa-edit"></i>Update</a>
                            </li>
                            <li class="pull-right">
                                <a class="btn btn-outline btn-danger btn-delete-idc">
                                    <i class="fa fa-edit"></i>Delete
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div class="col-sm-9" style="padding-left: 0;">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <span class="label"><b>{{ idc.name }}</b></span>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                            <i class="fa fa-wrench"></i>
                                        </a>
                                        <ul class="dropdown-menu dropdown-user">
                                        </ul>
                                        <a class="close-link">
                                            <i class="fa fa-times"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="ibox-content">
                                    <table class="table idc-details">
                                        <tbody>
                                        <tr class="no-borders-tr" data-name="{{ idc.name }}">
                                            <td>{% trans 'Name' %}:</td>
                                            <td><b>{{ idc.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Bandwidth' %}:</td>
                                            <td><b>{{ idc.bandwidth }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Contact' %}:</td>
                                            <td><b>{{ idc.contact }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Phone' %}:</td>
                                            <td><b>{{ idc.phone }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Address' %}:</td>
                                            <td><b>{{ idc.address }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Intranet' %}:</td>
                                            <td><b>{{ idc.Intranet }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Extranet' %}:</td>
                                            <td><b>{{ idc.extranet }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Operator' %}:</td>
                                            <td><b>{{ idc.operator }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Date created' %}:</td>
                                            <td><b>{{ system_user.date_created }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Created by' %}:</td>
                                            <td><b>{{ asset_group.created_by  }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>{% trans 'Comment' %}:</td>
                                            <td><b>{{ system_user.comment }}</b></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

{% endblock %}
{% block custom_foot_js %}
<script>
function idcDelete(name, url) {
    function doDelete() {
        var body = {};
        var success = function() {
            swal('Deleted!', "[ "+name+"]"+" has been deleted ", "success");
	        window.location.href="{% url 'assets:idc-list' %}";
        };
        var fail = function() {
            swal("Failed", "Delete"+"[ "+name+" ]"+"failed", "error");
        };
        APIUpdateAttr({
            url: url,
            body: JSON.stringify(body),
            method: 'DELETE',
            success: success,
            error: fail
        });
    }
    swal({
        title: 'Are you sure delete ?',
        text: " [" + name + "] ",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: 'Cancel',
        confirmButtonColor: "#DD6B55",
        confirmButtonText: 'Confirm',
        closeOnConfirm: false
    }, function () {
        doDelete()
    });
}

$(document).ready(function () {
	$('.select2').select2();
})
.on('click', '.btn-delete-idc', function () {
	var name = $('.idc-details > tbody > tr').attr("data-name");
	var id = {{ idc.id }};
	var the_url = '{% url "api-assets:idc-detail" pk=99991937 %}'.replace(99991937, id);
	idcDelete(name, the_url);
});
</script>
{% endblock %}
