query("SELECT m.*, s.subject_name, s.code, s.max_marks, s.min_marks, s.is_optional FROM marks_table m LEFT JOIN subjects s ON m.subject_id = s.id WHERE m.result_id = '".$serial_no."' AND (s.is_optional = 0 OR s.is_optional IS NULL) ORDER BY s.subject_name ASC"); $compulsory_marks = []; $total_compulsory_obtain = 0; $total_compulsory_max = 0; if($compulsory_marks_query && $compulsory_marks_query->num_rows > 0) { while($cm = $compulsory_marks_query->fetch_assoc()) { $compulsory_marks[] = $cm; $total_compulsory_obtain += $cm['marks']; $total_compulsory_max += ($cm['max_marks'] ? $cm['max_marks'] : 100); } } // Get optional subjects $optional_marks_query = $con->query("SELECT m.*, s.subject_name, s.code, s.max_marks, s.min_marks, s.is_optional FROM marks_table m LEFT JOIN subjects s ON m.subject_id = s.id WHERE m.result_id = '".$serial_no."' AND s.is_optional = 1 ORDER BY s.subject_name ASC"); $optional_marks = []; if($optional_marks_query && $optional_marks_query->num_rows > 0) { while($om = $optional_marks_query->fetch_assoc()) { $optional_marks[] = $om; } } // Grand total - ONLY COMPULSORY MARKS INCLUDED $grand_total_obtain = $total_compulsory_obtain; $grand_total_max = $total_compulsory_max; $percentage = $grand_total_max > 0 ? round(($grand_total_obtain / $grand_total_max) * 100, 2) : 0; // Function to convert numbers into full words if (!function_exists('numberToWords')) { function numberToWords($num) { $num = (int)$num; if ($num == 0) return 'Zero'; $ones = array('', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'); $tens = array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'); if ($num < 20) { return $ones[$num]; } elseif ($num < 100) { return trim($tens[(int)($num / 10)] . ' ' . $ones[$num % 10]); } elseif ($num < 1000) { return trim($ones[(int)($num / 100)] . ' Hundred ' . numberToWords($num % 100)); } elseif ($num < 100000) { return trim(numberToWords((int)($num / 1000)) . ' Thousand ' . numberToWords($num % 1000)); } return (string)$num; } } // CORRECTED DOB PARSING (DD-MM-YYYY) $dob_clean = str_replace('/', '-', $dob); $dob_parts = explode('-', $dob_clean); $dob_day = isset($dob_parts[0]) ? (int)$dob_parts[0] : 0; // DD $dob_month = isset($dob_parts[1]) ? (int)$dob_parts[1] : 0; // MM $dob_year = isset($dob_parts[2]) ? (int)$dob_parts[2] : 0; // YYYY $months = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; // Complete DOB in words $dob_in_words = trim(numberToWords($dob_day) . ' ' . ($months[$dob_month] ?? '') . ' ' . numberToWords($dob_year)); // DOB display format: DD/MM/YYYY $dob_display = sprintf('%02d/%02d/%04d', $dob_day, $dob_month, $dob_year); // Parse session for exam month/year $session_parts = explode(' ', $session); $exam_month = $session_parts[0] ?? ''; $exam_year = $session_parts[1] ?? date('Y'); $exam_display = $exam_month . ' - ' . $exam_year; // Generate Serial Number $alphabet_index = ($serial_no - 1) % 26; $alpha = chr(65 + $alphabet_index); $num_part = str_pad($serial_no, 6, '572', STR_PAD_LEFT); // Dynamic Seat Number logic $seat_alpha_index = ($serial_no - 1) % 26; $seat_alpha = chr(65 + $seat_alpha_index); $seat_num = str_pad(($serial_no % 100), 2, '0', STR_PAD_LEFT); $seat_no = $seat_alpha . '-' . $seat_num; // Dynamic Centre/Institute Code Resolution $display_centre_code = $center_code ?? $centre_code ?? $centre_no ?? $institute_code ?? $inst_code ?? $school_code ?? $college_code ?? $center_id ?? 'GSOS-AHM-001'; // ============ FIX: GSOS School/Centre Name from Database ============ $display_isu = 'Gujarat State Open School'; // Default // Get center_id and issue_date from results table $center_query = $con->query("SELECT center_id, issue_date FROM results WHERE id = '".$serial_no."' OR enrollment_no = '".$enroll_no."'"); $db_issue_date = ''; // For storing issue date from DB if($center_query && $center_query->num_rows > 0) { $center_data = $center_query->fetch_assoc(); $db_center_id = $center_data['center_id']; // Get issue_date from results if(!empty($center_data['issue_date'])) { $db_issue_date = $center_data['issue_date']; } if(!empty($db_center_id)) { // Get institute name from centers table $institute_query = $con->query("SELECT institute_name FROM centers WHERE id = '".$db_center_id."'"); if($institute_query && $institute_query->num_rows > 0) { $inst_data = $institute_query->fetch_assoc(); if(!empty($inst_data['institute_name'])) { $display_isu = $inst_data['institute_name']; } } } } // ============ FIXED: Issue Date for Footer ============ // Priority: results.issue_date > $issue_date variable > current date if (!empty($db_issue_date)) { $display_issue_date = date('d/m/Y', strtotime($db_issue_date)); } elseif (isset($issue_date) && !empty($issue_date)) { $display_issue_date = date('d/m/Y', strtotime($issue_date)); } else { // Check migrations table for issue_date $mig_query = $con->query("SELECT issue_date FROM migrations WHERE enrollment_no = '".$enroll_no."' LIMIT 1"); if($mig_query && $mig_query->num_rows > 0) { $mig_data = $mig_query->fetch_assoc(); if(!empty($mig_data['issue_date'])) { $display_issue_date = date('d/m/Y', strtotime($mig_data['issue_date'])); } else { $display_issue_date = date('d/m/Y'); } } else { $display_issue_date = date('d/m/Y'); } } // ============ END ISSUE DATE FIX ============ // Photo path $photo_path = $photo; // QR Code Data $qr_data = "Enrollment No: " . $enroll_no . "\n"; $qr_data .= "Name: " . $name . "\n"; $qr_data .= "Roll No: " . $enroll_no . "\n"; $qr_data .= "Seat No: " . $seat_no . "\n"; $qr_data .= "Serial: " . $alpha . "-" . $num_part . "\n"; $qr_data .= "Course: " . $course_name . "\n"; $qr_data .= "Exam: " . $exam_display . "\n"; $qr_data .= "Result: " . $res . "\n"; $qr_data .= "Grade: " . $grade . "\n"; $qr_data .= "Percentage: " . $percentage . "%"; ob_start(); QRcode::png($qr_data, null, QR_ECLEVEL_L, 10, 1); $image_data = ob_get_contents(); ob_end_clean(); ?> Marksheet | [<?= $enroll_no ?>] | <?= $alpha ?>-<?= $num_part ?> Marksheet Background
-
MONTH & YEAR OF THE EXAM. SEAT No. CENTRE CODE STREAM ROLL NO.
Candidate Name : Father's Name :
Mother's Name :
Date of Birth : ()
School/Centre :
Student Photo
= 33 ? 'PASS' : 'FAIL'; $grade_result = my_grade($percentage); ?>
NAME OF THE SUBJECT WITH CODE NO. TOTAL MARKS MARKS OBTAINED +CONDONATION = TOTAL MARKS OBTAINED IN WORDS SUBJECT WISE GRADE
OBTAINED MARKS OUT OF TOTAL MARKS / TOTAL MARKS OBTAINED IN WORDS
'SKILL', 'grade' => 'A'], ]; $max_rows = max(count($optional_marks), count($co_scholastic)); ?>
PERFORMANCE IN THE SUBJECTS OF SCHOOL BASED EXAMINATION
NAME OF THE SUBJECT WITH CODE NO. GRADE CO-SCHOLASTIC EVALUATION GRADE
RESULT GRADE PERCENTILE RANK %
મહત્વપૂર્ણ: જારી કરનાર સત્તાધિકારી સિવાય આ દસ્તાવેજમાં કોઈપણ ફેરફાર, નિવેદન રદ કરવામાં પરિણમશે અને યોગ્ય કાનૂની કાર્યવાહી લાગુ કરવામાં આવશે.
IMPORTANT: Any change in this document except by the issuing authority, will result into cancellation of the statement and shall also invoke imposition of appropriate legal action.
QR Code