projetphp/views/table.html.twig

82 lines
2.5 KiB
Twig
Executable File

<html>
<head>
{% include 'header.html.twig' %}
</head>
<body><span>
<input type="text" id="myInput" style="width:95%" onkeyup="myFunction()" placeholder="Search for login..">
<input type="hidden" id="slVal" value="{{ session["sl"] }}" />
<form method="post" action="" style="display:inline">
<input type="hidden" name="sessionDestroy" value=""/>
<button style="float: right;width: 5%;"><i class="fas fa-sign-out-alt fa-2x"></i></button>
</form></span>
<table id="allRecord">
<thead>
<tr>
<th>login</th>
<th>Date de nésance</th>
<th>email</th>
<th>PW</th>
<th>slvl</th>
{% if (session["sl"] == "5" or session["sl"] == "10") %}
<th><i class="fas fa-cogs"></i></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for data in datas %}
<tr class="record">
<td class="login">
{{ data["login"] }}
</td>
<td class="datene">
{{ data["date_naissance"] }}
</td>
<td class="email">
{{ data["e_mail"] }}
</td>
<td class="pw">
{{ data["mot_de_passe"] }}
</td>
<td class="sl">
{{ data["security_level"] }}
</td>{% if (session["sl"] == "5" or session["sl"] == "10") %}
<td>{% if ((session["sl"] == "5" and session["login"] == data["login"]) or session["sl"] == "10") %}
<i class="fas fa-edit click editUser"></i><i class="fas fa-trash-alt click delUser"></i>
{% endif %}
</td>{% endif %}
</tr>
{% endfor %}
{% if (session["sl"] == "10") %}
<tr rowspan="2">
<td colspan="6" style="text-align:center"><i class="fas fa-user-plus fa-4x click"></i></td>
</tr>{% endif %}
</tbody>
</table>
</body>
<script>
//https://www.w3schools.com/howto/howto_js_filter_table.asp
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("allRecord");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</html>