[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: mynewreport.php
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require("fpdf/fpdf.php"); include("../functions.php"); $school_ID = $_SESSION['student_id0023894']; $myschoolcode = $_SESSION['myschoolcode']; $school_ID = $_SESSION['index_no78897498']; function ordinal($num) { $ends = ['th','st','nd','rd','th','th','th','th','th','th']; if (($num % 100) >= 11 && ($num % 100) <= 13) return $num.'th'; else return $num.$ends[$num % 10]; } // === GET SCHOOL DETAILS === $stmt = $con->prepare("Select * from schools where school_code = ?"); $stmt->execute(array($myschoolcode)); $row = $stmt->fetch(); $logo = $row['logo']; $school_name = $row['school_name']; $school_region = $row['school_region']; $school_location = $row['school_location']; $school_email = $row['school_email']; $phone_num = $row['phone_num']; // === GET STUDENT PHOTO FROM enrol_details === $indexx1 = mysqli_query($new, "SELECT * FROM enrol_details WHERE index_no = '$school_ID' AND s_code = '$myschoolcode'"); $fetchschh = mysqli_fetch_array($indexx1); $photo = $fetchschh['photo'] ?? ''; // fallback if null // === FPDF CLASS === class PDF extends FPDF { private $school_name; private $school_region; private $school_location; private $school_email; private $phone_num; private $logo; private $photo; public function __construct($school_name, $school_region, $school_location, $school_email, $phone_num, $logo, $photo = '') { parent::__construct(); $this->school_name = $school_name; $this->school_region = $school_region; $this->school_location = $school_location; $this->school_email = $school_email; $this->phone_num = $phone_num; $this->logo = $logo; $this->photo = $photo; } function Header() { // === SCHOOL LOGO (LEFT) === $schoolLogoPath = (!empty($this->logo) && file_exists(__DIR__ . "/../admin/{$this->logo}")) ? __DIR__ . "/../admin/{$this->logo}" : __DIR__ . '/nulllogo.jpg'; $this->Image($schoolLogoPath, 15, 10, 20); // === STUDENT PICTURE (RIGHT) === $profilePicturePath = empty($this->photo) ? __DIR__ . '/myprofile.png' : __DIR__ . "/../admin/{$this->photo}"; if (file_exists($profilePicturePath)) { $this->Image($profilePicturePath, 175, 10, 25); } else { $this->Image(__DIR__ . '/myprofile.png', 175, 10, 25); } // === HEADER TEXT === $this->SetY(12); $this->SetFont('Arial', 'B', 14); $this->Cell(0, 7, $this->school_name, 0, 1, 'C'); $this->SetFont('Arial', '', 10); $this->Cell(0, 6, "P.O. BOX 404, {$this->school_location}, {$this->school_region}, GHANA TEL: {$this->phone_num}", 0, 1, 'C'); $this->Ln(3); $this->SetFont('Arial', 'B', 12); $this->Cell(0, 8, 'TERMINAL REPORT', 0, 1, 'C'); $this->Ln(3); $this->SetDrawColor(0, 0, 0); $this->SetLineWidth(0.4); $this->Line(15, $this->GetY(), 195, $this->GetY()); $this->Ln(5); } function SubjectTableHeader() { $this->SetFont('Arial', 'B', 9); $this->Cell(40, 8, 'SUBJECTS', 1, 0, 'C'); $this->Cell(20, 8, 'CLASS', 1, 0, 'C'); $this->Cell(20, 8, 'EXAM', 1, 0, 'C'); $this->Cell(20, 8, 'TOTAL', 1, 0, 'C'); $this->Cell(30, 8, 'POSITION', 1, 0, 'C'); $this->Cell(20, 8, 'GRADE', 1, 0, 'C'); $this->Cell(40, 8, 'REMARKS', 1, 1, 'C'); } } $pdf = new PDF($school_name, $school_region, $school_location, $school_email, $phone_num, $logo, $photo); $pdf->AddPage(); // Student Info Section // ===================== // STUDENT INFO SECTION (COMPACT) // ===================== $pdf->Ln(4); $pdf->SetFont('Arial', '', 10); $indexx1 = mysqli_query($new, "SELECT * FROM enrol_details WHERE index_no = '$school_ID' AND s_code = '$myschoolcode'"); $fetchschh = mysqli_fetch_array($indexx1); $student_name = $fetchschh['student_name'] ?? ''; // fallback if null $my_schoolid1 = $fetchschh['schoolID'] ?? ''; // fallback if null $my_schoolid2 = $fetchschh['unique_student_code'] ?? ''; // fallback if null if($my_schoolid1 ==""){ $htismyid = $my_schoolid2; } else { $htismyid = $my_schoolid1; } $studentD = mysqli_query($new,"SELECT * FROM enrol_details,class WHERE enrol_details.index_no = '$school_ID' and enrol_details.class_id = class.cid"); $getinfo = mysqli_fetch_array($studentD); $c_name = $getinfo['class_name'] ?? ''; $classID = $getinfo['cid'] ?? ''; $classprog = mysqli_query($new,"SELECT * FROM programme,class WHERE class.program_id = programme.progid and class.cid = '$classID'"); $getclassprogg = mysqli_fetch_array($classprog); $programme = $getclassprogg['program_name'] ?? ''; $class_name = $getclassprogg['class_name'] ?? ''; $getprogramme = mysqli_query($new,"SELECT * FROM enrol_details WHERE index_no = '$school_ID' and s_code = '$myschoolcode'"); $getinfoo = mysqli_fetch_array($getprogramme); $myprograme = $getinfoo['programe'] ?? ''; $myclassname = $getinfoo['classname'] ?? ''; if($programme ==""){ $thismyprograme = $myprograme; } else { $thismyprograme = $programme; } if($class_name ==""){ $thismyclass = $myclassname; } else { $thismyclass = $class_name; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['semesterSelect'])) { // Get the raw value from POST $value = $_POST['semesterSelect']; // Split it back into form, semester, and term list($form, $semester, $term) = explode('-', $value); $total_avg_sql = " SELECT ROUND(AVG(total_score), 2) AS total_average FROM student_result WHERE s_code = '$myschoolcode' AND form = '$form' AND term = '$term' AND academicyear = '$semester' AND index_number = '$school_ID'; "; $total_avg_result = mysqli_query($new, $total_avg_sql); $total_avg = mysqli_fetch_assoc($total_avg_result)['total_average'] ?? 0; // Define column widths for better alignment $labelWidth = 35; // width for labels (Student:, Programme:, etc.) $valueWidth = 55; // width for values (AGYARE, BLESSING, etc.) $labelWidth2 = 30; // width for second label (Student ID:, etc.) $valueWidth2 = 35; // width for second value (2186952, etc.) // Row 1 $pdf->Cell($labelWidth, 6, 'Student:', 0, 0); $pdf->Cell($valueWidth, 6, "$student_name", 0, 0); $pdf->Cell($labelWidth2, 6, 'Student ID:', 0, 0); $pdf->Cell($valueWidth2, 6, "$htismyid", 0, 1); // Row 2 $pdf->Cell($labelWidth, 6, 'Programme:', 0, 0); $pdf->Cell($valueWidth, 6, "$thismyprograme", 0, 0); $pdf->Cell($labelWidth2, 6, 'Class:', 0, 0); $pdf->Cell($valueWidth2, 6, "$thismyclass", 0, 1); // Row 3 $pdf->Cell($labelWidth, 6, 'House:', 0, 0); $pdf->Cell($valueWidth, 6, 'ST. MARTINS DE PORRES', 0, 0); $pdf->Cell($labelWidth2, 6, 'Academic Year:', 0, 0); $pdf->Cell($valueWidth2, 6, "$semester/$term/$form", 0, 1); $pdf->Cell($labelWidth2, 6, 'Average:', 0, 0); $pdf->Cell($valueWidth2, 6, "$total_avg", 0, 1); // Row 5 // $pdf->Cell($labelWidth, 6, 'Position:', 0, 0); // $pdf->Cell($valueWidth, 6, '19th', 0, 1); $pdf->Ln(3); $pdf->Ln(3); // Subjects Table $pdf->SubjectTableHeader(); $subjects = [ ['Core Mathematics', 27.80, 46.90, 74.70, '14 / 60', 'B2', 'Very Good'], ['English Language', 23.00, 42.00, 65.00, '27 / 60', 'C4', 'Good'], ['Integrated Science', 27.00, 40.00, 67.00, '16 / 60', 'B3', 'Good'], ['Social Studies', 29.00, 50.50, 79.50, '9 / 60', 'A2', 'Very Good'], ['Biology', 18.00, 42.00, 60.00, '40 / 60', 'C5', 'Credit'], ['Chemistry', 30.00, 40.00, 70.00, '17 / 60', 'B3', 'Good'], ['Elective Mathematics', 26.00, 51.00, 77.00, '7 / 60', 'A2', 'Excellent'], ['Physics', 23.00, 51.10, 74.10, '15 / 60', 'B2', 'Very Good'], ]; $pdf->SetFont('Arial', '', 9); foreach ($subjects as $row) { $pdf->Cell(40, 8, $row[0], 1); $pdf->Cell(20, 8, number_format($row[1], 2), 1, 0, 'C'); $pdf->Cell(20, 8, number_format($row[2], 2), 1, 0, 'C'); $pdf->Cell(20, 8, number_format($row[3], 2), 1, 0, 'C'); $pdf->Cell(30, 8, $row[4], 1, 0, 'C'); $pdf->Cell(20, 8, $row[5], 1, 0, 'C'); $pdf->Cell(40, 8, $row[6], 1, 1, 'C'); } $pdf->Ln(4); } } // ===================== // GRADING SYSTEM (FULL WIDTH, BALANCED) // ===================== $pdf->Ln(4); // Title (centered) $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(0, 6, 'GRADING SYSTEM', 0, 1, 'C'); // Horizontal line $startX = 15; $endX = 195; $y = $pdf->GetY(); $pdf->Line($startX, $y, $endX, $y); $pdf->Ln(4); // Grading data $grading = [ ['80-100', 'A+', 'EXCELLENT'], ['75-79', 'B2', 'VERY GOOD'], ['70-74', 'B3', 'GOOD'], ['65-69', 'C4', 'CREDIT'], ['60-64', 'C5', 'CREDIT'], ['55-59', 'C6', 'CREDIT'], ['50-54', 'D7', 'PASS'], ['40-49', 'E8', 'WEAK PASS'], ['0-39', 'F9', 'FAIL'], ]; // We will print 3 grading items per line (auto-balance) $colsPerRow = 3; $colWidth = ($endX - $startX) / $colsPerRow; $pdf->SetFont('Arial', '', 9); foreach (array_chunk($grading, $colsPerRow) as $row) { $x = $startX; foreach ($row as $g) { $pdf->SetXY($x, $pdf->GetY()); $pdf->Cell($colWidth, 6, '', 0, 0); // placeholder cell // Print inside the cell: Marks = Grade Remark $pdf->SetX($x + 2); $pdf->SetFont('Arial', '', 9); $pdf->Write(5, "{$g[0]} = "); $pdf->SetFont('Arial', 'B', 9); $pdf->Write(5, "{$g[1]} "); $pdf->SetFont('Arial', '', 9); $pdf->Write(5, "{$g[2]}"); $x += $colWidth; } $pdf->Ln(6); } $pdf->Ln(6); // ===================== // FOOTER (REMARKS + SIGNATURE + DATES) // ===================== // Teacher's Remark $pdf->SetFont('Arial', '', 10); $pdf->Cell(50, 7, "Form Teacher's Remark:", 0, 0); $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(0, 7, 'EXCELLENT ACADEMIC PERFORMANCE', 0, 1); $pdf->SetFont('Arial', '', 10); $pdf->Cell(50, 7, "Head's Remark:", 0, 0); $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(0, 7, 'Excellent Academic Performance, Keep It Up', 0, 1); // Space before signature $pdf->Ln(10); // Add horizontal line below Head's Remark $startX = 15; $endX = 195; $y = $pdf->GetY() + 2; // a little spacing $pdf->Line($startX, $y, $endX, $y); $pdf->Ln(6); // Signature image (right-aligned) if (file_exists(__DIR__ . '/nulllogo.jpg')) { // Place image at the left (x = 15), current Y position $pdf->Image(__DIR__ . '/nulllogo.jpg', 15, $pdf->GetY(), 40); } // Head name & title $pdf->Ln(18); $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(0, 6, 'AMA KYEREWAA B (Mrs)', 0, 1, 'R'); $pdf->SetFont('Arial', '', 9); $pdf->Cell(0, 6, 'HEADMISTRESS', 0, 1, 'R'); $pdf->Ln(6); // Next term date and printed date (left-aligned) $pdf->SetFont('Arial', '', 9); $pdf->Cell(0, 6, 'Term Next Begins: 01-May-2023', 0, 1); $pdf->Output();
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.02 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