{% extends "idhub/base_admin.html" %}
{% load i18n %}

{% block content %}
<h3>
  <i class="{{ icon }}"></i>
  {{ subtitle }}
</h3>
{% load django_bootstrap5 %}
<form role="form" method="post">
{% csrf_token %}
{% if form.errors %}
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert">
  <div class="icon"><span class="mdi mdi-close-circle-o"></span></div>
  <div class="message">
    <button class="close" type="button" data-dismiss="alert" aria-label="Close">
    <span class="mdi mdi-close" aria-hidden="true"></span>
    </button>
    {% for field, error in form.errors.items %}
      {{ error }}
    {% endfor %}
  </div>
</div>
{% endif %}
{% bootstrap_form form %}
<div class="form-actions-no-box">
  <a class="btn btn-grey" href="{% url 'idhub:admin_people' object.id %}">{% translate "Cancel" %}</a>
  <input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
</div>

</form>

<hr />

<div class="row mt-5">
  <div class="col">
    <div class="table-responsive">
      <table class="table table-striped table-sm">
        <thead>
          <tr>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Membership' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'From' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'To' %}</button></th>
            <th scope="col"></th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
          {% for membership in object.memberships.all %}
          <tr>
            <td>{{ membership.get_type }}</td>
            <td>{{ membership.start_date|default:'' }}</td>
            <td>{{ membership.end_date|default:'' }}</td>
            <td><a href="{% url 'idhub:admin_people_membership_edit' membership.id %}" title="{% trans 'Edit' %}"><i class="bi bi-pencil-square"></i></a></td>
            <td><a href="{% url 'idhub:admin_people_membership_del' membership.id %}" title="{% trans 'Delete' %}"><i class="bi bi-trash"></i></a></td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      <div class="form-actions-no-box">
        <a class="btn btn-green-admin" href="{% url 'idhub:admin_people_membership_new' object.id %}">{% translate "Add membership" %} <i class="bi bi-plus"></i></a>
      </div>
    </div>
  </div>
</div>

<div class="row mt-5 mb-3">
  <div class="col">
    <div class="table-responsive">
      <table class="table table-striped table-sm">
        <thead>
          <tr>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Rol' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Description' %}</button></th>
            <th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Service' %}</button></th>
            <th scope="col"></th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
          {% for rol in object.roles.all %}
          <tr>
            <td>{{ rol.service.rol.name }}</td>
            <td>{{ rol.service.description }}</td>
            <td>{{ rol.service.domain }}</td>
            <td><a href="{% url 'idhub:admin_people_rol_edit' rol.id %}" title="{% trans 'Edit' %}"><i class="bi bi-pencil-square"></i></a></td>
            <td><a href="{% url 'idhub:admin_people_rol_del' rol.id %}" title="{% trans 'Delete' %}"><i class="bi bi-trash"></i></a></td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      <div class="form-actions-no-box">
        <a class="btn btn-green-admin" href="{% url 'idhub:admin_people_rol_new' object.id %}">{% translate "Add Rol" %} <i class="bi bi-plus"></i></a>
      </div>
    </div>
  </div>
</div>
{% endblock %}
