<?php

function template36($institutions, $branch, $students_array, $examination, $array, $result, $class_id, $section_id)
{
?>
	<!DOCTYPE html>
	<html lang="en">

	<head>
		<meta charset="UTF-8" />
		<title>Report Card</title>
		<link rel="stylesheet" href="<?php echo 'https://rejoicebilldesk.in/rjllearning_development/resources/marksheet_template/template36/style_template36.css?key=' . time(); ?>" />
	</head>

	<body>

		<div class="report-card">

			<!-- Header -->
			<div class="header">
				<div class="logo">
					<?php if (!empty($institutions['logo'])): ?>
						<img src="<?= htmlspecialchars($institutions['logo']) ?>" alt="School Logo">
					<?php endif; ?>
				</div>
				<div class="school-details">
					<p class="sname"><?= strtoupper(htmlspecialchars($institutions['institution_name'] ?? '')) ?></p>

					<p class="address"><strong><?= !empty($branch['address'])
													? ucfirst(htmlspecialchars($branch['address']))
													: '' ?></strong></p>

					<hr class="address-line">

					<div class="branch-details">
						<?php if (!empty($branch['city'])): ?>
							<?= htmlspecialchars($branch['city']) ?>
						<?php endif; ?>

						<?php if (!empty($branch['pincode'])): ?>
							- <?= htmlspecialchars($branch['pincode']) ?>
						<?php endif; ?>

						<?php if (!empty($branch['contact_number'])): ?>
							&nbsp; | ☎ <?= htmlspecialchars($branch['contact_number']) ?>
						<?php endif; ?>

						<?php if (!empty($branch['email'])): ?>
							&nbsp; | ✉ <?= htmlspecialchars($branch['email']) ?>
						<?php endif; ?>
					</div>

					<p class="affiliation">
						<strong>
							<?php if (!empty($branch['affiliation_code'])): ?>
								<?= htmlspecialchars($branch['affiliation_code']) ?>
							<?php endif; ?>
						</strong>
					</p>
				</div>
			</div>

			<div class="term-box">
				Term 2 (2025-26)
			</div>

			<!-- Student Info with Photo -->
			<div class="student-info-container">
				<div class="student-details">
					<p><strong>Student's Name : </strong> <?= $students_array[0]['name'] ?? '' ?></p>

					<p><strong>Father's Name : </strong> <?= $students_array[0]['fathername'] ?? '' ?></p>

					<p><strong>Mother's Name : </strong> <?= $students_array[0]['mothername'] ?? '' ?></p>

					<p><strong>D.O.B : </strong> <?= !empty($students_array[0]['dob'])
														? date('d-m-Y', strtotime($students_array[0]['dob']))
														: '' ?>
					</p>
				</div>
				<div class="student-details">
					<p><strong>Class : </strong> <?= $class_id ?? '' ?></p>

					<p><strong>Section : </strong> <?= $section_id ?? '' ?></p>

					<p><strong>Roll No : </strong> </p>

					<p><strong>Admission No : </strong> <?= $students_array[0]['admission_number'] ?? '' ?></p>

				</div>
				<div class="student-photo">
					<div class="photo-placeholder">
						<?php if (!empty($students_array[0]['student_image']['filepath'])): ?>
							<img src="<?= htmlspecialchars($students_array[0]['student_image']['filepath']) ?>" class="student-photo" alt="Student Photo">
						<?php else: ?>
							<span class="photo-label">No Photo</span>
						<?php endif; ?>
					</div>
				</div>
			</div>

			<!-- Scholastic Area -->
			<div class="table-title">
				Scholastic Area (Grading on 7 Point Scale)
			</div>
			<table>
				<thead>
					<tr>
						<th>Subjects</th>
						<th>Periodic Test (25)</th>
						<th>Subject Enrichment (20)</th>
						<th>Notebook (5)</th>
						<th>Half Yearly (50)</th>
						<th>Total (100)</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>English</td>
						<td><?php echo $array[1]; ?></td>
						<td><?php echo $array[2]; ?></td>
						<td><?php echo $array[3]; ?></td>
						<td><?php echo $array[4]; ?></td>
						<td><?php echo $array[5]; ?></td>
					</tr>
					<tr>
						<td>Hindi</td>
						<td><?php echo $array[6]; ?></td>
						<td><?php echo $array[7]; ?></td>
						<td><?php echo $array[8]; ?></td>
						<td><?php echo $array[9]; ?></td>
						<td><?php echo $array[10]; ?></td>
					</tr>
					<tr>
						<td>Punjabi</td>
						<td><?php echo $array[11]; ?></td>
						<td><?php echo $array[12]; ?></td>
						<td><?php echo $array[13]; ?></td>
						<td><?php echo $array[14]; ?></td>
						<td><?php echo $array[15]; ?></td>
					</tr>
					<tr>
						<td>Maths</td>
						<td><?php echo $array[16]; ?></td>
						<td><?php echo $array[17]; ?></td>
						<td><?php echo $array[18]; ?></td>
						<td><?php echo $array[19]; ?></td>
						<td><?php echo $array[20]; ?></td>
					</tr>
					<tr>
						<td>EVS</td>
						<td><?php echo $array[21]; ?></td>
						<td><?php echo $array[22]; ?></td>
						<td><?php echo $array[23]; ?></td>
						<td><?php echo $array[24]; ?></td>
						<td><?php echo $array[25]; ?></td>
					</tr>
				</tbody>
			</table>

			<!-- Summary -->
			<div class="summary">
				<div>
					Attendance :
					<strong>
						<?= ($array[26] ?? '') ?> / <?= ($array[27] ?? '') ?>
					</strong>
				</div>
				<div>
					Total Marks :
					<strong>
						<?= ($array[28] ?? '') ?> / 500
					</strong>
				</div>
				<div>
					Percentage :
					<strong>
						<?= isset($array[29]) ? number_format((float)$array[29], 2) . '%' : '' ?>
					</strong>
				</div>
				<div>
					Grade :
					<strong>
						<?= ($array[30] ?? '') ?>
					</strong>
				</div>
			</div>

			<!-- Grade Subjects -->
			<div class="bottom-section">
				<div class="box">
					<div class="table-title">
						Grade Subjects Areas (on a 3 point grade scale)
					</div>
					<table>
						<tr>
							<th>Subjects</th>
							<th>Grade</th>
						</tr>
						<tr>
							<td>GK</td>
							<td><?php echo $array[31]; ?></td>
						</tr>
						<tr>
							<td>ICT</td>
							<td><?php echo $array[32]; ?></td>
						</tr>
						<tr>
							<td>Sports</td>
							<td><?php echo $array[33]; ?></td>
						</tr>
					</table>
				</div>

				<div class="box">
					<div class="table-title">
						Skill Subjects Areas (on a 3 point grade scale)
					</div>
					<table>
						<tr>
							<b>
								<th>Subjects</th>
								<th>Grade</th>
							</b>
						</tr>
						<tr>
							<td>Art</td>
							<td><?php echo $array[34]; ?></td>
						</tr>
						<tr>
							<td>Speaking Skills</td>
							<td><?php echo $array[35]; ?></td>
						</tr>
						<tr>
							<td>Overall Conduct</td>
							<td><?php echo $array[36]; ?></td>
						</tr>
					</table>
				</div>
			</div>

			<!-- Grade Scale -->
			<div class="grade-scale">
				<div class="table-title">
					Grade Scale For Scholastic Areas(Grades are
					awarded on 7 Point Grade Scale As Follows):
				</div>
				<table>
					<tr>
						<th>Marks Range (%)</th>
						<td>91-100</td>
						<td>81-90</td>
						<td>71-80</td>
						<td>61-70</td>
						<td>51-60</td>
						<td>41-50</td>
						<td>33-40</td>
						<td>0-32</td>
					</tr>
					<tr>
						<th>Grade</th>
						<td>A1</td>
						<td>A2</td>
						<td>B1</td>
						<td>B2</td>
						<td>C1</td>
						<td>C2</td>
						<td>D</td>
						<td>E</td>
					</tr>
				</table>
			</div>

			<!-- Remarks -->
			<div class="remarks">
				<strong>Remarks:</strong> <?php echo $array[37]; ?>
			</div>

			<!-- Signatures -->
			<div class="signatures">
				<div>Parent Signature</div>
				<div>Teacher Signature</div>
				<div>Principal Signature</div>
			</div>

		</div>

	</body>

	</html>
<?php
}
?>