
{% extends "base.html.twig" %}

{% block title %}Reset hasła - {{ setting('title') }}{% endblock %}

{% block content %}
<div class="modal fade" id="remove" tabindex="-1" role="dialog" aria-labelledby="titleModal">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="titleModal">Usuń logi</h5>
				<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Anuluj"></button>
			</div>
			{{ form_start(form) }}
				<div class="modal-body">
					<p class="text-danger mb-1">Na pewno chcesz usunąć?</p>
				</div>
				<div class="modal-footer">
					<input type="button" class="btn btn-secondary" data-bs-dismiss="modal" value="Anuluj">
					{{ form_widget(form.submit) }}
				</div>
			{{ form_end(form) }}
		</div>
	</div>
</div>

<div class="page-header">
	<h1><i class="fas fa-hdd"></i> Reset hasła</h1>
</div>

{% include 'partial/alert.html.twig' %}

{% if resetPasswords|length %}

	<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#remove">Usuń logi</button>

	<div class="table-responsive mt-5">
		<table class="table table-striped table-bordered table-sm">
			<tr>
				<th scope="col"></th>
				<th scope="col" class="text-center{% if resetPasswords.isSorted('u.username') %} table-active{% endif %}">
          {{ knp_pagination_sortable(resetPasswords, 'Login', 'u.username') }}
        </th>
				<th scope="col" class="text-center{% if resetPasswords.isSorted('rp.active') %} table-active{% endif %}">
          {{ knp_pagination_sortable(resetPasswords, 'Aktywny', 'rp.active') }}
        </th>
				<th scope="col" class="text-center{% if resetPasswords.isSorted('rp.used') %} table-active{% endif %}">
          {{ knp_pagination_sortable(resetPasswords, 'Użyty', 'rp.used') }}
        </th>
				<th scope="col" class="text-center{% if resetPasswords.isSorted('rp.ip') %} table-active{% endif %}">
          {{ knp_pagination_sortable(resetPasswords, 'IP', 'rp.ip') }}
        </th>
				<th scope="col" class="text-center{% if resetPasswords.isSorted('rp.date') %} table-active{% endif %}">
          {{ knp_pagination_sortable(resetPasswords, 'Data', 'rp.date') }}
        </th>
			</tr>
			{% for resetPassword in resetPasswords %}
				<tr>
					<td class="text-center">{{ resetPasswords.getPaginationData.firstItemNumber + loop.index - 1 }}</td>
					<td>
						{% if resetPassword.user.username %}
							{{ resetPassword.user.username }}<br>
						{% endif %}
						<a href="mailto:{{ resetPassword.user.email }}" title="{{ resetPassword.user.email }}">{{ resetPassword.user.email }}</a>
					</td>
					<td class="text-center">{% if resetPassword.active %}Tak{% endif %}</td>
					<td class="text-center">{% if resetPassword.used %}Tak{% endif %}</td>
					<td class="text-center">{{ resetPassword.ip }}</td>
					<td class="text-center text-nowrap">{{ resetPassword.date|date('Y-m-d H:i') }}</td>
				</tr>
			{% endfor %}
		</table>
	</div>

	<p>Pokazuje {{ resetPasswords|length }} z {{ resetPasswords.getTotalItemCount }} rekordów.</p>
	{{ knp_pagination_render(resetPasswords) }}

{% else %}
	<h5 class="text-danger">Nic nie znaleziono</h5>
{% endif %}

{% endblock %}
