<?php ob_start();
session_start();
ini_set('display_errors', 0);
error_reporting(0);  // to keep error warning off replace E_ALL on 0
require_once('../classes/classes.php');
$crud = new CRUD();
require_once('../includes/configuration.php');
require_once('../classes/Hijri_GregorianConvert.php'); ?>
<?php $hijri = new Hijri_GregorianConvert(); ?>
<?php
$format = "DD/MM/YYYY";
$date = date("d/m/Y");
$promotionDt = "";
$dateEd = "";
$yearHijri = $hijri->GregorianToHijri($date, $format);
$HijriYr = explode('-', $yearHijri); //we have added one year to this because it will be considered as the end of admission year
$dateAdmitionAry = explode('-', $yearHijri);
//$dateAdmition = $dateAdmitionAry[2].'-'.$dateAdmitionAry[1].'-'.$dateAdmitionAry[0];
$dateAdmition = $dateAdmitionAry[2] . '-10-15';
if (isset($_SESSION['hijri'])) {
	$dt = new DateTime($_SESSION['hijri']);
	$promotionDt = $dt->format('Y-m-d');
	$y = explode("-", $promotionDt);
	$y = $y[0] + 1;
	$dateEd = $dt->format($y . '-m-d');
}
?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>تفصیلی رپورٹ رجسٹرڈ طلباء- </title>
	<link rel="stylesheet" type="text/css" href="../css/default.css" />
	<script type="text/javascript" src="../js/functions.js"></script>
	<script language="javascript" type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/jquery.datepick.js"></script>
	<style type="text/css">
		@import "../js/jquery.datepick.css";
	</style>
	<script type="text/javascript">
		$(function () {
			$('#admissionYear').datepick();
		});
		$(document).ready(function () {
			$("#hide").click(function () {
				$("#searchPanel").slideUp(1000);
			});
		});
		$(document).ready(function () {
			$("body").dblclick(function () {
				$("#searchPanel").slideDown(1000);
			});
		});
		$(document).ready(function () {
			$("#print").click(function () {
				Print("printerArea");
			});
		});
	</script>
	<script type="text/javascript" language="javascript">
		var snd;
		var year, snoDarja, opt;
		/*$(function(){
			 $('input:radio[name=opt]').click(function(){
				if($('input:radio[name=opt]:checked').val() == 1){
					opt = 1;
					}
				if($('input:radio[name=opt]:checked').val() == 2){
					opt = 2;
					}
				 });
			 });
		*/

		$(document).ready(function () {
			$("#showRpt").click(function () {
				var yearValue = $("#admissionYear").val();
				var darjaValue = $("#darja").val();
				var optValue = $('input[name=opt]:checked').val();

				if (!yearValue || !darjaValue || optValue === undefined) {
					alert('مہربانی کر کے داخلہ سال اور درجہ مہیّا کریں۔');
					return;
				}

				$("#printerArea").html('<div style="text-align:center; padding:50px;"><img src="../images/loading/loader.gif" alt="Loading..." /><p>رپورٹ تیار کی جا رہی ہے، براہ کرم انتظار کریں...</p></div>');
				document.title = 'Please Wait ...';

				$.ajax({
					type: "POST",
					url: "../AjaxPhp/admissionRegisterList.php",
					data: {
						snoDarja: darjaValue,
						year: yearValue,
						opt: optValue,
						rnd: Math.random()
					},
					success: function (response) {
						$("#printerArea").html(response);
						document.title = 'تفصیلی رپورٹ رجسٹرڈ طلباء-';
						if (typeof getDarjaLbl === 'function') {
							getDarjaLbl(darjaValue, "darjaLbl", "../AjaxPhp/getDarjaLabBySno.php");
						}
					},
					error: function () {
						$("#printerArea").html('<div class="error-msg">رپورٹ لوڈ کرنے میں غلطی ہوئی ہے۔ براہ کرم دوبارہ کوشش کریں۔</div>');
						document.title = 'Error Loading Report';
					}
				});
			});

			$("#hide").click(function () { $("#searchPanel").slideUp(500); });
			$("#show").click(function () { $("#searchPanel").slideDown(500); });
			$("body").dblclick(function () { $("#searchPanel").slideDown(500); });
			$("#print").click(function () { Print("printerArea"); });
		});


	</script>
</head>

<body style="font-family:'Jameel Noori Nastaleeq'; background-image:none; background-color:#ffffff;">
	<style>
		.search-panel-container {
			background: #fdfdfd;
			border-radius: 12px;
			box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
			padding: 25px;
			margin: 20px auto;
			width: 1140px;
			border: 1px solid #e0e0e0;
		}

		.search-grid {
			display: grid;
			grid-template-columns: 1fr 1fr 1fr 1fr;
			gap: 20px;
			align-items: end;
		}

		.form-group {
			text-align: right;
		}

		.form-group label {
			display: block;
			margin-bottom: 8px;
			font-weight: bold;
			color: #444;
			font-size: 16px;
		}

		.custom-select,
		.custom-input {
			width: 100%;
			padding: 10px;
			border-radius: 8px;
			border: 1px solid #ccc;
			font-family: inherit;
			font-size: 15px;
		}

		.radio-group {
			display: flex;
			gap: 15px;
			justify-content: center;
			padding: 10px 0;
		}

		.btn-primary-custom {
			background: #2c3e50;
			color: #fff;
			border: none;
			padding: 12px 25px;
			border-radius: 8px;
			cursor: pointer;
			font-size: 18px;
			font-weight: bold;
			transition: background 0.3s;
		}

		.btn-primary-custom:hover {
			background: #34495e;
		}

		.action-icons {
			display: flex;
			justify-content: center;
			gap: 30px;
			margin-top: 20px;
			border-top: 1px solid #eee;
			padding-top: 15px;
		}

		.action-icons img {
			width: 32px;
			transition: transform 0.2s;
		}

		.action-icons img:hover {
			transform: scale(1.1);
		}
	</style>

	<div class="search-panel-container" id="searchPanel">
		<form id="searchForm" onsubmit="return false;">
			<div class="search-grid">
				<div class="form-group">
					<label>درجہ منتخب کریں</label>
					<?php
					$css = 'class="custom-select"';
					$crud->darjaatCmb('darja', '', $css);
					?>
				</div>
				<div class="form-group">
					<label>داخلہ سال</label>
					<input type="text" class="custom-input"
						value="<?php echo (!empty($_REQUEST['admissionYear']) ? htmlspecialchars($_REQUEST['admissionYear']) : $promotionDt); ?>"
						name="admissionYear" id="admissionYear" autocomplete="off" />
				</div>
				<div class="form-group">
					<div class="radio-group">
						<label style="display:inline; margin:0;">
							<input type="radio" name="opt" id="dakhil" checked="checked" value="1" /> داخل
						</label>
						<label style="display:inline; margin:0;">
							<input type="radio" name="opt" value="2" id="kharij" /> خارج
						</label>
					</div>
				</div>
				<div class="form-group">
					<button type="button" class="btn-primary-custom" id="showRpt">رپورٹ دکھائیں</button>
				</div>
			</div>

			<div class="action-icons">
				<a href="#" id="hide" title="سرچ پینل کو چھہائیں">
					<img src="../images/minus.png" alt="Hide" />
				</a>
				<a href="#" id="print" title="رپورٹ پرنٹ کریں">
					<img src="../images/print.png" alt="Print" />
				</a>
				<a href="#" id="show" title="سرج پینل کو کھولیں">
					<img src="../images/plus.png" alt="Show" />
				</a>
			</div>
		</form>
	</div>


	<div id="printerArea" style="width:1160px; background-color:#ffffff; min-height:550px;" title="رپورٹ">
		<table width="1160" align="right" border="1" cellspacing="0" cellpadding="4"
			style="padding-left:15px; border:0px;">
			<tr>
				<th colspan="10" class="titleFont" style="height:60px; text-align:center; font-size:40px;">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<th style="font-size:35px;">
								<?php echo (M_Name); ?><br />
								<font style="font-size:22px;">
									<?php echo (L_Address); ?>
								</font>
							</th>
							<th style="font-size:20px; font-family:'Aseer Unicode';"> رجسٹر داخل / خارج <br />
								تعلیمی درجہ /
							</th>
							<th style="font-size:18px;"> الحاق نمبر
								<?php echo (Elhaq); ?> <br /> رجسٹریشن نمبر
								<?php echo (Reg_Number); ?>
								<br /> تعلیمی سال
								<?php //echo($hijri->HijriToGregorian(date('d-m-Y'),"DD/MM/YYYY")); ?>
							</th>
						</tr>
					</table>
				</th>
			</tr>
			<tr>
				<td width="40"> الرقم </td>
				<td width="60"> اسم الطالب </td>
				<td width="70">اسم الوالد</td>
				<td width="84"> تاریخ المیلاد</td>
				<td width="85" colspan="2"> شناختی کارڈ نمبر / فارم ب</td>
				<td width="80"> اسم الضامن</td>
				<td width="171">العنوان الدائم</td>
				<td width="139"> العنوان</td>
				<td width="95"> الرقم الھاتف</td>
			</tr>
			<tr>
				<td colspan="10">
					<span id="data"></span>
				</td>
			</tr>
		</table>
		<br />
	</div>
</body>

</html>
<?php ob_flush(); ?>