{% extends "app_home/base.html" %}
{% load static %}
{% load i18n %}

{% block navbar_app %}
{% include 'app_home/_sidebar.html' %}
{% endblock %}

{% block title %}
{% if user.login %}
<H2><i class="fa fa-lg fa-user"></i>&nbsp; {{ user.login }} </H2>
{% else %}  
<H2><i class="fa fa-lg fa-user"></i>&nbsp; {% translate "New User" %}</H2>
{% endif %} 

<hr>
{% endblock %}


{% block content %}

<form method="post">{% csrf_token %}

<a class="btn btn-outline-dark" onclick="history.back()" role="button">
<i class="fa fa-backward" aria-hidden="true"></i>&nbsp; {% translate 'Back' %} </a>

{% if 'p_user_update' in aaa.perms %}
<input class="btn btn-success" type="submit" value="{% translate 'Save' %}" name="save">
{% endif %}


<hr>



<table class="table ">

{% if user.login %}
  <tr> <th><label>{% translate "User ID" %}</label></th><td>{{ user.id }}</td>  </tr>
  <tr> <th><label>{% translate "Last Login" %}</label></th><td>{{ user.last_login|date:'Y-m-d H:i:s'  }}</td>  </tr>
{% endif %}

{{ form.as_table }}

</table>
</form>


{% if user.login %}
<!-- DELETE CONFIRM Modal -->
<div class="modal fade" id="DeleteModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">

<div class="modal-header">
<h1 class="modal-title fs-5" id="staticBackdropLabel">{% translate "Confirm delete ?" %}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
    
<div class="modal-body">
<p>Login: {{ form.login.value|default:'n/a' }}</p>
</div>

<div class="modal-footer">
<form action="{% url 'app_user:user_delete' user.id %}" method="post">{% csrf_token %}
<button role="button" class="btn btn-danger">{% translate "Delete" %}</button>
<a role="button" class="btn btn-outline-dark" data-bs-dismiss="modal">{% translate "Cancel" %}</a>
</form>
</div>

</div>
</div>
</div>
{% endif %}


{% endblock %}



{% block script %}

<script>
$(document).ready(function() {
    $('#id_groups').select2({
      width: '100%'
  });
});
</script>


{% endblock %}


