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

	.break {
		page-break-before: always;
	}
</style>
<div id="main-report">
	<?php
	if ($_REQUEST['branch_hidden'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report--attendence-list.php';
		</script>
		<?php
	} elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
		ob_start();
		$branch_id = Escape($_REQUEST['branch_hidden']);
		$year_id = Escape($_REQUEST['year_hidden']);
		$branchyear_id = Escape($_REQUEST['branchyear_hidden']);
		$semester_id = Escape($_REQUEST['semester_hidden']);
		$subject_id = Escape($_REQUEST['subject_hidden']);
		$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 up.*,
					  (SELECT subject_name 
					  FROM cms_subjectmaster sub  
					  WHERE sub.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sub.subject_id=up.subject_id ) AS subject_name,
					  (SELECT branch_name 
					  FROM cms_branchmaster sec 
					  WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=up.branch_id) AS branch_name,
						  (SELECT year_name 
					  FROM cms_yearmaster ym 
					  WHERE ym.year_id=up.year_id) AS year_name,
						  (SELECT branchyear_name 
					  FROM cms_branchyear bry 
					  WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=up.branchyear_id) AS branchyear_name,
						  (SELECT semester_name
						 FROM cms_semestermaster sem 
					  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = up.semester_id) AS semester_name,		  	
					   cu.user_name
					  FROM 
						  cms_usermaster cu,
						  cms_upload up	
					  WHERE  up.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and up.login_id = cu.user_id";*/


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

		if ($subject_id != "" && $subject_id != "undefined") {
			$condition .= " AND up.subject_id = '" . $subject_id . "'";
		}



		//	echo $SQL_STUDENT;
		//	$RES_STUDENT = dbQuery($SQL_STUDENT);
	
		$objcms_uploadMgmt = new cms_uploadMgmt();
		$RES_STUDENT = $objcms_uploadMgmt->getupload($condition);
		if (dbRows($RES_STUDENT) > 0) { ?>
			<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>
			<center>
				<h4>Material Report</h4>
			</center>
			<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>
			<br />
			<br />
			<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<th style="text-align:center;" width="2%">Sr.</th>
					<th style="text-align:center;" width="5%">Course</th>
					<th style="text-align:center;" width="5%">Batch Year</th>
					<?php if ($branchyear_id != "") { ?>
						<th style="text-align:center;" width="5%">Course Name</th>
					<?php }
					if ($semester_id != "") { ?>
						<th style="text-align:center;" width="5%">Semester Name</th>
					<?php } ?>
					<th style="text-align:center;" width="15%">Subject Name</th>
					<th style="text-align:center;" width="15%">Chapter</th>
					<th style="text-align:center;" width="15%">Chapter Description</th>
					<th style="text-align:center;" width="10%">File Name</th>
					<th style="text-align:center;" width="8%">Ass Date</th>
					<th style="text-align:center;" width="8%">Sub. Date</th>
					<th style="text-align:center;" width="15%">Uploaded BY</th>
				</tr>
				<?php
				$i = 1;
				$temp = "";
				$temp1 = "";
				while ($REC_STUDENT = dbArray($RES_STUDENT)) { ?>
					<tr>
						<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['branch_name']; ?></td>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['year_name']; ?></td>
						<?php if ($branchyear_id != "") { ?>
							<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['branchyear_name']; ?></td>
						<?php }
						if ($semester_id != "") { ?>
							<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['semester_name']; ?></td>
						<?php } ?>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['subject_name']; ?></td>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['title']; ?></td>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['description']; ?></td>
						<td style="text-align:left;">&nbsp;
						<a href="<?php echo $CollegeImagePath . $REC_STUDENT['file_name']; ?>" target="_blank"><?php echo $REC_STUDENT['file_name']; ?></a>
						</td>
						<td style="text-align:left;">
							&nbsp;<?php echo ($REC_STUDENT['assignment_date'] != "0000-00-00" ? date('d-m-Y', strtotime($REC_STUDENT['assignment_date'])) : ''); ?>
						</td>
						<td style="text-align:left;">
							&nbsp;<?php echo ($REC_STUDENT['submission_date'] != "0000-00-00" ? date('d-m-Y', strtotime($REC_STUDENT['submission_date'])) : ''); ?>
						</td>
						<td style="text-align:center;">
							&nbsp;<?php echo $REC_STUDENT['user_name'] . "<br/>" . date("d-m-Y H:i:a", strtotime($REC_STUDENT['createdon'])); ?>
						</td>
					</tr>
					<?php
				}
				?>
				<!--<tr>
			<td colspan="10" >
			<table class="table-report-footer" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td align="left" style="border:solid 0px red; padding:0px;" width="71%">Created by <b><?php echo $_SESSION["VedantnrUserName"]; ?></b> </td>
					<td align="right" style="border:solid 0px red; padding:0px;" width="29%">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="Student Attendance Sheet";
		$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";
?>