{% extends "balafon/_bs_section.html" %}
{% load i18n thumbnail favorite_tags %}

{% block section_header_extra_class %}main-section-header{% endblock %}

{% block section_title %}
<a class="header-link" href="{% url 'crm_view_entity' entity.id %}">
  <div class="logo" style="display: inline-block; vertical-align: middle;">
    <i class="fas fa-chess-rook"></i>
    <div class="logo-container">
      <img {{ entity.get_logo_center_style }} src="{{ entity.get_safe_logo }}"/>
    </div>
  </div>
  <div style="display: inline-block; vertical-align: middle;">
    {{ entity.name }}
  </div>
</a>
<div class="section-subtitle">{{entity.description}}</div>
{% endblock %}


{% block section_data %}
<div class="row">
  <div class="col-lg-4">
    <table class="table">
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Address' %}" class="fas fa-envelope"></i>
        {{ entity.get_address_fields|join:'<br /><i class="fas fa-envelope" style="color:transparent"></i> ' }}
      </td></tr>
      {% if entity.has_billing_address %}
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Billing address' %}" class="fas fa-euro-sign"></i>
        {{ entity.get_billing_address_fields|join:'<br /><i class="fas fa-envelope" style="color:transparent"></i> ' }}
      </td></tr>
      {% endif %}
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Email' %}" class="fas fa-paper-plane"></i>
        <a href="mailto:{{ entity.email }}">{{ entity.email }}</a>
      </td></tr>
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Phone' %}" class="fas fa-phone-alt"></i>
        {{ entity.phone }}
      </td></tr>
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Web Site' %}" class="fas fa-link"></i>
        {% if entity.website %}<a href="{{ entity.website }}" target="_blank">{{ entity.website }}</a>{% endif %}
      </td></tr>
      <tr><td>
        <i data-toggle="tooltip" data-placement="bottom" title="{% trans 'Fax' %}" class="fas fa-print"></i>
        {{ entity.fax }}
      </td></tr>
    </table>
  </div>

  <div class="col-lg-6">

    <div class="note" style="margin-bottom: 5px;">
      <span class="contenteditable" contenteditable="true" rel="{% url 'auto_save_data' 'entity' 'notes' entity.id %}">
        {{ entity.notes|linebreaksbr|default:"&nbsp;" }}
      </span>
    </div>

    {% include "Crm/_entity_groups.html" %}

    {% with entity.get_custom_fields as custom_fields %}
    {% if custom_fields %}
        {% include "Crm/_custom_fields.html" with instance=entity  model="entity" %}
    {% endif %}
    {% endwith %}
  </div>

  <div class="col-lg-2">
    <table class="table micro-table table-striped">
      {% if entity.relationship_date %}
        <tr><td><b>{% trans "Relationship" %}</b> {{ entity.relationship_date|date:"d/m/Y" }}</td></tr>
      {% endif %}
      <tr><td><b>{% trans "ADD_DT" %}</b> {{ entity.created|date:"d/m/Y" }}</td></tr>
      <tr><td><b>{% trans "UPD_DT" %}</b>
          {{ entity.modified|date:"d/m/Y" }}
          {% if entity.last_modified_by %} {% trans "by" %} {{ entity.last_modified_by }} {% endif %}
      </td></tr>
      {% if entity.type %}
      <tr><td><b>{% trans "Type" %}</b> {{entity.type}}</td></tr>
      {% endif %}
    </table>
  </div>
</div>
{% endblock %}


{% block section_menu_name %}<i class="fas fa-cog"></i> {% trans "Update" %}{% endblock %}

{% block section_buttons %}
  <li><a class="colorbox-form dropdown-link" href="{% url 'crm_edit_entity' entity.id %}">{% trans "Edit" %}</a></li>
  <li><a class="colorbox-form dropdown-link" href="{% url 'crm_delete_entity' entity.id %}">{% trans "Delete" %}</a></li>
{% endblock %}

{% block section_favorite %}
  {% favorite_item object=entity %}
{% endblock %}
