BossBey File Manager
PHP:
8.4.18
OS:
Linux
User:
kids
Root
/
home
/
kids
/
public_html
/
app
📤 Upload
📝 New File
📁 New Folder
Close
Editing: aulasprof.php
<!DOCTYPE html> <html> <head> <title>Relação de Aulas</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> </head> <body> <?php include_once "menu/nav.php"; ?> <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 H:i:s", strtotime($firstDay)); $sql = "SELECT `events`.*, `events`.observacao AS aula_observacao, professor.id AS id_professor, aluno.nome AS aluno, responsavel.nome AS responsavel, responsavel.telefone, aluno.obs AS aluno_observacao, aluno.id AS id_aluno, professor.nome AS professor, `local`.nome AS nome_local, professor.telefone AS telefone_professor FROM professor INNER JOIN acessoFicha ON professor.id = acessoFicha.id_professor INNER JOIN responsavel ON acessoFicha.id_responsavel = responsavel.id INNER JOIN `events` ON acessoFicha.id_acesso_aluno = `events`.id_acessoFicha INNER JOIN aluno ON acessoFicha.id_aluno = aluno.id INNER JOIN `local` ON `events`.id_local = `local`.id WHERE title = 'Aula' AND id_professor = $_SESSION[id] AND start >= '$firstDay' AND end <= DATE_ADD('" . $lastDay . "', INTERVAL 1 DAY) ORDER BY end ASC"; $result = $pdo->query($sql); ?> <h2>Relação de Aulas marcadas de <?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-primary">< 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 + 1; ?>&month=<?php echo $currentMonth; ?>" class="btn btn-primary">Próximo Ano ></a> <a href="?year=<?php echo $currentYear; ?>&month=<?php echo ($currentMonth === 12 ? 1 : $currentMonth + 1); ?>" class="btn btn-primary">Próximo Mês ></a> <button type="button" class="btn btn-success" data-toggle="modal" data-target="#criarModal">Criar Aula</button> </div> <table class="table"> <thead> <tr> <th>Aluno</th> <th>Professor</th> <th>Data-Hora</th> <th>Realizou</th> <th></th> <th>Ações</th> <th>Envio de arquivos</th> </tr> </thead> <tbody> <?php while ($row = $result->fetch()) { echo "<tr>"; echo "<td>" . $row['aluno'] . "</td>"; echo "<td>" . $row['professor'] . "</td>"; echo "<td>" . date("d/m/Y H:i:s", strtotime($row['start'])) . "</td>"; echo '<td>'; if ($row['realizada'] == 0) { echo '<button type="button" name="informar" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#justificativaModal' . $row['id'] . '">INFORMAR</button>'; } if ($row['realizada'] == 1) { echo '<button type="button" disabled class="btn btn-success btn-sm">SIM</button>'; } if ($row['realizada'] == 3) { echo '<button type="button" disabled class="btn btn-danger btn-sm">NÃO</button>'; } echo '</td>'; echo '<td>'; echo '<button type="button" name="confirmar" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#obsModal' . $row['id'] . '">DADOS</button>'; echo '</td>'; echo '<td>'; echo '<button type="button" name="editar" class="btn btn-warning btn-sm" data-toggle="modal" data-target="#editModal' . $row['id'] . '">Editar</button>'; echo '<form action="delete.php" method="post" style="display: inline;">'; echo '<input type="hidden" name="voltar" value="aulas.php">'; echo '<input type="hidden" name="origem" value="events">'; echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; echo '<input type="hidden" name="tipo" value="essa Aula">'; echo '<input type="submit" class="btn btn-danger btn-sm" value="Deletar"'; if ($row['realizada'] == 1) { echo 'disabled'; } echo '>'; echo '</form>'; echo '</td>'; echo '<td>'; echo '<form class="form-inline" action="upload_process.php" method="POST" enctype="multipart/form-data"> <div class="form-group mb-2"> <input type="file" class="form-control-file" id="file" name="file" accept=".pdf, .jpg, .png, .jpeg, .mp4, .m4u, .mov">'; echo '<input type="hidden" name="id_evento" value="' . $row['id'] . '">'; echo'</div> <button type="submit" class="btn btn-primary">Enviar</button> </form> </td>'; echo "</tr>"; // Modal de Justificativa echo '<div class="modal fade" id="justificativaModal' . $row['id'] . '" tabindex="-1" role="dialog" aria-labelledby="justificativaModalLabel' . $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="justificativaModalLabel' . $row['id'] . '">Informar dados da Aula:</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>Aluno: ' . htmlspecialchars($row['aluno']) . '</p>'; echo ' <p>Professor: ' . htmlspecialchars($row['professor']) . '</p>'; echo ' <p>Responsável: ' . htmlspecialchars($row['responsavel']) . '</p>'; echo ' <form action="confirmar_aula.php" method="post" style="display: inline;">'; echo ' <label for="realizada">Realizada</label>'; echo ' <select name="realizada" class="form-control" id="realizada' . htmlspecialchars($row['id']) . '" onchange="toggleJustificativa(' . htmlspecialchars($row['id']) . ')">'; echo ' <option value="1">Sim</option>'; echo ' <option value="3">Não</option>'; echo ' </select>'; echo ' <div id="justificativaDiv' . htmlspecialchars($row['id']) . '" style="display:none;">'; echo ' <label for="justificativa">Justificativa:</label>'; echo ' <textarea id="justificativa' . htmlspecialchars($row['id']) . '" name="justificativa" class="form-control"></textarea>'; echo ' <input type="hidden" id="id' . htmlspecialchars($row['id']) . '" name="id" value="' . htmlspecialchars($row['id']) . '">'; echo ' </div>'; echo ' <input type="submit" value="Enviar" class="btn btn-primary mt-3">'; echo ' </form>'; echo ' </div>'; echo ' </div>'; echo ' </div>'; echo '</div>'; // Modal para visualizar dados da aula 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 da Aula:</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>Aluno: ' . $row['aluno'] . '</p>'; echo '<p>Professor: ' . $row['professor'] . '</p>'; echo '<p>Telefone do Professor: ' . $row['telefone_professor'] . '</p>'; echo '<p>Responsável: ' . $row['responsavel'] . '</p>'; echo '<p>Telefone do Responsável: ' . $row['telefone'] . '</p>'; echo '<p>Objetivo da Aula: ' . $row['descricao'] . '</p>'; echo '<p>Início: ' . date("d/m/Y H:i:s", strtotime($row['start'])) . '</p>'; echo '<p>Término: ' . date("d/m/Y H:i:s", strtotime($row['end'])) . '</p>'; echo '<p>Estabelecimento: ' . $row['nome_local'] . '</p>'; echo '<p>Observações da Aula: ' . $row['aula_observacao'] . '</p>'; if ($row['realizada'] == 3) { echo '<h1>JUSTIFICATIVA:</h1>' . $row['justificativa']; } echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; // Modal para editar aula echo '<div class="modal fade" id="editModal' . $row['id'] . '" tabindex="-1" role="dialog" aria-labelledby="editModalLabel' . $row['id'] . '" aria-hidden="true">'; echo '<div class="modal-dialog" role="document">'; echo '<div class="modal-content">'; echo '<div class="modal-header">'; echo '<h5 class="modal-title" id="editModalLabel' . $row['id'] . '">Editar Aula</h5>'; echo '<button type="button" class="close" data-dismiss="modal" aria-label="Fechar">'; echo '<span aria-hidden="true">×</span>'; echo '</button>'; echo '</div>'; echo '<div class="modal-body">'; echo '<form action="editar_aula.php" method="post">'; echo '<input type="hidden" name="id" value="' . $row['id'] . '">'; echo '<input type="hidden" id="title" name="title" class="form-control" value="' . $row['title'] . '" required>'; echo '<label for="descricao">Objetivo da Aula:</label>'; echo '<input type="text" id="descricao" name="descricao" class="form-control" value="' . $row['descricao'] . '">'; echo '<label for="color">Cor:</label>'; echo '<input type="color" id="color" name="color" class="form-control" value="' . $row['color'] . '">'; echo '<label for="start">Início:</label>'; echo '<input type="datetime-local" id="start" name="start" class="form-control" value="' . date('Y-m-d\TH:i', strtotime($row['start'])) . '">'; echo '<label for="end">Fim:</label>'; echo '<input type="datetime-local" id="end" name="end" class="form-control" value="' . date('Y-m-d\TH:i', strtotime($row['end'])) . '">'; echo '<label for="observacao">Observações:</label>'; echo '<textarea id="observacao" name="observacao" class="form-control">' . $row['observacao'] . '</textarea>'; echo '<label for="id_local">Estabelecimento:</label>'; echo '<select name="id_local" class="form-control">'; $resultLocal = $pdo->query("SELECT `local`.nome as nome_local, `local`.id as id_local FROM `local`"); while ($rowLocal = $resultLocal->fetch(PDO::FETCH_ASSOC)) { $selected = ($row['id_local'] == $rowLocal['id_local']) ? 'selected' : ''; echo '<option value="' . $rowLocal['id_local'] . '" ' . $selected . '>' . $rowLocal['nome_local'] . '</option>'; } echo '</select>'; echo '<label for="realizada">Realizada</label>'; echo '<select name="realizada" class="form-control" id="realizadaEdit' . $row['id'] . '" onchange="toggleJustificativaEdit(' . $row['id'] . ')">'; echo '<option value="1"' . ($row['realizada'] == 1 ? ' selected' : '') . '>Sim</option>'; echo '<option value="3"' . ($row['realizada'] == 3 ? ' selected' : '') . '>Não</option>'; echo '</select>'; echo '<div id="justificativaDivEdit' . $row['id'] . '" style="display:' . ($row['realizada'] == 3 ? 'block' : 'none') . '">'; echo '<label for="justificativa">Justificativa:</label>'; echo '<textarea id="justificativaEdit' . $row['id'] . '" name="justificativa" class="form-control">' . $row['justificativa'] . '</textarea>'; echo '</div>'; echo '<button type="submit" class="btn btn-primary mt-3">Salvar Alterações</button>'; echo '</form>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; } ?> </tbody> </table> </div> <!-- Modal para criar nova aula (sem alterações) --> <div class="container mt-5"> <div class="modal fade" id="criarModal" tabindex="-1" role="dialog" aria-labelledby="criarModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="criarModalLabel">Criar Nova Aula</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Fechar"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form id="createEventForm" action="criar_aula.php" method="post"> <input type="hidden" id="title" name="title" class="form-control" value="Aula" required> <select name="id_acesso_aluno" class="form-control"> <?php $result = $pdo->query("SELECT aluno.nome AS aluno, professor.nome AS professor, responsavel.nome AS responsavel, acessoFicha.id_acesso_aluno FROM acessoFicha INNER JOIN aluno ON acessoFicha.id_aluno = aluno.id INNER JOIN professor ON acessoFicha.id_professor = professor.id INNER JOIN responsavel ON acessoFicha.id_responsavel = responsavel.id"); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $aluno = $row['aluno']; $professor = $row['professor']; $id_acesso_aluno = $row['id_acesso_aluno']; echo "<option value='$id_acesso_aluno'>Aluno: $aluno , Professor: $professor</option>"; } ?> </select> <label for="descricao">Objetivo da Aula:</label> <input type="text" id="descricao" name="descricao" class="form-control"> <label for="color">Cor:</label> <input type="color" id="color" name="color" class="form-control"> <label for="start">Selecione o horário do início da aula:</label> <select id="start" name="start" class="form-control"> <?php $horario_inicial = strtotime("06:00:00"); $horario_final = strtotime("23:00:00"); $intervalo = 600; // 10 minutos em segundos while ($horario_inicial <= $horario_final) { $horario_formatado = date("H:i:s", $horario_inicial); echo '<option value="' . $horario_formatado . '">' . $horario_formatado . '</option>'; $horario_inicial += $intervalo; } ?> </select> <div class="container mt-5"> <div class="form-row"> <div class="form-group col-md-6"> <label for="selectedMonth">Mês:</label> <select id="selectedMonth" name="selectedMonth" class="form-control"> <?php $meses = 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" ); foreach ($meses as $numero => $nome) { $selected = ($numero == date("n")) ? "selected" : ""; echo "<option value='$numero' $selected>$nome</option>"; } ?> </select> </div> <div class="form-group col-md-6"> <label for="selectedYear">Ano:</label> <select id="selectedYear" name="selectedYear" class="form-control"> <?php $currentYear = date("Y"); for ($year = $currentYear - 10; $year <= $currentYear + 10; $year++) { $selected = ($year == $currentYear) ? "selected" : ""; echo "<option value='$year' $selected>$year</option>"; } ?> </select> </div> </div> <div class="table-responsive"> <table class="table table-bordered"> <thead> <tr> <th>Dom</th> <th>Seg</th> <th>Ter</th> <th>Qua</th> <th>Qui</th> <th>Sex</th> <th>Sáb</th> </tr> </thead> <tbody id="calendarBody"> <!-- O conteúdo da tabela será preenchido usando JavaScript --> </tbody> </table> </div> </div> <label for="observacao">Observações: (Objetivo cumprido ou não, local, material usado, etc...)</label> <textarea id="observacao" name="observacao" class="form-control"></textarea> <label for="id_local">Estabelecimento:</label> <select name="id_local" class="form-control"> <?php $result = $pdo->query("SELECT `local`.nome as nome_local, `local`.id as id_local FROM `local`"); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $nome_local = $row['nome_local']; $id_local = $row['id_local']; echo "<option value='$id_local'>Local: $nome_local</option>"; } ?> </select> <button type="submit" class="btn btn-primary mt-3">Criar Aula</button> </form> </div> </div> </div> </div> </div> <?php include_once 'menu/footer.php';?> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> <script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/pt.js"></script> <script> document.addEventListener('DOMContentLoaded', function() { flatpickr("#dataHora", { enableTime: true, dateFormat: "d/m/Y H:i:ss", time_24hr: true, locale: "pt" }); }); </script> <script> function toggleJustificativa(id) { var realizadaSelect = document.getElementById('realizada' + id); var justificativaDiv = document.getElementById('justificativaDiv' + id); if (realizadaSelect.value == "3") { // Se "Não" for selecionado justificativaDiv.style.display = 'block'; } else { justificativaDiv.style.display = 'none'; } } function toggleJustificativaEdit(id) { var realizadaSelect = document.getElementById('realizadaEdit' + id); var justificativaDiv = document.getElementById('justificativaDivEdit' + id); if (realizadaSelect.value == "3") { // Se "Não" for selecionado justificativaDiv.style.display = 'block'; } else { justificativaDiv.style.display = 'none'; } } </script> <script> $(function () { fillCalendar(new Date()); $("#selectedMonth, #selectedYear").change(function () { var selectedDate = new Date($("#selectedYear").val(), $("#selectedMonth").val() - 1); fillCalendar(selectedDate); }); }); function fillCalendar(selectedDate) { var firstDay = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), 1); var lastDay = new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 0); var calendarBody = $("#calendarBody"); calendarBody.empty(); var currentDate = new Date(firstDay); var row = $("<tr></tr>"); for (var i = 0; i < firstDay.getDay(); i++) { row.append("<td></td>"); } while (currentDate <= lastDay) { var formattedDate = currentDate.toISOString().slice(0, 10); var dayNumber = currentDate.getDate(); row.append("<td><label><input type='checkbox' name='selectedDates[]' value='" + formattedDate + "'> " + dayNumber + "</label></td>"); if (currentDate.getDay() === 6) { calendarBody.append(row); row = $("<tr></tr>"); } currentDate.setDate(currentDate.getDate() + 1); } for (var i = lastDay.getDay() + 1; i <= 6; i++) { row.append("<td></td>"); } calendarBody.append(row); } </script> </body> </html>
Save
Cancel