{% load helpers %}

{% with contacts=object.contact.all %}
{% if contacts.exists %}
<div class="card">
    <h5 class="card-header">
        Contact
        <div class="card-actions">
            <a href="{% url 'plugins:netbox_svm:softwareproductinstallation_add_contact' pk=object.pk %}" class="btn btn-ghost-primary btn-sm">
            <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add a Contact
            </a>
        </div>
    </h5>
    <div class="card-body">
        <table class="table table-hover">
        <tr>
            <th>Name</th>
            <th>Title</th>
            <th>Phone</th>
            <th>Email</th>
        </tr>
        {% for contact in contacts %}
            <tr>
            <td><a href="{{ contact.get_absolute_url }}">{{ contact.name }} </a></td>
            <td>{{ contact.title|placeholder }}</td>
            <td>
                {% if contact.phone %}
                <a href="tel:{{ contact.contact.phone }}">{{ contact.phone }}</a>
                {% else %}
                {{ ''|placeholder }}
                {% endif %}
            </td>
            <td>
                {% if contact.email %}
                <a href="mailto:{{ contact.contact.email }}">{{ contact.email }}</a>
                {% else %}
                {{ ''|placeholder }}
                {% endif %}
            </td>
            </tr>
        {% endfor %}
        </table>
    </div>
</div>
{% endif %}
{% endwith %}