BossBey File Manager
PHP:
8.4.18
OS:
Linux
User:
kids
Root
/
home
/
kids
/
public_html
/
app
📤 Upload
📝 New File
📁 New Folder
Close
Editing: formcal.php
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Calendário de Aulas</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> </head> <body> <div class="container mt-5"> <h1>Calendário de Aulas</h1> <form action="criar_aulas.php" method="post"> <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> <button type="submit" class="btn btn-primary">Criar Aulas</button> </form> </div> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script> $(function () { // Preenche a tabela com o mês e o ano atuais fillCalendar(new Date()); // Atualiza a tabela quando o mês ou o ano selecionado mudam $("#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>"); // Preenche os dias anteriores ao primeiro dia do mês for (var i = 0; i < firstDay.getDay(); i++) { row.append("<td></td>"); } // Preenche os dias do mês atual com checkboxes 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); } // Completa a última linha com dias do próximo mês, se necessário for (var i = lastDay.getDay() + 1; i <= 6; i++) { row.append("<td></td>"); } calendarBody.append(row); } </script> </body> </html>
Save
Cancel