BossBey File Manager
PHP:
8.4.18
OS:
Linux
User:
kids
Root
/
home
/
kids
/
public_html
/
app
📤 Upload
📝 New File
📁 New Folder
Close
Editing: rela.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; } ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> </head> <body> <div class="container mt-5"> <?php $currentYear = date("Y"); $currentMonth = date("n"); // n: mês sem zero à esquerda if (isset($_GET['year']) && is_numeric($_GET['year'])) { $currentYear = $_GET['year']; } if (isset($_GET['month'])) { $currentMonth = max(1, min(12, $_GET['month'])); // Garantir que o mês esteja entre 1 e 12 } $months = array( 1 => 'Janeiro', 2 => 'Fevereiro', 3 => 'Março', 4 => 'Abril', 5 => 'Maio', 6 => 'Junho', 7 => 'Julho', 8 => 'Agosto', 9 => 'Setembro', 10 => 'Outubro', 11 => 'Novembro', 12 => 'Dezembro' ); $firstDay = "$currentYear-$currentMonth-01"; $lastDay = date("Y-m-t", strtotime($firstDay)); ?> <h2>Controle de aulas (Administração) <?php echo $months[$currentMonth] . " de $currentYear"; ?></h2> <div class="d-flex justify-content-between align-items-center mb-3"> <a href="?year=<?php echo $currentYear - 1; ?>&month=<?php echo $currentMonth; ?>" class="btn btn-danger">< Ano Anterior</a> <a href="?year=<?php echo $currentYear; ?>&month=<?php echo ($currentMonth === 1 ? 12 : $currentMonth - 1); ?>" class="btn btn-primary">< Mês Anterior</a> <span><?php echo $currentYear; ?></span> <a href="?year=<?php echo $currentYear; ?>&month=<?php echo ($currentMonth === 12 ? 1 : $currentMonth + 1); ?>" class="btn btn-primary">Próximo Mês ></a> <a href="?year=<?php echo $currentYear + 1; ?>&month=<?php echo $currentMonth; ?>" class="btn btn-danger">Próximo Ano ></a> </div> <?php echo '<div class="container-fluid">'; // Executar a consulta SQL para obter os resultados $sql = "SELECT professor.nome AS Professor, aluno.nome AS Aluno, COUNT(*) AS Aulas_Marcadas, SUM( CASE WHEN `events`.realizada = 1 THEN 1 ELSE 0 END ) AS Confirmadas, SUM( CASE WHEN `events`.realizada = 0 THEN 1 ELSE 0 END ) AS Nao_Executadas FROM acessoFicha INNER JOIN professor ON acessoFicha.id_professor = professor.id INNER JOIN `events` ON `events`.id_acessoFicha = acessoFicha.id_acesso_aluno INNER JOIN aluno ON acessoFicha.id_aluno = aluno.id WHERE start >= '$firstDay' AND end <= DATE_ADD('" . $lastDay . "', INTERVAL 1 DAY) GROUP BY professor.nome, aluno.nome"; $result = $pdo->query($sql); // Verificar se há resultados if ($result->rowCount() > 0) { echo ' <h2>Tabela de Aulas</h2> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th>Professor</th> <th>Aluno</th> <th>Aulas Marcadas</th> <th>Confirmadas</th> <th>Não Executadas</th> </tr> </thead> <tbody> '; // Loop para exibir os resultados while ($row = $result->fetch()) { echo ' <tr> <td>' . $row["Professor"] . '</td> <td>' . $row["Aluno"] . '</td> <td>' . $row["Aulas_Marcadas"] . '</td> <td>' . $row["Confirmadas"] . '</td> <td>' . $row["Nao_Executadas"] . '</td> </tr> '; } echo ' </tbody> </table> </div> '; } else { echo '<p>Nenhum resultado encontrado.</p>'; } ?> <!-- Seu código JavaScript e fechamento do HTML aqui --> </div> </div> </body> <?php include_once "menu/footer.php"; ?> </html>
Save
Cancel