BossBey File Manager
PHP:
8.4.18
OS:
Linux
User:
kids
Root
/
home
/
kids
/
public_html
/
app
đ€ Upload
đ New File
đ New Folder
Close
Editing: admin.php
<?php session_start(); //var_dump($_SESSION); require_once "connection.php"; // Define os estilos padrĂŁo como ocultos include_once "menu/nav.php"; if ($_SESSION['nivelAcesso'] !== "admin") { // Make sure to use single quotes around the session key echo "<script> alert('VocĂȘ nĂŁo tem acesso a esta pĂĄgina'); window.location.href = 'inicial.php'; </script>"; exit; } ?> <!-- ConteĂșdo para o nĂvel de acesso de Administrador --> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="mt-5 mb-3 clearfix"> <h2 class="pull-left">USUĂRIOS CADASTRADOS</h2> <a href="create.php" class="btn btn-success pull-right"><i class="fa fa-plus"></i> CRIAR USUĂRIO</a> </div> <div class="table-responsive"> <?php // Attempt select query execution $sql = "SELECT *, 'aluno' AS origem FROM aluno UNION ALL SELECT *, 'professor' AS origem FROM professor UNION ALL SELECT *, 'responsavel' AS origem FROM responsavel UNION ALL SELECT *, 'usuario' AS origem FROM usuario WHERE ativo = '1' ORDER BY nivelAcesso ASC"; if ($result = $pdo->query($sql)) { if ($result->rowCount() > 0) { echo '<table class="table table-hover table-bordered table-striped w-100">'; echo "<thead>"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>NOME</th>"; echo "<th>LOGIN</th>"; echo "<th>TIPO</th>"; echo "<th>DADOS</th>"; echo "<th>LOGS</th>"; echo "<th>AĂĂES</th>"; echo "<th>ANIVERSĂRIO / DIAS</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; while ($row = $result->fetch()) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['nome'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['nivelAcesso'] . "</td>"; echo '<td>'; if (!is_null($row['obs']) || !empty(trim($row['obs']))) { echo '<button type="button" name="confirmar" class="btn btn-secondary obs-button" data-toggle="modal" data-target="#obsModal' . $row['id'] . '">OBS</button>'; } echo '</td>'; echo '<td>'; if (!is_null($row['obs']) || !empty(trim($row['obs']))) { echo '<button type="button" name="logs" class="btn btn-info obs-button" data-toggle="modal" data-target="#logModal' . $row['id'] . '">LOGS</button>'; } echo '</td>'; echo "<td>"; // Ăcone de Editar echo '<a href="update.php?id=' . $row['id'] . '&origem=' . $row['origem'] . '" class="btn btn-primary" >EDITAR</a>'; // FormulĂĄrio de inativar if ($row['ativo'] == '1') { echo '<form action="inativar.php" method="post" class="d-inline">'; echo '<input type="hidden" name="voltar" value="inicial.php">'; echo '<input type="hidden" name="origem" value="' . $row['origem'] . '">'; echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; echo '<input type="hidden" name="tipo" value="usuario">'; echo '<button type="submit" class="btn btn-danger">INATIVAR</button>'; echo '</form>'; } else { echo '<form action="ativar.php" method="post" class="d-inline">'; echo '<input type="hidden" name="voltar" value="inicial.php">'; echo '<input type="hidden" name="origem" value="' . $row['origem'] . '">'; echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; echo '<input type="hidden" name="tipo" value="usuario">'; echo '<button type="submit" class="btn btn-success">ATIVAR</button>'; echo '</form>'; } echo "</td>"; echo "<td>"; if (isset($row['nascimento']) && !empty($row['nascimento'])) { echo $row['nascimento'] . ' - '; // Supondo que $row['nascimento'] contenha a data de nascimento no formato 'd/m/Y' $aniversario = DateTime::createFromFormat('d/m/Y', $row['nascimento']); $dataAtual = new DateTime(); if ($aniversario === false) { echo 'Data de nascimento invĂĄlida'; } else { $aniversario->setTime(0, 0, 0); if ($aniversario->format('d/m') === $dataAtual->format('d/m')) { echo '<div class="alert alert-primary" role="alert">FELIZ ANIVERSĂRIO</div>'; } else { $aniversario->setDate($dataAtual->format('Y'), $aniversario->format('m'), $aniversario->format('d')); if ($aniversario < $dataAtual) { $aniversario->modify('+1 year'); } $interval = $aniversario->diff($dataAtual); $diasFaltando = $interval->days; if ($diasFaltando == 0) { echo '<div class="alert alert-primary" role="alert">FELIZ ANIVERSĂRIO</div>'; } else { echo "<p>Faltam $diasFaltando dias para o prĂłximo aniversĂĄrio.</p>"; } } } } else { echo 'Data de nascimento nĂŁo especificada.'; } echo "</td>"; echo "</tr>"; // Add the modal for each row with OBS content if (!is_null($row['obs'])) { echo '<div class="modal fade" id="obsModal' . $row['id'] . '" tabindex="-1" role="dialog" aria-labelledby="obsModalLabel' . $row['id'] . '" aria-hidden="true">'; echo '<div class="modal-dialog modal-lg" role="document">'; echo '<div class="modal-content">'; echo '<div class="modal-header">'; echo '<h5 class="modal-title" id="obsModalLabel' . $row['id'] . '">Dados do UsuĂĄrio:</h5>'; echo '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'; echo '<span aria-hidden="true">×</span>'; echo '</button>'; echo '</div>'; echo '<div class="modal-body">'; echo '<p>email: ' . $row['email'] . '</p>'; echo '<p>Telefone: ' . $row['telefone'] . '</p>'; echo '<p>ObservaçÔes: ' . $row['obs'] . '</p>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; } if (!is_null($row['obs'])) { $sql2 = "SELECT * FROM `kids_app`.`logs` WHERE origem = :origem AND id_origem = :id"; $stmt2 = $pdo->prepare($sql2); $stmt2->bindParam(':origem', $row['origem'], PDO::PARAM_STR); $stmt2->bindParam(':id', $row['id'], PDO::PARAM_INT); $stmt2->execute(); echo '<div class="modal fade" id="logModal' . $row['id'] . '" tabindex="-1" role="dialog" aria-labelledby="logModalLabel' . $row['id'] . '" aria-hidden="true">'; echo '<div class="modal-dialog modal-lg" role="document">'; echo '<div class="modal-content">'; echo '<div class="modal-header">'; echo '<h5 class="modal-title" id="logModalLabel' . $row['id'] . '">Logs do usuĂĄrio:</h5>'; echo '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'; echo '<span aria-hidden="true">×</span>'; echo '</button>'; echo '</div>'; echo '<div class="modal-body">'; if ($stmt2->rowCount() > 0) { while ($row2 = $stmt2->fetch()) { echo '<p>' . $row2['acao'] . '</p>'; } } echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; } } echo "</tbody>"; echo "</table>"; // Free result set unset($result); } else { echo '<div class="alert alert-danger"><em>NĂO HĂ REGISTROS</em></div>'; } } else { echo "Ops! Algo deu errado. Por favor, TIRE UM PRINT E MANDE PARA O WEBDESIGNER."; } // Close connection unset($pdo); ?> </div> </div> </div> </div> <?php include_once "footer.php"; ?>
Save
Cancel