séparation de la page group view en templates twig

php
Anthony RICHARD 1 year ago
parent 84d23f0478
commit 3d91d8f03d

@ -0,0 +1,38 @@
<table>
{% if groups is defined %}
{% for row in groups %}
{% if selectedGroup is defined and selectedGroup == row.id %}
<tr style="background-color:red;">
{% else %}
<tr>
{% endif %}
<td>ID</td>
<td>Num</td>
<td>Year</td>
<td>Sector</td>
</tr>
<tr>
<td>{{row.id}}</td>
<td>{{row.num}}</td>
<td>{{row.year}}</td>
<td>{{row.sector}}</td>
{% if actions is defined %}
{% if 'showGroupDetails' in actions %}
<td><a href="index.php?action=showGroupDetails&selectedGroup={{row.id}}">
<input class="btn-black" type="button" value="Show"/>
</a></td>
{% endif %}
{% if 'removeGroup' in actions %}
<td><a href="index.php?action=removeGroup&selectedGroup={{row.id}}">
<input class="btn-black" type="button" value="Remove"/>
</a></td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
{% endif %}
</table>

@ -1,125 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Groups</title>
</head>
<body>
<style>
body{
display: flex;
flex-wrap: wrap;
}
section{
border: 1px solid black;
width: 33%;
}
</style>
<section class="groupList">
<h2>Group list</h2>
<table>
{% if groups is defined %}
{% for row in groups %}
{% if selectedGroup is defined and selectedGroup == row.id %}
<tr style="background-color:red;">
{% else %}
<tr>
{% endif %}
<td>ID</td>
<td>Num</td>
<td>Year</td>
<td>Sector</td>
</tr>
<tr>
<td>{{row.id}}</td>
<td>{{row.num}}</td>
<td>{{row.year}}</td>
<td>{{row.sector}}</td>
<td><a href="index.php?action=showGroupDetails&selectedGroup={{row.id}}">
<input class="btn-black" type="button" value="Show"/>
</a></td>
<td><a href="index.php?action=removeGroup&selectedGroup={{row.id}}">
<input class="btn-black" type="button" value="Remove"/>
</a></td>
</tr>
{% endfor %}
{% endif %}
</table>
</section>
<section class="users">
<h2>User list</h2>
<table>
<tr>
<td>ID</td>
<td>Nickname</td>
<td>Name</td>
<td>Surname</td>
<td>Mail</td>
<td>Group</td>
<td>Role</td>
<td>Extra Time</td>
</tr>
{% if selectedGroup is defined and users is defined %}
{% for row in users %}
<tr>
<td>{{row.id}}</td>
<td>{{row.nickname}}</td>
<td>{{row.name}}</td>
<td>{{row.surname}}</td>
<td>{{row.email}}</td>
<td>{{row.group}}</td>
<td>{{row.role}}</td>
<td>{{row.extraTime}}</td>
<td><a href="index.php?action=removeUserFromGroup&id={{row.id}}&selectedGroup={{selectedGroup}}">
<input class="btn-black" type="button" value="Delete from group"/>
</a></td>
</tr>
{% endfor %}
{% endif %}
</table>
</section>
<section class="addGroupForm">
<h2>Add group</h2>
<form action="index.php" method="GET">
<input type="hidden" name="action" value="addGroup">
<input name="num" type="text" placeholder="number" required>
<input name="year" type="text" placeholder="year" required>
<input name="sector" type="text" placeholder="sector" required>
<input type="submit" value="Add">
</form>
</section>
<section class="unassignedUsers">
<h1>Unassigned users</h1>
<table>
<tr>
<td>ID</td>
<td>Nickname</td>
<td>Name</td>
<td>Surname</td>
<td>Mail</td>
<td>Group</td>
<td>Role</td>
<td>Extra Time</td>
</tr>
{% if unassignedUsers is defined %}
{% for row in unassignedUsers %}
<tr>
<td>{{row.id}}</td>
<td>{{row.nickname}}</td>
<td>{{row.name}}</td>
<td>{{row.surname}}</td>
<td>{{row.email}}</td>
<td>{{row.group}}</td>
<td>{{row.role}}</td>
<td>{{row.extraTime}}</td>
<td><a href="index.php?action=addUserToGroup&userID={{row.id}}&groupID={{selectedGroup}}">
<input class="btn-black" type="button" value="Add to group"/>
</a></td>
</tr>
{% endfor %}
{% endif %}
</table>
</section>
</body>
</html>

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Groups</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Font Awesome icons (free version)-->
<script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script>
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet" />
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
</head>
<style>
section {
border: 2px solid black;
margin: 10px 0;
}
</style>
<body>
<section class="groupList">
<h2>Group list</h2>
{% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %}
</section>
<section class="users">
<h2>Users of the group</h2>
{% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %}
</section>
<section class="addGroupForm">
<h2>Add group</h2>
<form action="index.php" method="GET">
<input type="hidden" name="action" value="addGroup">
<input name="num" type="text" placeholder="number" required>
<input name="year" type="text" placeholder="year" required>
<input name="sector" type="text" placeholder="sector" required>
<input type="submit" value="Add">
</form>
</section>
<section class="unassignedUsers">
<h1>Unassigned users</h1>
{% include 'userContainer.twig' with {'users' : unassignedUsers, 'action' : 'addUserToGroup'} %}
</section>
</body>
</html>

@ -0,0 +1,42 @@
<table>
<tr>
<td>ID</td>
<td>Nickname</td>
<td>Name</td>
<td>Surname</td>
<td>Mail</td>
<td>Group</td>
<td>Role</td>
<td>Extra Time</td>
</tr>
{% if users is defined %}
{% for row in users %}
<tr>
<td>{{row.id}}</td>
<td>{{row.nickname}}</td>
<td>{{row.name}}</td>
<td>{{row.surname}}</td>
<td>{{row.email}}</td>
<td>{{row.group}}</td>
<td>{{row.role}}</td>
<td>{{row.extraTime}}</td>
{% if action is defined %}
{% if action == 'removeUserFromGroup' %}
<td><a href="index.php?action=removeUserFromGroup&id={{row.id}}&selectedGroup={{selectedGroup}}">
<input class="btn-black" type="button" value="Delete from group"/>
</a></td>
{% elseif action == 'addUserToGroup' %}
<td><a href="index.php?action=addUserToGroup&userID={{row.id}}&groupID={{selectedGroup}}">
<input class="btn-black" type="button" value="Add to group"/>
</a></td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
{% endif %}
</table>
Loading…
Cancel
Save