<?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;
	}

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

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

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

	.college_address {
		font-family: Tahoma, Geneva, sans-serif;
		font-size: 11px;
		text-align: center;
		padding: 2px 2px 2px 2px;
	}
</style>
<div id="main-report">
	<?php
	if ($_REQUEST['branch_hidden'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-student-summary.php';
		</script>
		<?php
	} elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
		ob_start();
		$branch_id = Escape($_REQUEST['branch_hidden']);
		$branchyear_id = Escape($_REQUEST['branchyear_hidden']);
		$year_id = Escape($_REQUEST['year_hidden']);
		$semester_id = Escape($_REQUEST['semester_hidden']);
		$order_by = $_REQUEST['hid_orderby'];
		$branch_name = Escape($_REQUEST['branch_disp']);
		$year_name = Escape($_REQUEST['year_disp']);
		$branchyear_name = Escape($_REQUEST['branchyear_disp']);
		$semester_name = Escape($_REQUEST['semester_disp']);
		/*$SQL_STUDENT = "SELECT 
						  student_gender,
						  count(student_gender)as count,
						  sm.student_admby,
						  COUNT(sm.student_admby) AS count,
						  student_category,
						  count(student_category)as count,
						  tfw_scheme,
						  count(tfw_scheme)as count,
						  student_active ,
						  count(student_active)as count,
						  sd.cur_semesterid,
						  sd.cur_branchid,
						  sd.cur_branchyearid,
						  sd.year_id,
						  (SELECT branch_name FROM cms_branchmaster sec WHERE 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 semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
						  (SELECT branchyear_name FROM cms_branchyear bry 
							  WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
						  FROM
							  cms_studentmaster sm,
							  cms_studentdetail sd
						  WHERE 
							  sm.student_active = 1 AND 
							  sm.student_id = sd.student_id AND
							  sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  ";*/
		//$RES_STUDENT = dbQuery($SQL_STUDENT);
	
		$condition = "";

		if ($branch_id != "" && $branch_id != "All") {
			$condition .= " AND sd.cur_branchid = " . $branch_id;
		}
		if ($semester_id != "" && $semester_id != "undefined") {
			$condition .= " AND sd.cur_semesterid = " . $semester_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 ($order_by == "" || $order_by == 'gender') {
			$condition1 = "";
			$condition1 .= $condition;
			$condition1 .= " Group By student_gender ORDER BY sd.cur_branchid , sd.year_id,sd.cur_branchyearid,sd.cur_semesterid";

			$objStudentMgmt = new StudentMgmt();
			$RES_STUDENT = $objStudentMgmt->getstudentsummary($condition1);
			if (dbRows($RES_STUDENT) > 0) { ?>
				<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>
				<center>
					<h4>Student Gender Summary</h4>
				</center>
				<div align="left">
					<b>Course</b> :
					<?php echo $branch_name; ?>
				</div>
				<div align="right">
				<?php if ($year_id != "") { ?>
					<b>Batch Year</b>:
					<?php echo $year_name; ?>
					<?php } ?>
				</div>
				<div align="left">
					<?php if ($branchyear_id != "") { ?>
						<b>Course Name</b>:
						<?php echo $branchyear_name; ?>
					</div>
					<div align="left">
					<?php }
					if ($semester_id != "") { ?>
						<b>Semester</b>:
						<?php echo $semester_name;
					} ?>
				</div><br />

				<table class="table-report" border="1" cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<th style="text-align:center;" width="80%">Gender</th>
						<th style="text-align:center;" width="20%">Total</th>
					</tr>
					<?php
					$i = 1;
					$temp = "";
					$temp1 = "";
					$temp2 = "";
					$temp3 = "";
					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['year_name'] != $temp1) || ($REC_STUDENT['branchyear_name'] != $temp2) || ($REC_STUDENT['semester_name'] != $temp3)) {
							$temp = $REC_STUDENT['branch_name'];
							$temp1 = $REC_STUDENT['year_name'];
							$temp2 = $REC_STUDENT['branchyear_name'];
							$temp3 = $REC_STUDENT['semester_name'];
							$i = 1;
						} ?>
						<tr>
							<td style="text-align:center;" width="80%">&nbsp;<?php echo $REC_STUDENT['student_gender']; ?></td>
							<td style="text-align:center;" width="20%">&nbsp;<?php echo $REC_STUDENT['count']; ?></td>
						</tr><?php
						if ($REC_STUDENT['student_gender'] != '') {
							$total += $REC_STUDENT['count'];
						}
					}
					?>
					<tr>
						<th style="text-align:right;">Total</th>
						<td style="text-align:center;" width="20%">&nbsp;<?php echo $total; ?></td>
					</tr>
				</table>
				<br />
				<div class="break">&nbsp;</div>
				<?php
			} else {
				echo "NO DATA FOUND!";
			}
		}
		if ($order_by == "" || $order_by == 'addmission') {

			$condition2 = "";
			$condition2 .= $condition;
			$condition2 .= " GROUP BY sm.student_admby ORDER BY sd.cur_branchid, sd.year_id, sd.cur_branchyearid, sd.cur_semesterid";

			$RES_STUDENT = $objStudentMgmt->getstudentsummary($condition2);
			if (dbRows($RES_STUDENT) > 0) { ?>
				<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>
				<center>
					<h4>Student Addmission Type Summary</h4>
				</center>
				<div align="left">
					<b>Course</b> :
					<?php echo $branch_name; ?>
				</div>
				<div align="right">
				<?php if ($year_id != "") { ?>
					<b>Batch Year</b>:
					<?php echo $year_name; ?>
					<?php } ?>
				</div>
				<div align="left">
					<?php if ($branchyear_id != "") { ?>
						<b>Course Name</b>:
						<?php echo $branchyear_name; ?>
					</div>
					<div align="left">
					<?php }
					if ($semester_id != "") { ?>
						<b>Semester</b>:
						<?php echo $semester_name;
					} ?>
				</div><br />
				<table class="table-report" border="1" cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<th style="text-align:center;" width="80%">Addmission Type</th>
						<th style="text-align:center;" width="20%">Total</th>
					</tr>
					<?php
					$i = 1;
					$temp = "";
					$temp1 = "";
					$temp2 = "";
					$temp3 = "";
					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['year_name'] != $temp1) || ($REC_STUDENT['branchyear_name'] != $temp2) || ($REC_STUDENT['semester_name'] != $temp3)) {
							$temp = $REC_STUDENT['branch_name'];
							$temp1 = $REC_STUDENT['year_name'];
							$temp2 = $REC_STUDENT['branchyear_name'];
							$temp3 = $REC_STUDENT['semester_name'];
							$i = 1;
						} ?>
						<tr>
							<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_admby']; ?></td>
							<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['count']; ?></td>
						</tr><?php
						if ($REC_STUDENT['student_admby'] != '') {
							$ACPDC += $REC_STUDENT['count'];
						}
					}
					?>
					<tr>
						<th style=" text-align: right;">Total</th>
						<td style="text-align:center;">&nbsp;<?php echo $ACPDC; ?></td>
					</tr>
				</table>
				<br />
				<div class="break">&nbsp;</div>
				<?php
			} else {
				echo "NO DATA FOUND!";
			}
		}
		if ($order_by == "" || $order_by == 'categary') {

			$condition3 = "";
			$condition3 .= $condition;
			$condition3 .= " GROUP BY sm.student_category ORDER BY sd.cur_branchid, sd.year_id, sd.cur_branchyearid, sd.cur_semesterid";

			$objStudentMgmt = new StudentMgmt();
			$RES_STUDENT = $objStudentMgmt->getstudentsummary($condition3);
			if (dbRows($RES_STUDENT) > 0) { ?>
				
				<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>
				<center>
					<h4>Student Categary Summary</h4>
				</center>
				<div align="left">
					<b>Course</b> :
					<?php echo $branch_name; ?>
				</div>
				<div align="right">
				<?php if ($year_id != "") { ?>
					<b>Batch Year</b>:
					<?php echo $year_name; ?>
					<?php } ?>
				</div>
				<div align="left">
					<?php if ($branchyear_id != "") { ?>
						<b>Course Name</b>:
						<?php echo $branchyear_name; ?>
					</div>
					<div align="left">
					<?php }
					if ($semester_id != "") { ?>
						<b>Semester</b>:
						<?php echo $semester_name;
					} ?>
				</div><br />

				<table class="table-report" border="1" cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<th style="text-align:center;" width="80%">Categary</th>
						<th style="text-align:center;" width="20%">Total</th>
					</tr>
					<?php
					$i = 1;
					$temp = "";
					$temp1 = "";
					$temp2 = "";
					$temp3 = "";
					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['year_name'] != $temp1) || ($REC_STUDENT['branchyear_name'] != $temp2) || ($REC_STUDENT['semester_name'] != $temp3)) {
							$temp = $REC_STUDENT['branch_name'];
							$temp1 = $REC_STUDENT['year_name'];
							$temp2 = $REC_STUDENT['branchyear_name'];
							$temp3 = $REC_STUDENT['semester_name'];
							$i = 1;
						} ?>
						<tr>
							<td style="text-align:center;">
								&nbsp;<?php echo $REC_STUDENT['student_category'] == "" ? "Not Added" : $REC_STUDENT['student_category']; ?>
							</td>
							<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['count']; ?></td>
						</tr><?php
						if ($REC_STUDENT['student_category'] != '') {
							$no += $REC_STUDENT['count'];
						}
					}
					?>
					<tr>
						<th style="text-align:right;">Total</th>
						<td style="text-align:center;">&nbsp;<?php echo $no; ?></td>
					</tr>
				</table>
				<br />
				<div class="break">&nbsp;</div>
				<?php
			} else {
				echo "NO DATA FOUND!";
			}
		}
		if ($order_by == "" || $order_by == 'tfws') {

			$condition4 = "";
			$condition4 .= $condition;
			$condition4 .= " GROUP BY sm.tfw_scheme   ORDER BY sd.cur_branchid, sd.year_id, sd.cur_branchyearid, sd.cur_semesterid";
			$objStudentMgmt = new StudentMgmt();
			$RES_STUDENT = $objStudentMgmt->getstudentsummary($condition4);
			if (dbRows($RES_STUDENT) > 0) { ?>
				<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>
				<center>
					<h4>Student TFWS Summary</h4>
				</center>
				<div align="left">
					<b>Course</b> :
					<?php echo $branch_name; ?>
				</div>
				<div align="right">
				<?php if ($year_id != "") { ?>
					<b>Batch Year</b>:
					<?php echo $year_name; ?>
					<?php } ?>
				</div>
				<div align="left">
					<?php if ($branchyear_id != "") { ?>
						<b>Course Name</b>:
						<?php echo $branchyear_name; ?>
					</div>
					<div align="left">
					<?php }
					if ($semester_id != "") { ?>
						<b>Semester</b>:
						<?php echo $semester_name;
					} ?>
				</div><br />

				<table class="table-report" border="1" cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<th style="text-align:center;" width="80%">TFWS</th>
						<th style="text-align:center;" width="20%">Total</th>
					</tr>
					<?php
					$i = 1;
					$temp = "";
					$temp1 = "";
					$temp2 = "";
					$temp3 = "";
					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['year_name'] != $temp1) || ($REC_STUDENT['branchyear_name'] != $temp2) || ($REC_STUDENT['semester_name'] != $temp3)) {
							$temp = $REC_STUDENT['branch_name'];
							$temp1 = $REC_STUDENT['year_name'];
							$temp2 = $REC_STUDENT['branchyear_name'];
							$temp3 = $REC_STUDENT['semester_name'];
							$i = 1;
						} ?>
						<tr>
							<td style="text-align:center;">&nbsp;<?php

							if ($REC_STUDENT['tfw_scheme'] == 0) {
								echo "Not In TFW";
								$No += $REC_STUDENT['count'];
							} elseif ($REC_STUDENT['tfw_scheme'] == 1) {
								echo "In TFW";
								$Yes += $REC_STUDENT['count'];
							}
							?></td>
							<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['count']; ?></td>
						</tr><?php
					}
					?>
					<tr>
						<th colspan="2">Total</th>
					</tr>
					<tr>
						<td style="text-align:center;">&nbsp;Not In TFW</td>
						<td style="text-align:center;">&nbsp;<?php echo $No; ?></td>
					</tr>
					<tr>
						<td style="text-align:center;">&nbsp;In TFW</td>
						<td style="text-align:center;">&nbsp;<?php echo $Yes; ?></td>
					</tr>
				</table>
				<br />
				<div class="break">&nbsp;</div>
				<?php
			} else {
				echo "NO DATA FOUND!";
			}
		}
		if ($order_by == "" || $order_by == 'status') {

			$condition5 = "";
			$condition5 .= $condition;
			$condition5 .= " GROUP BY sm.student_active ORDER BY sd.cur_branchid, sd.year_id, sd.cur_branchyearid, sd.cur_semesterid";
			$objStudentMgmt = new StudentMgmt();
			$RES_STUDENT = $objStudentMgmt->getstudentactivesummary($condition5);
			if (dbRows($RES_STUDENT) > 0) { ?>
				<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>
				<center>
					<h4>Student Status Summary</h4>
				</center>
				<div align="left">
					<b>Course</b> :
					<?php echo $branch_name; ?>
				</div>
				<div align="right">
				<?php if ($year_id != "") { ?>
					<b>Batch Year</b>:
					<?php echo $year_name; ?>
					<?php } ?>
				</div>
				<div align="left">
					<?php if ($branchyear_id != "") { ?>
						<b>Course Name</b>:
						<?php echo $branchyear_name; ?>
				</div>
					<div align="left">
					<?php }
					if ($semester_id != "") { ?>
						<b>Semester</b>:
						<?php echo $semester_name;
					} ?>
				</div><br />
				<table class="table-report" border="1" cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<th style="text-align:center;" width="80%">Status</th>
						<th style="text-align:center;" width="20%">Total</th>
					</tr>
					<?php
					$i = 1;
					$temp = "";
					$temp1 = "";
					$temp2 = "";
					$temp3 = "";
					while ($REC_STUDENT = dbArray($RES_STUDENT)) {
						if (($REC_STUDENT['branch_name'] != $temp) || ($REC_STUDENT['year_name'] != $temp1) || ($REC_STUDENT['branchyear_name'] != $temp2) || ($REC_STUDENT['semester_name'] != $temp3)) {
							$temp = $REC_STUDENT['branch_name'];
							$temp1 = $REC_STUDENT['year_name'];
							$temp2 = $REC_STUDENT['branchyear_name'];
							$temp3 = $REC_STUDENT['semester_name'];
							$i = 1;
						} ?>
						<tr>
							<td style="text-align:center;">&nbsp;<?php
							if ($REC_STUDENT['student_active'] == 0) {
								echo "Not Active";
								$NoActive += $REC_STUDENT['count'];
							} elseif ($REC_STUDENT['student_active'] == 1) {
								echo "Active";
								$Active += $REC_STUDENT['count'];
							}
							?></td>
							<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['count']; ?></td>
						</tr>
						<?php
					}
					?>
					<tr>
						<th colspan="2">Total</th>
					</tr>
					<tr>
						<td style="text-align:center;">&nbsp;Not Active</td>
						<td style="text-align:center;">&nbsp;<?php echo $NoActive; ?></td>
					</tr>
					<tr>
						<td style="text-align:center;">&nbsp;Active</td>
						<td style="text-align:center;">&nbsp;<?php echo $Active; ?></td>
					</tr>
				</table>
				<br /><br /><br />
				<div class="break">&nbsp;</div>
				<?php
			} else {
				echo "NO DATA FOUND!";
			}
		}
		?>
		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$header_row_string = "";
		$HtmlUrl = "studentlist-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>
		<br /><br />
		<br /><br />
		<br /><br />
		<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 } ?>
</div>
<?php require "_footer.php"; ?>