<?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: 24px;
		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-sheet.php';
		</script>
		<?php
	} elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
		ob_start();
		$branch_id = Escape($_REQUEST['branch_hidden']);
		$semester_id = Escape($_REQUEST['semester_hidden']);
		$year_id = Escape($_REQUEST['year_hidden']);
		$branchyear_id = Escape($_REQUEST['branchyear_hidden']);
		$subject_id = Escape($_REQUEST['subject_hidden']);
		$batch_id = Escape($_REQUEST['batch_idhidden']);
		$start_date = date('Y-m-d', strtotime(str_replace("/", "-", Escape($_REQUEST['startdate']))));
		$end_date = date('Y-m-d', strtotime(str_replace("/", "-", Escape($_REQUEST['enddate']))));
		$employee_id = Escape($_REQUEST['employee_id_hid']);
		$report_type = Escape($_REQUEST['report_type']);
		$lectype = Escape($_REQUEST['lectype_hid']);
		$lectype_disp = Escape($_REQUEST['lectype_disp']);

		$condition = "";
		/*$SQL_STUDENT = "SELECT cp.*,cl.lectype_name,cb.batch_name,cu.user_name FROM 
								 cms_presentmaster cp left join cms_lectype cl on cp.lectype = cl.lectype_id 
								 left join cms_batchmaster cb on cp.batch_id = cb.batch_id 
								 left join cms_usermaster cu on cp.login_id = cu.user_id 
								 WHERE cp.college_id = ".$_SESSION["VedantnrCollegeId"];*/

		if ($branch_id != "") {
			$condition .= " AND cp.branch_id = " . $branch_id;
		}
		if ($year_id != "") {
			$condition .= " AND cp.year_id = " . $year_id;
		}

		if ($branchyear_id != "") {
			$condition .= " AND cp.branchyear_id = " . $branchyear_id;
		}

		
		if ($semester_id != "") {
			$condition .= " AND cp.semester_id = " . $semester_id;
		}

		if ($subject_id != "") {
			$condition .= " AND cp.subject_id = '" . $subject_id . "'";
		}

		if ($employee_id != "" && $employee_id != "undefined") {
			//$RES_EMP = dbQuery("select user_id from cms_employeemaster where employee_id = '".$employee_id."'");
			$condition1 = "";
			$condition1 .= " And employee_id = '" . $employee_id . "'";
			$objEmployeeMgmt = new EmployeeMgmt();
			$RES_EMP = $objEmployeeMgmt->getusersyllabus($condition1);
			$REC_EMP = dbArray($RES_EMP);

			$user_id = $REC_EMP['user_id'];
			$condition .= " AND cp.login_id = '" . $user_id . "'";
		}
		if ($start_date != "") {
			$condition .= " AND cp.day_date >='" . $start_date . "' ";
		}
		if ($end_date != "") {
			$condition .= " AND cp.day_date <='" . $end_date . "'  ";
		}
		if ($batch_id != '' && $batch_id != '0') {
			$condition .= " AND cp.batch_id = " . $batch_id;
		}
		$condition .= " order by day_date ASC ";

		/*if($SQL_CONDITION != ""){
					  $SQL_STUDENT .= $SQL_CONDITION;
				 }
				 $RES_STUDENT = dbQuery($SQL_STUDENT);*/


		$objLecMgmt = new LecMgmt();
		$RES_STUDENT = $objLecMgmt->getsyllabuscovered($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>Syllabus Covered Report</h4>
			</center>
			<div>
				<div class="left"><b>Branch</b> :
					<?php echo $branch_disp . " - " . $semester_disp . " - " . $div_id . " - " . $batch_disp . ' - ' . $emp_disp; ?>
				</div>
				<div class="right"> <?php echo $subject_disp ? '<b>Subject</b> :' . $subject_disp : '&nbsp;'; ?>
					<?php echo $lectype_disp ? '[' . $lectype_disp . ']' : '&nbsp;'; ?>
				</div>
			</div>
			<br />
			<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="8%">Date</th>
					<th style="text-align:center;" width="40%">Topic Covered</th>
					<th style="text-align:center;" width="8%">Lec. Name</th>
					<th style="text-align:center;" width="5%">Lec. No</th>
					<th style="text-align:center;" width="5%">Batch</th>
					<th style="text-align:center;" width="8%">Present By</th>
					<th style="text-align:center;" width="8%">Student Present</th>
					<th style="text-align:center;" width="8%">Student Absent</th>
					<th style="text-align:center;" width="8%">Total Student</th>
				</tr>
				<?php
				$i = 1;
				while ($REC_STUDENT = dbArray($RES_STUDENT)) {
					/*$day_present=count(explode(',',$REC_STUDENT['day_present']));
									  $day_absent=count(explode(',',$REC_STUDENT['day_absent']));*/

					$day_present = 0;
					$day_absent = 0;
					if ($REC_STUDENT['day_present'] != "") {
						$day_present = count(explode(',', $REC_STUDENT['day_present']));
					}
					if ($REC_STUDENT['day_absent'] != "") {
						$day_absent = count(explode(',', $REC_STUDENT['day_absent']));
					}

					?>
					<tr>
						<td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
						<td style="text-align:center;">&nbsp;<?php
						if ($REC_STUDENT['day_date'] != '0000-00-00')
							echo date('d-m-Y', strtotime($REC_STUDENT['day_date']));
						else
							echo '-'; ?></td>
						<td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['day_comment']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['lec_name']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['lec_id']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['batch_name']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['user_name']; ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $day_present ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $day_absent ?></td>
						<td style="text-align:center;">&nbsp;<?php echo $day_present + $day_absent; ?></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="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>
			</table>
			<?php
			$HtmlCode = ob_get_contents();
			ob_end_flush();
			$header_row_string = "";
			$HtmlUrl = "attendancesheet-blank-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 } else {
			echo "NO DATA FOUND!";
		}
	} ?>
</div>
<?php require "_footer.php"; ?>