<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>LHSS DIGITAL - Cadastro</title>
</head>
<body>
<h1>LHSS DIGITAL - Cadastro</h1>
<p><a href="form-add.php">Adicionar Usuário</a></p>
<h2>Lista de Usuários</h2>
<p>Total de usuários: <?php echo $total ?></p>
<?php if ($total > 0): ?>
<table width="50%" border="1">
<thead>
<tr>
<th>Nome</th>
<th>Email</th>
<th>Gênero</th>
<th>Data de Nascimento</th>
<th>Idade</th>
<th>Ações</th>
</tr>
</thead>
<tbody>
<?php while ($user = $stmt->fetch(PDO::FETCH_ASSOC)): ?>
<tr>
<td><?php echo $user['name'] ?></td>
<td><?php echo $user['email'] ?></td>
<td><?php echo ($user['gender'] == 'm') ? 'Masculino' : 'Feminino' ?></td>
<td><?php echo dateConvert($user['birthdate']) ?></td>
<td><?php echo calculateAge($user['birthdate']) ?> anos</td>
<td>
<a href="form-edit.php?id=<?php echo $user['id'] ?>">Editar</a>
<a href="delete.php?id=<?php echo $user['id'] ?>" onclick="return confirm('Tem certeza de que deseja remover?');">Remover</a>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php else: ?>
<p>Nenhum usuário registrado</p>
<?php endif; ?>
</body>
</html>