<?php require "_header.php"; ?>
<script language="javascript" type="text/javascript">
</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;
	}

	.break {
		page-break-before: always;
	}
</style>
<div id="main-report">
	<?php
	if ($_REQUEST['branch_hidden'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-student-list.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']);
		$gturegno_start = Escape($_REQUEST['gturegno_start']);
		$gturegno_end = Escape($_REQUEST['gturegno_end']);
		$gender = Escape($_REQUEST['gender']);
		$cast = Escape($_REQUEST['cast']);
		$AYEAR = Escape($_REQUEST['AYEAR']);
		$student_admby = Escape($_REQUEST['student_admby']);
		$feespaid = Escape($_REQUEST['feespaid']);
		$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_CONDITION = "";
		$SQL_STUDENT = "SELECT 
							  sm.student_id,
							  sd.cur_semesterid,
							  sd.cur_branchid,
							  sd.cur_branchyearid,
							  sd.year_id,
							  student_admdate,
							  CONCAT(student_surname,' ',student_firstname,' ',student_lastname,'') AS student_name,
							  student_gturegno,
							  SUBSTR(student_gender,1,1) AS student_gender,
							  student_mobileother,
							  student_fathermobile,
							  student_category,
							  sm.student_admby,
							  sd.student_rollno,
							  student_birthdate,
							  (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.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
								  AND sm.student_id=sd.student_id
								  AND sm.student_active= 1";*/
		//	$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 ($gender != "" && $gender != "undefined") {
			$condition .= " AND sm.student_gender = '" . $gender . "'";
		}

		if ($cast != "" && $cast != "undefined") {
			$condition .= " AND sm.student_category = '" . $cast . "'";
		}

		if ($AYEAR != "" && $AYEAR != "undefined") {
			$condition .= " AND YEAR(sm.student_admdate) = '" . $AYEAR . "'";
		}

		if ($admtype != "" && $admtype != "undefined") {
			if ($admtype == 'ACPDC-Certificate') {
				$condition .= " AND sm.student_admby = 'ACPDC' AND sm.student_techcerti != ''";
			} elseif ($admtype == 'Transfered Students') {
				$condition .= " AND sm.student_lastcollege != ''";
			} else {
				$condition .= " AND sm.student_admby = '" . $admtype . "'";
			}
		}

		if ($gturegno_start != "" && $gturegno_start != "Start From") {
			$condition .= " AND sm.student_gturegno >= '" . $gturegno_start . "' ";
		}
		if ($gturegno_end != "" && $gturegno_start != "End To") {
			$condition .= " AND sm.student_gturegno <= '" . $gturegno_end . "' ";
		}

		$condition .= " ORDER BY  sd.year_id,student_name ASC";

	
		$objStudentMgmt = new StudentMgmt();
		$RES_STUDENT = $objStudentMgmt->getstudentlist($condition);
		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 Detail Report</h4>
			</center>
			<div align="left">
				<b>Course</b> :
				<?php echo $branch_name; ?>
			</div>
			<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<th style="text-align:center;" width="5%">Sr</th>
					<th style="text-align:center;" width="5%">Roll No</th>
					<th style="text-align:center;" width="15%">Enrollment No</th>
					<th style="text-align:center;" width="10%">Student Mob.No</th>
					<th style="text-align:center;" width="10%">Parents Mob.No</th>
					<th style="text-align:left;" width="20%">Student Name</th>
					<th style="text-align:center;" width="5%">Fees Paid?</th>
					<th style="text-align:center;" width="10%">Category</th>
					<th style="text-align:center;" width="10%">Admission by</th>
					<th style="text-align:center;" width="10%">Gender</th>
					<th style="text-align:center;" width="10%">Birthdate</th>
					<th style="text-align:center;" width="30%">Remarks</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>
							<th colspan="12"><?php echo strtoupper($temp1); ?></th>
						</tr>
						<?php
					} ?>
					<tr>
						<?php $student_id = $REC_STUDENT['student_id'];
						$branch_id = $REC_STUDENT['cur_branchid'];
						$branchyear_id = $REC_STUDENT['cur_branchyearid'];
						$semester_id = $REC_STUDENT['cur_semesterid'];
						$condition1 = "";
						$condition1 .= " AND student_id = '" . $student_id . "' AND 
									branch_id = '" . $branch_id . "' AND
									branchyear_id= '" . $branchyear_id . "' AND
									semester_id = '" . $semester_id . "'";
						$objFees = new StudentFeesRecMgmt();
						if ($feespaid == 'Yes') {
							/*$sql_fees = "SELECT * FROM cms_feesreceivemaster WHERE 
																									student_id = '" . $student_id . "' AND 
																								   branch_id = '" . $branch_id . "' AND
																								   branchyear_id= '" . $branchyear_id . "' AND
																								   semester_id = '" . $semester_id . "'";
																						   $res_fees = dbQuery($sql_fees);*/
							$res_fees = $objFees->getstudentfees($condition1);
							if (dbRows($res_fees) > 0) {
								?>
								<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_rollno']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gturegno']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_mobileother']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_fathermobile']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_name']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo "Y"; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_category']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_admby']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gender']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo date('d-m-Y', strtotime($REC_STUDENT['student_birthdate'])); ?></td>
								<td></td>
								<?php
							}
						} else if ($feespaid == 'No') {
							/*$sql_fees = "SELECT * FROM cms_feesreceivemaster 
																								WHERE 
																									student_id = '" . $student_id . "' AND 
																								   branch_id = '" . $branch_id . "' AND
																								   branchyear_id= '" . $branchyear_id . "' AND
																								   semester_id = '" . $semester_id . "'";
																						   $res_fees = dbQuery($sql_fees);*/
							$res_fees = $objFees->getstudentfees($condition1);
							if (dbRows($res_fees) <= 0) {
								?>
									<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
									<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_rollno']; ?></td>
									<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gturegno']; ?></td>
									<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_mobileother']; ?></td>
									<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_fathermobile']; ?></td>
									<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_name']; ?></td>
									<td style="text-align:center;">&nbsp;<?php echo "N"; ?></td>
									<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gender']; ?></td>
									<td style="text-align:center;"><?php echo date('d-m-Y', strtotime($REC_SELECT['receipt_date'])); ?></td>
							
									<td style="text-align:center;">&nbsp;<?php echo date('d-m-Y', strtotime($REC_STUDENT['student_birthdate'])); ?></td>
									<td></td>
								<?php
							}
						} else { ?>
								<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_rollno']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gturegno']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_mobileother']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_fathermobile']; ?></td>
								<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_name']; ?></td>
								<td style="text-align:center;">&nbsp;
									<?php
									/*$sql_fees = "SELECT * FROM cms_feesreceivemaster 
																														 WHERE 
																															 student_id = '" . $student_id . "' AND 
																															 branch_id = '" . $branch_id . "' AND
																															 branchyear_id= '" . $branchyear_id . "' AND
																															 semester_id = '" . $semester_id . "'";
																													 $res_fees = dbQuery($sql_fees);*/
									$res_fees = $objFees->getstudentfees($condition1);
									if (dbRows($res_fees) > 0) {
										echo "Y";
									} else {
										echo "N";
									}
									?>
								</td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_category']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_admby']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gender']; ?></td>
								<td style="text-align:center;">&nbsp;<?php echo date('d-m-Y', strtotime($REC_STUDENT['student_birthdate'])); ?></td>
								<td></td>
							<?php
						}
						?>
					</tr>
					<?php
				}
				?>
			</table>
			<?php
		} else {
			echo "NO DATA FOUND!";
		}
		?>
		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$header_row_string = "";
		$HtmlUrl = "student-list-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 } ?>
</div>
<?php require "_footer.php"; ?>