<?php require "_header.php";
error_reporting(1);
?>
<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;
	}
</style>

<div id="main-report">
	<?php
	if ($_REQUEST['branch_hidden'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-reshuffling-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']);
		$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']);

		$condition = "";

		/*$SQL_STUDENT = "
					SELECT 
						sm.student_id,
						leave_date,
						CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
						sm.student_gturegno,
						sm.student_gender,
						sm.leave_comment,
						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 = 0 AND 
						sm.leave_type = 'r' AND
						sm.student_id = sd.student_id AND
						sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  ";*/

		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 . "'";
		}

		$condition .= " ORDER BY sd.cur_branchid , sd.year_id,sd.cur_branchyearid,sd.cur_semesterid";

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

		//echo $SQL_STUDENT;
		//	$RES_STUDENT = dbQuery($SQL_STUDENT);
		$objStudentMgmt = new StudentMgmt();
		$RES_STUDENT = $objStudentMgmt->getstudentreshuffling($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>Reshuffling Student List</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" width="100%">
				<tr>
					<th width="5%" style="text-align:center;">Sr.</th>
					<th width="5%" style="text-align:center;">Course Year</th>
					<th width="5%" style="text-align:center;">Semester</th>
					<th width="10%" style="text-align:center;">Leave Date</th>
					<th width="12%" style="text-align:center;">GTU Reg No</th>
					<th width="38%" style="text-align:left;">Student Name</th>
					<th width="12%" style="text-align:right;">Refundable Amt</th>
					<th width="15%" style="text-align:center;">Remarks</th>
				</tr>
				<?php
				$i = 1;
				$temp = "";
				while ($REC_STUDENT = dbArray($RES_STUDENT)) {
					if ($REC_STUDENT['branch_name'] != $temp) {
						$temp = $REC_STUDENT['branch_name'];
						$i = 1; ?>
						<?php
					} ?>
					<tr>
						<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['branchyear_name']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['semester_name']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo date("d-m-Y", strtotime($REC_STUDENT['leave_date'])); ?>
						</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_name']; ?></td>
						<td style="text-align:right;">&nbsp;<?php echo $REC_STUDENT['receive_amt']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['leave_comment']; ?></td>
					</tr><?php
					$receive_amt += $REC_STUDENT['receive_amt'];
				}
				?>
				<tr>
					<th style="text-align:right;" colspan="6">&nbsp;Total</th>
					<th style="text-align:right;">&nbsp;<?php echo $receive_amt; ?></th>
					<th style="text-align:center;">&nbsp;</th>
				</tr>
			</table>
			<?php
		} else {
			echo "NO DATA FOUND!";
		}
		?>
		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$header_row_string = "";
		$HtmlUrl = "reshuffling-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";
?>