<?php require "_header.php"; ?>
<script language="javascript" type="text/javascript">
	//document.getElementById("main-content").style.display = 'none';
</script>

<div id="main-report">
	<?php
	if ($_REQUEST['branch_hidden'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-address-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']);
		$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 
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_addressat,
			student_addresspost,	
			student_pincode,
			taluko_nameeng,
			dist_nameeng,
			state_nameeng,			
			student_mobileother,
			student_fathermobile
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd			
		WHERE 
			sm.student_id = sd.student_id AND
			sm.student_active = 1";*/

		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 ($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 sm.student_gturegno ";

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


		//$RES_STUDENT = dbQuery($SQL_STUDENT);
		$objStudentMgmt = new StudentMgmt();
		$RES_STUDENT = $objStudentMgmt->getstudentaddress($condition);
		if (dbRows($RES_STUDENT) > 0) {
			$counter = 1; ?>
		<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 Address Sheet</h4>
			</center>
			
			<table cellpadding="0" cellspacing="8" align="center" width="100%"
				style="margin: left 5px;border: 1px solid black;">
				<tr>
					<td colspan="7">
						<table class="table-report-footer" cellpadding="0" cellspacing="0" width="100%">
							<tr>
							<div align="left">
				<b>Course</b> :
				<?php echo $branch_name; ?>
			</div>
			<div align="right">
				<b>Batch Year</b>:
				<?php echo $year_name; ?>
			</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>
							</tr>
						</table>
					</td>
				</tr>
				
				<?php 
				$rowcntr = 0;
				
				while ($row = dbArray($RES_STUDENT)) {
					if ($counter % 3 == 1) {

						if ($rowcntr == 8) { ?>
							<tr>
								<td style="height:20px" colspan=3></td>
							</tr>
							<tr height="122"><?php $rowcntr = 0;
						} else { ?>
							<tr height="122"><?php }
						$rowcntr++;
					} ?>
						<td align="center" valign="top" width="34%"
							style="font-family:Verdana, Geneva, sans-serif; font-size:12px; padding:5px;border: 1px solid black">
							<table cellpadding="0" cellspacing="2" align="center" width="100%">
								<tr>
									<td align="left">
										<font size='1.9'>

											<b><?php echo $row['student_name']; ?></b><br />
											<?php echo $row['student_addressat'] . " , "; ?>
											<?php echo $row['student_addresspost']; ?><br />
											<?php echo $row['taluko_nameeng'] . " , "; ?>
											<?php echo $row['dist_nameeng'] . " , "; ?>
											<?php echo $row['state_nameeng'] . " - "; ?>
											<?php echo $row['student_pincode']; ?><br />
											Contact: <?php echo $row['student_fathermobile'] . " , "; ?>
											<?php echo $row['student_mobileother']; ?>
										</font>
									</td>
								</tr>
							</table>
						</td><?php
						$counter++;
						if ($counter % 3 == 1) {
							$counter = 1; ?>
						</tr><?php
						}
				}
				if ($counter % 3 == 2) { ?>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					</tr><?php
				}
				if ($counter % 3 == 0) { ?>
					<td>&nbsp;</td>
					</tr><?php
				} ?>
				<tr>
					<td colspan="7">
						<table class="table-report-footer" cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td align="left" style="border:solid 0px red; padding:0px;" width="70%">Created by
									<b><?php echo $_SESSION["VedantnrUserName"]; ?></b> </td>
								<td align="right" style="border:solid 0px red; padding:0px;" width="30%">Developed By <b>Aum
										Imagineering Pvt.Ltd.</b></td>
							</tr>
						</table>
					</td>
				</tr>

			</table>


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