<?php require "_header.php"; ?>

<script language="javascript" type="text/javascript">
	document.getElementById("main-content").style.display = 'none';
</script>
<style type="text/css">
	.table-report {
		font-family: Verdana, Geneva, sans-serif;
		font-size: 12px;
		text-align: left;
		border-right: 0px none;
		border-bottom: 0px none;

	}

	.table-report-inner {
		font-family: Verdana, Geneva, sans-serif;
		font-size: 12px;
	}

	.table-report tr {
		padding: 2px 2px 2px 2px;
		border: none;
	}

	.table-report td {
		padding: 2px 2px 2px 2px;
		border-top: 0px none;
		border-left: 0px none;
		border: none;
	}

	.table-report th {
		padding: 2px 2px 2px 2px;
		background-color: #eee;
		font-weight: bold;
		text-align: left;
		border: none;
		border-top: 0px none;
		border-left: 0px none;
		border: none;
	}

	.college_name {
		font-family: QTAbbie;
		font-size: 24px;
		font-weight: bold;
		padding: 2px 2px 2px 2px;
		text-align: center;
		border: none;
	}

	.college_address {
		font-family: Tahoma, Geneva, sans-serif;

		font-color: #3e4095;
		text-align: center;
		padding: 2px 2px 2px 2px;
		border: none;
	}

	span.highlight {
		background-color: #6495ED;
	}
</style>
<div id="main-report">
	<?php

	if ($_REQUEST['student_gturegno'] == "" && $_REQUEST['branch_hidden'] == "" && $_REQUEST['student_hidden'] == "") {

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

		if ($_REQUEST['student_gturegno'] != "") {
			$sql_studentdata = "SELECT sd.student_id,cur_branchid,batch_id,cur_semesterid,cur_branchyearid,sd.year_id FROM `cms_studentmaster` sm,cms_studentdetail sd where sm.student_id=sd.student_id and sm.student_gturegno='" . Escape($_REQUEST['student_gturegno']) . "' order by sd.year_id";
			$res_studentdata = dbQuery($sql_studentdata);
		} else {
			$sql_studentdata = "SELECT sd.student_id,cur_branchid,batch_id,cur_semesterid,cur_branchyearid,sd.year_id FROM `cms_studentmaster` sm,cms_studentdetail sd where sm.student_id=sd.student_id and sm.student_id='" . Escape($_REQUEST['student_hidden']) . "' order by sd.year_id";
			$res_studentdata = dbQuery($sql_studentdata);

		}
		if (dbRows($res_studentdata) > 0) { ?>

			<?php
			$studentprofileflag = 0;
			while ($rec_studentdata = dbArray($res_studentdata)) {
				//echo "<pre>";print_r($rec_studentdata);exit;
				$branch_id = $rec_studentdata['cur_branchid'];
				$year_id = $rec_studentdata['year_id'];
				$branchyear_id = $rec_studentdata['cur_branchyearid'];
				$semester_id = $rec_studentdata['cur_semesterid'];
				$batch_id = $rec_studentdata['batch_id'];


				$gturegno = Escape($_REQUEST['student_gturegno']);
				$stuid = Escape($_REQUEST['student_hidden']);



				$order_by = 'student_gturegno';
				$condition = "";

				/*	$SQL_STUDENT = "
														 SELECT
															 sm.student_photo,
															 sm.student_id,
															 sd.cur_semesterid,
															 sd.cur_branchid,
															 sd.cur_branchyearid,
															 sd.year_id,
															 student_admdate,
															 CONCAT(student_surname,' ',student_firstname,' ',SUBSTR(student_lastname,1,1),'.') AS student_name,
															 
															 student_emailid,
															 student_birthdate,
															 student_gturegno,
															 SUBSTR(student_gender,1,1) AS student_gender,
															 student_mobilestudents,
															 student_mobileparents,
															 
															 sm.student_admby,
															 sm.tfw_scheme ,
															 sd.batch_id,
															 sm.leave_type,
															 (SELECT branch_name 
																 FROM cms_branchmaster sec 
																 WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
															   (SELECT year_name 
																 FROM cms_yearmaster ym 
																 WHERE ym.year_id=sd.year_id) AS year_name,
															   (SELECT branchyear_name 
																 FROM cms_branchyear bry 
																 WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
															   (SELECT semester_name
																	 FROM cms_semestermaster sem 
																  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name
															 
														 FROM
															 cms_studentmaster sm,
															 cms_studentdetail sd
															 
														 WHERE  
															 sm.student_id = sd.student_id";*/



				if ($branch_id != "" && $branch_id != "All") {
					$condition .= " AND sd.cur_branchid = " . $branch_id;
				}
				if ($year_id != "" && $year_id != "undefined") {
					$condition .= " AND sd.year_id = " . $year_id;
				}
				if ($branchyear_id != "" && $branchyear_id != "undefined") {
					$condition .= " AND sd.cur_branchyearid = " . $branchyear_id;
				}
				if ($semester_id != "" && $semester_id != "undefined") {
					$condition .= " AND sd.cur_semesterid = " . $semester_id;
				}


				if ($gturegno != "") {
					$condition .= " AND sm.student_gturegno = '" . $gturegno . "' ";
				}

				if ($stuid != "") {
					$condition .= " AND sm.student_id = '" . $stuid . "' ";
				}

				$condition .= " ORDER BY sd.cur_branchid ASC ";

				if ($order_by != "" && $order_by != "undefined") {
					$condition .= "," . $order_by . " ASC ";
				} else {
					$condition .= " ,student_gturegno ASC ";
				}



				$objStudent = new StudentMgmt();
				$RES_STUDENT = $objStudent->getAllStudentbonafied($limit, $start, $condition, $order_field, $order_type);

				if (dbRows($RES_STUDENT) > 0) { ?>

					<?php

					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						extract($REC_STUDENT);

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

						<?php if ($studentprofileflag == 0) {
							$studentprofileflag = 1;
							?>


							<table class="table-report" frame="box" border="0" cellpadding="0" cellspacing="0" width="100%"
								style="border: 8px solid black; border-style: outset;">
								<tr style="vertical-align: middle;">
									<td colspan="6" style="border: 1px solid; padding: 5px; text-align: center;">
										<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>
								</tr>
								<tr height="30px">

									<td>
										<font size="3px">Date: <?php echo date("d/m/Y"); ?></font>
									</td>
								</tr>
								<tr>
									<td width="85%" style="padding-left:425px;">
										<font size="5px"></br><u><span style="background-color: #4AB2F2;">Bonafied certificate</span><u></u>
										</font>
									</td>
									<td>
										<img style="padding-top:25px;" src="<?php echo $imgfile; ?>" width="105" height="105" alt="" />
										</br></br></br>
									</td>
								</tr>

								<tr>
									<td colspan="4">
										<font size="4px"><i>
												<p style=" line-height: 150%;">This is to certifiy that Mr./Mrs.
													<b><?php echo $REC_STUDENT['student_name']; ?></b>
													Enrollment No. <b><?php echo $REC_STUDENT['student_gturegno']; ?></b> Studying in
													<b><?php if ($REC_STUDENT['branchyear_name'] != "") {
														echo $REC_STUDENT['branchyear_name'];
													}
													if ($REC_STUDENT['semester_name'] != "") {?></b>
													Semester <b><?php
														echo $REC_STUDENT['semester_name'];
													}
													?></b>
													of <?php echo $REC_STUDENT['branch_name']; ?> - <?php echo $REC_STUDENT['year_name']; ?>
													Engineering is bonafied student of this
													institute.</br></br>
													To the best of my Knowledge, he / she bears a good moral
													character.
												</p>
											</i>
											<font size="5px">
									</td>
								</tr>

								<tr height="90px">
									<td colspan="4" align="right">
										<font size="3"><i>Principal Signature &nbsp;&nbsp;</i></font>
									</td>

								</tr>

							</table>
							</table>

						<?php } ?>

						<?php
					}

				} else {
					echo "";
				} ?>
				<?php
			}
		}
		?>

		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$header_row_string = "";
		$HtmlUrl = "student-overall-report.html";
		$HtmlPath = "report/" . $HtmlUrl;
		createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, false);
		?>
		<br />
		<form name="frm" id="frm" action="" method="post">
			<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl; ?>" />
			<input type="button" name="btnPrint" id="btnPrint" 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.frm.action = "print/create-print.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "PDF") {
					document.frm.action = "convertpdf/create-pdf.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "HTML") {
					document.frm.action = "<?php echo $HtmlPath; ?>";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "WORD") {
					document.frm.action = "convertword/create-word.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "Excel") {
					document.frm.action = "convertword/create-excel.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
			}
		</script>
	<?php } ?>
	<?php
	require "_footer.php";
	?>