ÿþ<?php require_once 'admin/config/database.php'; require_once 'admin/config/session.php'; $database = new Database(); $pdo = $database->getConnection(); // Get parameters $admission_number = $_GET['admission_number'] ?? ''; $term_id = $_GET['term_id'] ?? ''; if (empty($admission_number) || empty($term_id)) { die('Missing required parameters'); } try { // Get student information $studentQuery = "SELECT s.*, sub2.name as subsidiary_name, sub2.logo as subsidiary_logo FROM students s LEFT JOIN subsidiaries sub2 ON s.subsidiary_id = sub2.id WHERE s.admission_number = :admission_number"; $studentStmt = $pdo->prepare($studentQuery); $studentStmt->bindParam(':admission_number', $admission_number); $studentStmt->execute(); $student = $studentStmt->fetch(PDO::FETCH_ASSOC); if (!$student) { die('Student not found'); } // Get term information $termQuery = "SELECT * FROM academic_terms WHERE id = :term_id"; $termStmt = $pdo->prepare($termQuery); $termStmt->bindParam(':term_id', $term_id); $termStmt->execute(); $term = $termStmt->fetch(PDO::FETCH_ASSOC); if (!$term) { die('Term not found'); } // Get student results $resultsQuery = "SELECT r.*, sub.name as subject_name FROM results r JOIN subjects sub ON r.subject_id = sub.id WHERE r.student_id = :student_id AND r.term_id = :term_id ORDER BY sub.name"; $resultsStmt = $pdo->prepare($resultsQuery); $resultsStmt->bindParam(':student_id', $student['id']); $resultsStmt->bindParam(':term_id', $term_id); $resultsStmt->execute(); $results = $resultsStmt->fetchAll(PDO::FETCH_ASSOC); if (empty($results)) { die('No results found for this student in the selected term'); } // Calculate summary $totalScore = 0; $totalPercentage = 0; $subjectCount = count($results); foreach ($results as $result) { $totalScore += $result['total_score']; $totalPercentage += $result['percentage']; } $averagePercentage = $subjectCount > 0 ? round($totalPercentage / $subjectCount, 2) : 0; } catch (Exception $e) { die('Error: ' . $e->getMessage()); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Student Result - <?php echo htmlspecialchars($student['first_name'] . ' ' . $student['last_name']); ?></title> <script src="https://cdn.tailwindcss.com"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"> <style> @media print { .no-print { display: none !important; } body { margin: 0; padding: 10px; } } </style> </head> <body class="bg-gray-100"> <div class="max-w-4xl mx-auto p-6"> <!-- Print Button --> <button onclick="window.print()" class="no-print mb-4 bg-blue-600 text-white px-4 py-2 rounded-lg"> <i class="fas fa-print mr-2"></i>Print Result </button> <!-- Result Card --> <div class="bg-white rounded-lg shadow-lg overflow-hidden"> <!-- Header --> <div class="bg-gradient-to-r from-blue-600 to-blue-800 text-white p-6 text-center"> <div class="flex items-center justify-center mb-4"> <div class="w-16 h-16 bg-white rounded-full flex items-center justify-center mr-4"> <i class="fas fa-graduation-cap text-blue-600 text-2xl"></i> </div> <div> <h1 class="text-2xl font-bold"><?php echo htmlspecialchars($student['subsidiary_name'] ?? 'Haneef Network of Schools'); ?></h1> <p class="text-blue-100">Student Performance Report</p> </div> </div> <h2 class="text-xl font-semibold"><?php echo strtoupper($term['name']); ?> TERM - <?php echo htmlspecialchars($term['academic_year']); ?></h2> </div> <!-- Student Info --> <div class="p-6 bg-gray-50 border-b"> <div class="grid md:grid-cols-2 gap-4"> <div> <h3 class="font-bold text-gray-700 mb-2">Student Information</h3> <p><strong>Name:</strong> <?php echo strtoupper($student['last_name'] . ', ' . $student['first_name']); ?></p> <p><strong>Class:</strong> <?php echo strtoupper($student['class_level']); ?></p> <p><strong>Admission No:</strong> <?php echo htmlspecialchars($student['admission_number']); ?></p> <p><strong>Gender:</strong> <?php echo strtoupper($student['gender']); ?></p> </div> <div> <h3 class="font-bold text-gray-700 mb-2">Academic Summary</h3> <p><strong>Total Score:</strong> <?php echo number_format($totalScore, 1); ?></p> <p><strong>Average:</strong> <?php echo number_format($averagePercentage, 2); ?>%</p> <p><strong>Subjects:</strong> <?php echo $subjectCount; ?></p> <p><strong>Term:</strong> <?php echo strtoupper($term['name']); ?></p> </div> </div> </div> <!-- Results Table --> <div class="p-6"> <h3 class="font-bold text-gray-700 mb-4">Subject Results</h3> <div class="overflow-x-auto"> <table class="w-full border-collapse border border-gray-300"> <thead> <tr class="bg-gray-100"> <th class="border border-gray-300 px-4 py-2 text-left">Subject</th> <th class="border border-gray-300 px-4 py-2 text-center">C.A. (40)</th> <th class="border border-gray-300 px-4 py-2 text-center">Exam (60)</th> <th class="border border-gray-300 px-4 py-2 text-center">Total (100)</th> <th class="border border-gray-300 px-4 py-2 text-center">Grade</th> <th class="border border-gray-300 px-4 py-2 text-center">Remark</th> </tr> </thead> <tbody> <?php foreach ($results as $result): ?> <tr> <td class="border border-gray-300 px-4 py-2 font-semibold"><?php echo strtoupper($result['subject_name']); ?></td> <td class="border border-gray-300 px-4 py-2 text-center"><?php echo $result['ca1_score'] + $result['ca2_score']; ?></td> <td class="border border-gray-300 px-4 py-2 text-center"><?php echo $result['exam_score']; ?></td> <td class="border border-gray-300 px-4 py-2 text-center font-bold"><?php echo $result['total_score']; ?></td> <td class="border border-gray-300 px-4 py-2 text-center font-bold"><?php echo $result['grade']; ?></td> <td class="border border-gray-300 px-4 py-2 text-center"><?php echo getGradeRemark($result['grade']); ?></td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> <!-- Grade Scale --> <div class="p-6 bg-gray-50 border-t"> <h3 class="font-bold text-gray-700 mb-4">Grade Scale</h3> <div class="grid md:grid-cols-3 gap-4 text-sm"> <div><strong>A1:</strong> 85-100% - EXCELLENT</div> <div><strong>B2:</strong> 75-84.9% - VERY GOOD</div> <div><strong>B3:</strong> 70-74.9% - GOOD</div> <div><strong>C4:</strong> 65-69.9% - CREDIT</div> <div><strong>C5:</strong> 60-64.9% - CREDIT</div> <div><strong>C6:</strong> 50-59.9% - CREDIT</div> <div><strong>D7:</strong> 45-49.9% - PASS</div> <div><strong>E8:</strong> 40-44.9% - PASS</div> <div><strong>F9:</strong> 0-39.9% - FAIL</div> </div> </div> <!-- Footer --> <div class="p-6 bg-gray-800 text-white text-center"> <p class="font-semibold">Haneef Network of Schools</p> <p class="text-sm text-gray-300">Excellence in Islamic Education</p> <p class="text-xs text-gray-400 mt-2">Generated on <?php echo date('d-M-Y H:i:s'); ?></p> </div> </div> </div> <?php function getGradeRemark($grade) { $remarks = [ 'A1' => 'EXCELLENT', 'A2' => 'EXCELLENT', 'A3' => 'EXCELLENT', 'B2' => 'VERY GOOD', 'B3' => 'GOOD', 'B4' => 'GOOD', 'C4' => 'CREDIT', 'C5' => 'CREDIT', 'C6' => 'CREDIT', 'D7' => 'PASS', 'E8' => 'PASS', 'F9' => 'FAIL' ]; return $remarks[$grade] ?? 'N/A'; } ?> </body> </html>