<?php
require "_header.php";

?>
<script language="javascript" type="text/javascript">
</script>
<style type="text/css">
	.attendance-table-report {
		font-family: Verdana, Geneva, sans-serif;
		font-size: 9px;
		text-align: left;
		border-right: 0px none;
		border-bottom: 0px none;
	}

	.attendance-table-report tr {
		padding: 0px 0px 0px 0px;
	}

	.attendance-table-report td {
		padding: 0px 0px 0px 0px;
		border-top: 0px none;
		border-left: 0px none;
	}

	.attendance-table-report th {
		padding: 1px 1px 1px 1px;
		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'] == "" && $_REQUEST['semester_hidden'] == "" && $_REQUEST['subject_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 = Escape($_REQUEST['startdate']);
		$end_date = Escape($_REQUEST['enddate']);
		$month = date('m', strtotime($start_date));
		$year = date('Y', strtotime($start_date));
		$orderby = Escape($_REQUEST['hid_orderby']);

		$report_type = Escape($_REQUEST['report_type']);
		$days = daysInMonth($month, $year);
		$lectype = Escape($_REQUEST['lectype_hid']);
		$lectype_disp = Escape($_REQUEST['lectype_disp']);

		$branch_name = Escape($_REQUEST['branch_disp']);
		$year_name = Escape($_REQUEST['year_disp']);
		$branchyear_name = Escape($_REQUEST['branchyear_disp']);
		$semester_name = Escape($_REQUEST['semester_disp']);
		$subject_name = Escape($_REQUEST['subject_disp']);
		$monthname1 = date("F", mktime(0, 0, 0, $month, 1, 1));
		$condition = "";

		/*$SQL_STUDENT = "
		SELECT 
			sm.student_id,
			CONCAT(student_surname,' ',student_firstname) AS student_name,
			student_gturegno,
			student_gender,
			batch_id
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
		WHERE sm.student_active = 1 AND sm.student_id = sd.student_id ";*/

		if ($branch_id != "") {
			$condition .= " AND sd.cur_branchid = " . $branch_id;
		}

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

		if ($year_id != "") {
			$condition .= " AND sd.year_id = '" . $year_id . "'";
		}
		if ($branchyear_id != "") {
			$condition .= " AND sd.cur_branchyearid = '" . $branchyear_id . "'";
		}
		if ($batch_id != '' && $batch_id != '0') {
			$condition .= " AND sd.batch_id = " . $batch_id;
		}
		if ($orderby != "" && $orderby != "undefined") {
			$condition .= " ORDER BY " . $orderby . " ASC ";
		} else {
			$condition .= " ORDER BY student_gturegno ASC ";
		}

		$objStudentMgmt=new StudentMgmt();
		$RES_STUDENT=$objStudentMgmt->getstudentattnd($condition);
		function makeRow_blank($days)
		{ ?>
			<table cellpadding="0" class="attendance-table-report" cellspacing="0" width="100%" border="1">
				<tr><?php
				for ($j = 0; $j < $days; $j++) { ?>
						<td style="height:25px; width:40px;">&nbsp;</td><?php
				} ?>
				</tr>
			</table>
			<?php
		}
		?>
		<div class="college_name"><?php echo $_SESSION["VedantnrCollegeName"]; ?></div>
		<div class="college_address"><?php echo $_SESSION["VedantnrCollegeAddress"]; ?></div>
		<div class="college_address">
			
			Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
			&nbsp;&nbsp;
			Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>
		</div>

		<center>
			<h4>Subject wise Attendance Report</h4>
		</center>
		<table 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>
				<div align="left">
					<b>Subject</b>:
					<?php echo $subject_name; ?>
				</div>
			</tr>
		</table>


		<br />

		<?php if ($report_type == "blank_sheet") { ?>
			<table border="1" class="attendance-table-report" cellpadding="0" cellspacing="0">
				<tr>
					<th colspan="3"><?php print "Month :: " . $monthname1 . "&nbsp;&nbsp; Year :: " . $year; ?></th>

					<td rowspan="2" valign="top" style="height:106px">
						<table width="100%" border="1" class="attendance-table-report" style="height:106px;" cellpadding="0"
							cellspacing="0">
							<tr>
								<?php

								for ($i = 1; $i <= $days; $i++) { ?>
									<th style="height:66px; text-align:center; vertical-align:middle;">
										<?php $day = date("D", mktime(0, 0, 0, $month, $i, $year));
										for ($l = 0; $l < strlen($day); $l++) {
											print ucwords($day[$l]) . "<br>";
										}
										?>
									</th>
								<?php
								}
								?>
							</tr>
							<tr>
								<?php
								for ($i = 1; $i <= $days; $i++) { ?>
									<th style="height:40px; text-align:center; vertical-align:middle;">
										<?php print str_pad($i, 2, "0", STR_PAD_LEFT); ?></th>
								<?php
								}
								?>
							</tr>
						</table>
					</td>
					<th width="10%">Total Days of Current Month</th>
					<th width="10%">Total Days of Last Month</th>
					<th width="10%">Total Days of End of Month</th>
					<th width="6%" rowspan="2">Notes</th>
				</tr>
				<tr>
					<th width="2%" style="text-align:center;">Sr. No.</th>
					<th width="4%" style="text-align:center;">Roll No</th>
					<th width="15%" style="text-align:left; padding:0px 2px 0px 2px;">Student Name</th>
					<th width="12%">Out Of Atten.</th>
					<th width="12%">Out Of Atten.</th>
					<th width="12%">Out Of Atten.</th>
				</tr>
				<?php
				$i = 1;
				while ($REC_STUDENT = dbArray($RES_STUDENT)) {
					extract($REC_STUDENT);
					?>
					<tr>
						<td style="text-align:center"><?php print $i++; ?></td>
						<td style="text-align:center; padding:0px 2px 0px 2px;"><?php print $student_gturegno; ?></td>
						<td style="text-align:left; padding:0px 2px 0px 2px;"><?php print $student_name; ?></td>
						<td width="100%" valign="top"><?php makeRow_blank($days); ?></td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
					<?php
				}
				?>
				<tr>
					<td colspan="2" rowspan="7">&nbsp;</td>
					<th>&nbsp;Present Boys</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
					<td colspan="3" rowspan="7">&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Present Girls</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Absent Boys</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Absent Girls</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Total Boys</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Total Girls</th>
					<td valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<th>&nbsp;Total Intake</th>
					<td width="100%" valign="top"><?php makeRow_blank($days); ?></td>
					<td>&nbsp;</td>
				</tr>
				<!--<tr>
					<td colspan="8" >
					<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 if ($report_type == "detail_sheet") {
			$i = 1;
			$present = array();
			$present_total = 0;
			$total_summary = array();
			$day_str = Get_PresentDays($start_date, $end_date, $branch_id, $semester_id, $year_id, $branchyear_id, $subject_id, $lectype, $emp_aay);
			if ($day_str != "") {
				$day_array = explode(',', $day_str);
				?>
					<table cellpadding="0" cellspacing="0" border="1" class="attendance-table-report" width="100%">
						<tr>
							<th colspan="3"><?php print "Month :: " . $monthname1 . "&nbsp;&nbsp; Year :: " . $year; ?></th>
							<td rowspan="2" valign="top" width="100%" style="height:106px;">
								<table cellpadding="0" cellspacing="0" width="100%" border="1" style="height:106px;"
									class="attendance-table-report">
									<tr>
										<?php

										for ($i = 0; $i < count($day_array); $i++) {
											$day = date("D", strtotime($day_array[$i]));
											?>
											<th style="height:66px; text-align:center; vertical-align:middle;min-width: 50px;">
											<?php


											$total_summary["present boys"][$i] = 0;
											$total_summary["present girls"][$i] = 0;
											$total_summary["absent boys"][$i] = 0;
											$total_summary["absent girls"][$i] = 0;
											$total_summary["total absent"][$i] = 0;
											$total_summary["total present"][$i] = 0;
											$total_summary["total intake"][$i] = 0;
											$total_summary["total present boys"] = 0;
											$total_summary["total present girls"] = 0;
											$total_summary["total absent boys"] = 0;
											$total_summary["total absent girls"] = 0;
											$total_summary["total absents"] = 0;
											$total_summary["total presents"] = 0;
											$total_summary["total intakes"] = 0;
											$present[$i][1] = "";
											$present[$i][2] = "";
											$present[$i][3] = "";
											$present[$i][4] = "";
											$present[$i][5] = "";
											$present[$i][6] = "";

											for ($l = 0; $l < strlen($day); $l++) {
												print ucwords($day[$l]) . "<br>";

											}
											?>
											</th>
									<?php
										}

										?>
									</tr>
									<tr>
										<?php
										for ($i = 0; $i < count($day_array); $i++) {
											?>
											<th style="height:40px; text-align:center; vertical-align:middle;min-width: 50px;">
											<?php print str_replace('-', "<br/>", date("d-M", strtotime($day_array[$i]))); ?>
											</th>
									<?php
										}
										?>
									</tr>

								</table>
							</td>
							<th width="10%" rowspan="2" class="90degree_th 90degree"><?php echo "Total Present"; ?></th>
							<th width="10%" rowspan="2"><?php echo "Total Conduct"; ?></th>
							<th width="10%" rowspan="2"><?php echo "Per.[%]"; ?></th>
							<th width="6%" rowspan="2">Notes</th>
						</tr>
						<tr>
							<th width="2%" style="text-align:center;">Sr. No.</th>
							<th width="4%" style="text-align:center;">Roll No</th>
							<th width="15%" style="text-align:left; padding:0px 2px 0px 2px;">Student Name</th>
						</tr>
						<tr>
							<th style="text-align:center" colspan='3'>Employee Name</th>
							<td width="100%" valign="top">
								<table cellpadding="0" cellspacing="0" width="100%" border="1" style="height:15px;"
									class="attendance-table-report">
									<tr>
										<?php
										$emp_aay = explode(',', $emp_aay);
										for ($i = 0; $i < count($emp_aay); $i++) {
											?>
											<td style="height:20px; text-align:center; vertical-align:middle;min-width: 50px;">
											<?php print $emp_aay[$i]; ?>
											</td>
									<?php
										}
										?>
									</tr>
								</table>
							</td>
							<td style="text-align:center" colspan='4'>&nbsp;</td>

						</tr>

						<?php
						$i = 1;
						getArray($present, $start_date, $end_date, $branch_id, $semester_id, $subject_id, $year_id, $branchyear_id, $lectype);
						while ($row = dbArray($RES_STUDENT)) {
							extract($row);

							?>
							<tr>
								<td style="text-align:center"><?php print $i++; ?></td>
								<td style="text-align:center; padding:0px 2px 0px 2px;"><?php print $student_gturegno; ?></td>
								<td style="text-align:left; padding:0px 2px 0px 2px;"><?php print $student_name; ?></td>
								<td width="100%" valign="top">
								<?php makeRow($present, $present_total, $total_summary, $day_array, $student_id, $student_gender, $total_a_p); ?>
								</td>
								<td style="text-align:center"><?php print $present_total; ?></td>
								<td style="text-align:center">
								<?php print $total_a_p; ?>
								</td>
								<td style="text-align:center"><?php print round(($present_total * 100) / $total_a_p, 2) . '%'; ?></td>
								<td>&nbsp;</td>
							</tr>
						<?php
						}
						?>

						<tr>
							<td colspan="2" rowspan="7">&nbsp;</td>
							<th>Present Boys</th>
							<td width="100%" valign="top"><?php @makeRow_totalsummary($total_summary, $day_array, "present boys"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total present boys"]; ?></td>
							<td colspan="3" rowspan="7">&nbsp;</td>
						</tr>
						<tr>
							<th>Present Girls</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "present girls"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total present girls"]; ?></td>
						</tr>
						<tr>
							<th>Absent Boys</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "absent boys"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total absent boys"]; ?></td>
						</tr>
						<tr>
							<th>Absent Girls</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "absent girls"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total absent girls"]; ?></td>
						</tr>
						<tr>
							<th>Total Absent</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "total absent"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total absents"]; ?></td>
						</tr>
						<tr>
							<th>Total Present</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "total present"); ?>
							</td>
							<td style="text-align:center"><?php print $total_summary["total presents"]; ?></td>
						</tr>
						<tr>
							<th>Total Intake</th>
							<td width="100%" valign="top" style="text-align:center">
							<?php @makeRow_totalsummary($total_summary, $day_array, "total intake"); ?></td>
							<td style="text-align:center"><?php print $total_summary["total intakes"]; ?></td>
						</tr>


					</table>
			<?php }
		} ?>
		<?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") {
					<?php
					/* $path1 = "http://server/pims/report/attendancesheet-blank-report.html";
				   copy("http://server/cms/report/attendancesheet-blank-report.html", $path1);	
				  */
					?>

					/*		document.frm.action="http://server/pims/convertpdf/create-pdf.php";*/
					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";
function getArray(&$present, $start_date, $end_date, $branch, $semester, $subject, $year_id, $branchyear_id, $lectype)
{
	$batch_id = $_REQUEST['batch_idhidden'];
	$qry = "SELECT 
					day_date,day_present,day_absent,day_working,lec_id,batch_id 
				FROM 
					cms_presentmaster 
				WHERE 
					day_date >='" . $start_date . "'
					AND day_date <='" . $end_date . "' 
					AND branch_id = '" . $branch . "'
					AND semester_id = '" . $semester . "'
					AND year_id = '" . $year_id . "'
					AND branchyear_id = '" . $branchyear_id . "'
					AND subject_id = '" . $subject . "'
					AND college_id = '" . $_SESSION['VedantnrCollegeId'] . "'";
	if ($batch_id != '' && $batch_id != '0') {
		$qry .= " AND batch_id In (0," . $batch_id . ")";
	}

	if ($lectype != '' && $lectype != '0' && $lectype != 'undefined') {
		$qry .= " AND lectype = '" . $lectype . "'";
	}
	//	echo $qry;
	$allDetails = dbQuery($qry);
	if (dbRows($allDetails) > 0) {
		while ($row = dbArray($allDetails)) {
			//$day = number_format(substr($row['day_date'],8,2));
			$day = $row['day_date'];
			if ($row['day_working'] == "1") {
				$present[$day][$row['lec_id']] = $row['day_present'];
				if ($row['day_present'] == "") {
					$present[$day][$row['lec_id']] = '11111111111111111111111111111';
				}

			} else if ($present[$day][$row['lec_id']] != "S") {
				$present[$day][$row['lec_id']] = "H";
			}

		}
	}
}
function makeRow_totalsummary(&$total_summary, $days, $perform)
{ ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="1" class="attendance-table-report">
		<tr><?php
		for ($j = 0; $j < count($days); $j++) { ?>
				<td height="20px;" style="width:3%;text-align:center;min-width: 50px;"><?php
				if ($perform == "present boys") {
					$temp = $total_summary["present boys"][$days[$j]];
					$total_summary["total present boys"] += $temp;
					print $temp;
				} else if ($perform == "present girls") {
					$temp = $total_summary["present girls"][$days[$j]];
					$total_summary["total present girls"] += $temp;
					print $temp;
				} else if ($perform == "absent boys") {
					$temp = $total_summary["absent boys"][$days[$j]];
					$total_summary["total absent boys"] += $temp;
					print $temp;
				} else if ($perform == "absent girls") {
					$temp = $total_summary["absent girls"][$days[$j]];
					$total_summary["total absent girls"] += $temp;
					print $temp;
				} else if ($perform == "total absent") {
					$temp = $total_summary["absent boys"][$days[$j]] + $total_summary["absent girls"][$days[$j]];
					$total_summary["total intake"][$days[$j]] += $temp;
					$total_summary["total absents"] += $temp;
					print $temp;
				} else if ($perform == "total present") {
					$temp = $total_summary["present boys"][$days[$j]] + $total_summary["present girls"][$days[$j]];
					$total_summary["total intake"][$days[$j]] += $temp;
					$total_summary["total presents"] += $temp;
					print $temp;
				} else if ($perform == "total intake") {
					$temp = $total_summary["total intake"][$days[$j]];
					$total_summary["total intakes"] += $temp;
					print $temp;
				} ?>
				</td><?php
		} ?>
		</tr>
	</table>
	<?php
}

function makeRow($present, &$present_total, &$total_summary, $days, $student_id, $student_gender, &$total_a_p)
{
	$present_total = 0;
	$total_a_p = 0;
	$present_array = array();
	?>
	<table width="100%" cellpadding="0" cellspacing="0" border="1" class="attendance-table-report">
		<tr><?php
		//print_r ($present);
		//exit();
		for ($j = 0; $j < count($days); $j++) { ?>

				<td height="25px;" style="width:3%;text-align:center; font-size:9px;min-width: 50px;">&nbsp;<?php

				for ($k = 1; $k <= 7; $k++) {
					if ($present[$days[$j]][$k] != "S" && $present[$days[$j]][$k] != "H") {

						if ($present[$days[$j]][$k] != "") {

							$present_array = explode(",", $present[$days[$j]][$k]);

							if (in_array($student_id, $present_array) == true) {
								if ($student_gender == "Male") {
									$total_summary["present boys"][$days[$j]] += 1;
								} else if ($student_gender == "Female") {
									$total_summary["present girls"][$days[$j]] += 1;
								}
								echo "P";
								$present_total++;
							} else {
								if ($student_gender == "Male") {
									$total_summary["absent boys"][$days[$j]] += 1;
								} else if ($student_gender == "Female") {
									$total_summary["absent girls"][$days[$j]] += 1;
								}
								echo "A";

							}
							$total_a_p++;
						}
					} else {
						if ($k == 1)

							print $present[$days[$j]][$k];
					} ?>
						<?php
				} ?>
				</td><?php } ?>
		</tr>
	</table>
	<?php
}



function Get_PresentDays($start_date, $end_date, $branch, $semester, $year_id, $branchyear_id, $subject, $lectype, $emp_aay)
{
	$qry = "";
	$emp_aay = "";
	$total_day = "";
	$batch_id = Escape($_REQUEST['batch_idhidden']);
	$qry = "SELECT distinct(day_date)as day_date,login_id,user_name
				FROM 
					cms_presentmaster pre,
					cms_usermaster u
				WHERE 
					u.user_id=pre.login_id AND
					pre.branch_id = '" . $branch . "' AND
					pre.semester_id = '" . $semester . "' AND
					pre.year_id = '" . $year_id . "' AND
					pre.branchyear_id = '" . $branchyear_id . "' AND
					pre.subject_id = '" . $subject . "' AND
					pre.college_id = '" . $_SESSION['VedantnrCollegeId'] . "' AND
					pre.day_date >='" . $start_date . "' AND
					pre.day_date <='" . $end_date . "' ";

	if ($batch_id != '' && $batch_id != '0') {
		$qry .= " AND pre.batch_id In (0," . $batch_id . ")";
	}

	if ($lectype != '' && $lectype != '0' && $lectype != 'undefined') {
		$qry .= " AND pre.lectype = '" . $lectype . "'";
	}
	$qry .= " order by pre.day_date ASC ";

	$out = dbQuery($qry);
	if (dbRows($out) > 0) {
		while ($row = dbArray($out)) {
			$total_day .= $row['day_date'] . ",";
			$emp_aay .= $row['user_name'] . ",";
		}
		$emp_aay = substr($emp_aay, 0, -1);
		$total_day = substr($total_day, 0, -1);
		return $total_day;
	} else {
		return $total_day;
	}
}
function add_br($str)
{
	$final_str = "";
	for ($i = 0; $i < strlen($str); $i++) {
		$final_str .= ucfirst($str[$i]) . "<br/>";
	}
	return $final_str;
}
?>