[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: print-timetable.php
<?php include("functions.php"); if(!isset($_SESSION['index_no78897498'])){ header("location:index"); } else { $myschoolcode = $_SESSION['myschoolcode'] ?? ''; $schoolID = $_SESSION['student_id0023894'] ?? ''; $stmt = $con->prepare("SELECT * FROM admission_info WHERE s_code = ?"); $stmt->execute(array($myschoolcode)); $userstatus = $stmt->fetchAll(); foreach ($userstatus as $sta) { $academic_year = $sta['academic_year']; } $stmtt = $con->prepare("SELECT * FROM schools WHERE school_code = ?"); $stmtt->execute(array($myschoolcode)); $sname = $stmtt->fetchAll(); foreach ($sname as $sta) { $school_name = $sta['school_name']; } // Fetch all saved timetable records including is_break_time $sql = "SELECT * FROM timetable1 WHERE s_code = '$myschoolcode'"; $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 = '$myschoolcode'")->fetch_all(MYSQLI_ASSOC); $teachers = $new->query("SELECT * FROM schools WHERE school_code = '$myschoolcode' and user_name != 'Admin'")->fetch_all(MYSQLI_ASSOC); $rooms = $new->query("SELECT * FROM room WHERE s_code = '$myschoolcode'")->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>School Timetable</title> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet"> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: 'Roboto', sans-serif; background-color: #f7f9fc; color: #333; padding: 20px; line-height: 1.6; } .container { max-width: 1200px; margin: 0 auto; background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); padding: 20px; } .header { text-align: center; margin-bottom: 20px; } .header h1 { font-size: 1.8rem; color: #1a3c6c; font-weight: 700; text-transform: uppercase; } .header h2 { font-size: 1.2rem; color: #555; font-weight: 500; } .print-button { display: block; margin: 20px auto; padding: 10px 24px; background-color: #1a3c6c; color: #fff; border: none; border-radius: 4px; font-size: 1rem; cursor: pointer; transition: background-color 0.3s ease; } .print-button:hover { background-color: #2a5c9c; } table { width: 100%; border-collapse: collapse; font-size: 0.9rem; } th, td { border: 1px solid #e0e0e0; padding: 12px; text-align: center; vertical-align: middle; } th { background-color: #1a3c6c; color: #fff; font-weight: 500; text-transform: uppercase; font-size: 0.85rem; } td { background-color: #fff; transition: background-color 0.2s ease; } .break-time { background-color: #ff8c00; color: #fff; font-weight: 500; } .free-period { background-color: #e6ffed; color: #2e7d32; font-style: italic; } td div { margin-bottom: 4px; font-size: 0.85rem; } td div:last-child { margin-bottom: 0; } /* Responsive Design */ @media (max-width: 768px) { .container { padding: 10px; } table { font-size: 0.8rem; } th, td { padding: 8px; } .header h1 { font-size: 1.4rem; } .header h2 { font-size: 1rem; } } /* Print Styles */ @media print { @page { size: landscape; margin: 0.5in; } body { background-color: #fff; padding: 0; } .container { box-shadow: none; padding: 0; margin: 0; } .print-button { display: none; } th { background-color: #333; color: #fff; } td { border: 1px solid #000; } .break-time { background-color: #ccc; color: #000; } .free-period { background-color: #eee; color: #000; } } </style> <script> function printTimetable() { window.print(); } </script> </head> <body> <div class="container"> <div class="header"> <h1>Timetable for <?php echo htmlspecialchars($academic_year ?? '2025-2026'); ?> Academic Year</h1> <h2><?php echo htmlspecialchars($school_name ?? 'Your School Name'); ?></h2> </div> <button class="print-button" onclick="printTimetable()">Print Timetable</button> <table> <thead> <tr> <th>Day/Time</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> </thead> <tbody> <?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; if ($data && ($data['is_break_time'] ?? 0) == 1) { echo "<td class='break-time'>Break Time</td>"; } else { $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>"; } ?> </tbody> </table> </div> </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: 60.07 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