<?php require "_header.php"; ?>
<script language="javascript" type="text/javascript">
</script>
<style type="text/css">
	body {
		font-family: Arial, sans-serif;
	}

	.id-card {
		width: 85%;
		border: 1px solid #ccc;
		border-radius: 10px;
		overflow: hidden;
		margin: 20px auto;
		background-size: cover;
		background-repeat: no-repeat;
	}

	.id-card table {
		width: 100%;
	}

	.id-card img {
		width: 100%;
		height: 100%;
		display: block;
	}

	.id-card th,
	.id-card td {
		padding: 10px;
		text-align: left;
	}

	.container {
		width: 95%;
		margin: 0 auto;
	}

	.id-card .photo {
		width: 150px;
		height: 150px;
		vertical-align: top;
	}

	.id-card .info {
		padding-left: 10px;
	}

	table.i-card {
		margin-top: 270px;
		/* Adjust based on layout */
	}

	th {
		color: rgb(6, 106, 96);
		font-size: 22px;
		font-weight: 600;
	}

	td {
		font-weight: 600;
		font-size: 22px;
	}

	.college_name {
		font-family: QTAbbie;
		font-size: 24px;
		font-weight: bold;
		padding: 1px 1px 1px 1px;
		text-align: center;
		vertical-align: top;
	}

	.college_address {
		font-family: Tahoma, Geneva, sans-serif;
		font-size: 11px;
		text-align: center;
		padding: 1px 1px 1px 1px;
		vertical-align: top;
	}

	@media print {
		.page-break {
			page-break-before: always;
			page-break-inside: avoid;
			page-break-after: auto;
			height: 0;
		}
	}
</style>
<div id="main-report">

	<center>
		<h4>Student Identity Card</h4>
	</center>
	<?php

	if ($_REQUEST['branch_id'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-form-student-icard.php';
		</script>
		<?php
	} elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {

		$StudentList = Escape($_REQUEST['studentlist_left']);
		$branch_id = Escape($_REQUEST['branch_hidden']);
		$year_id = Escape($_REQUEST['year_hidden']);
		$branchyear_id = Escape($_REQUEST['branchyear_hidden']);
		$semester_id = Escape($_REQUEST['semester_hidden']);
		$student_gturegno = Escape($_REQUEST['student_gturegno']);

		$limit = 0;
		$start = 0;
		$condition = "";
		$order_field = "";
		$order_type = "";


		if ($StudentList != '') {
			$condition .= " and sm.student_id in ($StudentList)";

		}
		$objStudent = new StudentMgmt();
		$outStudent = $objStudent->getAllStudentRecordsicard($limit, $start, $condition, $order_field, $order_type);

		$qry_college = dbQuery("SELECT * FROM cms_collegemaster WHERE college_id= '" . $_SESSION["VedantnrCollegeId"] . "' ");
		$qry_college_res = dbArray($qry_college);

		if (dbRows($outStudent)) {
			ob_start();
			?>
			<section class="portal-result">
				<div class="container">
					<?php
					while ($row = dbArray($outStudent)) {
						extract($row);

						if ($student_photo != "") {
							$imgfile = $SiteBaseUrl . $StudentImagePath . $student_id . "/" . $student_photo;
						} else {
							$imgfile = $SiteBaseUrl . $StudentImagePath . "default.gif";
						}


						?>
						<div class="id-card">
							<table>
								<img src="<?php echo $SiteBaseUrl . $CollegeImagePath . $_SESSION["VedantnrCollegeLogo"]; ?>"
									alt="College Logo" style="width: 80px; height: auto; float: left; margin-right: 10px;">
								<div style="display: inline-block; vertical-align: middle;">
									<b style="font-size: 30px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
									<?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
									Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>&nbsp;&nbsp;
									Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
								</div>
								<td rowspan="5" class="photo">
									<img src="<?php echo $imgfile; ?>" alt="">
								</td>
								<th style="width: 25%;">Name</th>
								<td style="width: 5px;">:</td>
								<td>
									<?php
									$a = $student_surname . " " . $student_firstname . " " . substr($student_lastname, 0, 1) . ".";
									$b = preg_replace_callback('~\b(\w)(\w+)~', function ($matches) {
										return $matches[1] . strtolower($matches[2]);
									}, $a);
									print $b;
									?>
								</td>

								<tr>
									<th>Address</th>
									<td style="width: 5px;">:</td>
									<td>

										<?php
										if (
											$student_addressat != "" && $student_addresspost != "" && $taluko_nameeng != "" && $dist_nameeng != "" && $state_nameeng != "" &&
											$student_pincode
										) {
											echo "$student_addressat ,  $student_addresspost, $taluko_nameeng , 
									  $dist_nameeng,  $state_nameeng , 
									  $student_pincode ";
										} else {
											echo "";
										}

										?>
									</td>
								</tr>
								<tr>
									<th>Mobile No</th>
									<td style="width: 5px;">:</td>
									<td>
										<?php
										if ($student_mobilestudents != "" && $student_mobileparents != "") {
											echo $student_mobilestudents . ',' . $student_mobileparents;
										} elseif ($student_mobilestudents != "") {
											echo $student_mobilestudents;
										} elseif ($student_mobileparents != "") {
											echo $student_mobileparents;
										} else {
											echo "";
										}
										?>
									</td>
								</tr>
								<tr>
									<th>Class</th>
									<td style="width: 5px;">:</td>
									<td><?php echo $branch_name; ?></td>
								</tr>
								<tr>
									<th>Year</th>
									<td style="width: 5px;">:</td>
									<td><?php echo $year_name; ?></td>
								</tr>
								<?php
								$gtuo = $student_gturegno;
								$branchname = $branch_name;
								$yearname = $year_name;
								$barcode = $branchname . $yearname . $gtuo;
								?>
								<tr>
									<td height="49" colspan="5" style="border:none; padding-left: 5px; padding-top: 20px;"
										valign="top">
										<?php

										echo "<img src='$SiteBaseUrl/bc.php?barcode=" . $barcode . "&width=1080&height=78' alt='barcode' />";
										?>
									</td>
								</tr>
							</table>
						</div>
						<div class="page-break"></div>
						<?php
					}
					?>
				</div>
			</section>
			<?php
			$HtmlCode = ob_get_contents();
			ob_end_flush();

			$HtmlUrl = "student-identity-report-" . $_SESSION["VedantnrUserId"] . ".html";
			$HtmlPath = "report/" . $HtmlUrl;
			createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode);

			?>
			<br />
			<form name="frm1" id="frm1" action="" method="get">
				<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl; ?>" />

				<input type="button" name="btnPdf" id="btnPdf" value="Print" onClick="SetPageAction('PRINT');" />
				<input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');" />
				<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');" />
				<input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');" />
				<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');" />
			</form>
			<script language="javascript" type="text/javascript">
				function SetPageAction(varAction) {
					if (varAction == "PRINT") {
						document.frm1.action = "print/create-print.php";
						document.frm1.submit();
					}
					if (varAction == "PDF") {
						document.frm1.action = "convertpdf/create-pdf.php";
						document.frm1.target = "_blank";
						document.frm1.submit();
					} else if (varAction == "HTML") {
						document.frm1.action = "<?php echo $HtmlPath; ?>";
						document.frm1.target = "_blank";
						document.frm1.submit();
					} else if (varAction == "WORD") {
						document.frm1.action = "convertword/create-word.php";
						document.frm1.target = "_blank";
						document.frm1.submit();
					} else if (varAction == "Excel") {
						document.frm1.action = "convertword/create-excel.php";
						document.frm1.target = "_blank";
						document.frm1.submit();
					}
				}
			</script>
			<?php
		} else {
			echo "<b>No Data Found.</b>";
		}
	}
	?>
</div>
<?php require "_footer.php"; ?>