<?php require "_header.php";
error_reporting(1); ?>
<script src="js/1_5_jquery.js" 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;
	}

	.break {
		page-break-before: always;
	}
</style>
<div id="main-content">
	<div id="headertext"
		style="color:#FF0000;font-size:20px;padding-top:10px;font-family:Georgia, 'Times New Roman', Times, serif;">
		<b><b>
	</div>

	<div id="pnlDiv1">
		<?php
		if ($_SESSION["VedantnrUserRole"] == "PowerUser") {

			//$date="2010-10-12"; //date("Y-m-d")
			/*$qry = "Select login_id,user_name,sum(case when discount = '0' then receive_amt else total_receive_amt  end) as receive_amt
									from 
									cms_feesreceivemaster fees, 
									cms_usermaster user 
									Where 
									user.user_id=fees.login_id
									And fees.receipt_date='" . date("Y-m-d") . "'
									And fees.college_id='" . $_SESSION["VedantnrCollegeId"] . "'
									group by login_id";

									$out = dbquery($qry); */

			$objUserMgmt = new UserMgmt();
			$out = $objUserMgmt->getuserfees($condition = "");
			if (dbRows($out) > 0) { ?>

				<table style="border:1px solid #03C;" border:2 class="report-color">
					<tr>
						<th>User Name</th>
						<th>Fees Collect</th>
					</tr>
					<?php
					while ($row = dbArray($out)) { ?>
						<tr>
							<td><?php echo $row['user_name']; ?> </td>
							<td style="text-align:right;font-size:12px;"><?php echo $row['receive_amt']; ?> </td>
						</tr>
						<?php $totalfees += $row['receive_amt'];
					} ?>
					<tr>
						<th>Total</th>
						<th style="text-align:right"><?php echo $totalfees; ?> </th>
					</tr>
				</table>
				<?php
			}
		}
		?>
		</br>
		<?php
		if ($_SESSION["VedantnrUserRole"] == "PowerUser" || $_SESSION["VedantnrUserId"] == "3") {
			?>
			<a href="report-student-summary.php">Click to Student Active Report</a>
			<?php
		}
		?>
		</br>
		</br>
	</div>

	<div id="contentBirth" class="x-hidden">
		<?php
		$bday = date("Y-m-d");
		$curmonth = date("m", strtotime($bday));
		$curdate = date("d", strtotime($bday));
		$branch_id = "";
		$semester_id = "";
		$year_id = "";
		$branchyear_id = "";
		$student_gturegno = "";


		/*$SQL_STUDENT = "
							 SELECT
							 sm.student_id,
							 sm.student_admby,
							 sd.cur_branchid,
							 sd.cur_semesterid,
							 sd.batch_id,
							 sd.cur_branchyearid,
							 sm.student_gender,
							 CONCAT(student_surname,' ',student_firstname,'. ',SUBSTR(student_lastname,1,1),'.') AS student_name,
							 student_gturegno,
							 student_mobilestudents,
							 student_mobileparents,
							 tfw_scheme,
							 (SELECT branch_name 
						 FROM cms_branchmaster sec 
						 WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and 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 branchyear_name
							 FROM 	cms_branchyear bry 
						  WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
						  (SELECT semester_name
							 FROM cms_semestermaster sem 
						  WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
				   
							 FROM
							 cms_studentmaster sm,
							 cms_studentdetail sd
							 
							 WHERE
							 sm.student_id = sd.student_id AND
							 sm.student_active = 1 AND
							 sm.college_id='" . $_SESSION["VedantnrCollegeId"] . "'";*/

		$condition = "";

		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 ($student_gturegno != "") {
			$condition .= " AND sm.student_gturegno = " . $student_gturegno;
		}
		//$condition .= " AND sm.student_birthdate = '".$bday."' ";	
		$condition .= " AND month( student_birthdate ) = $curmonth AND DAYOFMONTH( student_birthdate ) = $curdate";
		$condition .= " ORDER BY sd.cur_branchid ASC, sm.student_id ASC ";
		$objStudent = new StudentMgmt();
		$RESULT_STUDENT = $objStudent->getuserstudent($condition);

		$total = dbRows($RESULT_STUDENT);
		$total = dbRows($RESULT_STUDENT);
		$StudentData = array("count" => $total, "data" => array());
		$i = 0;
		?>
		<script language="javascript" type="text/javascript">
			Ext.onReady(function () {
				new Ext.Panel({ title: "Today's Birthday", renderTo: 'pnlDiv1', height: 300, autoScroll: true, width: 500, contentEl: 'contentBirth' });
			});
		</script>
		<?php
		if ($total > 0) { ?>
			<table class="table-report" border="1" cellpadding="0" cellspacing="0">
				<h1>Student Birthday</h1>
				<tr class="x-panel-header x-unselectable">
					<th>
						<center>Course</center>
					</th>
					<th>
						<center>Batch Year</center>
					</th>
					<th>
						<center>Course Year</center>
					</th>
					<th>
						<center>Semester</center>
					</th>
					<th>
						<center>Student Name</center>
					</th>
				</tr>
				<?php
				while ($RECORD_STUDENT = dbArray($RESULT_STUDENT)) {

					$student_id = $RECORD_STUDENT["student_id"];
					$student_name = $RECORD_STUDENT["student_name"];
					$branch_id = $RECORD_STUDENT["cur_branchid"];
					$semester_id = $RECORD_STUDENT["cur_semesterid"];
					$student_admby = $RECORD_STUDENT["student_admby"];
					$student_gender = $RECORD_STUDENT["student_gender"];
					$tfw_scheme = $RECORD_STUDENT["tfw_scheme"];
					$batch_id = $RECORD_STUDENT["batch_id"];
					$year_id = $RECORD_STUDENT["year_id"];
					$branchyear_id = $RECORD_STUDENT["branchyear_id"];
					$str_temp = str_replace("<StudentName>", $student_name, $str_msg);
					if ($message_to == "fees") {
						$str_temp = getFeesData($str_temp, $branch_id, $semester_id, $year_id, $branchyear_id, $student_id, $student_admby, $tfw_scheme, $greaterfees, $head_id);
					} else if ($message_to == "exam") {
						$str_temp = getExamData($str_temp, $branch_id, $semester_id, $year_id, $branchyear_id, $student_id, $exam_id, $allsub);
					} else if ($message_to == "atkt") {
						$str_temp = getAtktData($str_temp, $branch_id, $semester_id, $year_id, $branchyear_id, $student_id);
					} else if ($message_to == "present_day" || $message_to == "present_month") {
						$month = array();
						$month[1] = "January";
						$month[2] = "February";
						$month[3] = "March";
						$month[4] = "April";
						$month[5] = "May";
						$month[6] = "June";
						$month[7] = "July";
						$month[8] = "August";
						$month[9] = "September";
						$month[10] = "October";
						$month[11] = "November";
						$month[12] = "December";
						$str_temp = str_replace("<MonthName>", $month[$present_month], $str_temp);
						$str_temp = getPresentData($str_temp, $branch_id, $semester_id, $year_id, $branchyear_id, $student_id, $present_day, $present_month, $batch_id);
					}
					if ($str_temp != "skip student") {
						$temparray["student_id"] = $student_id;
						?>
						<tr>

							<td><?php echo $temparray["branch_name"] = $RECORD_STUDENT["branch_name"]; ?></td>

							<td><?php echo $temparray["year_name"] = $RECORD_STUDENT["year_name"]; ?></td>
							<td><?php echo $temparray["branchyear_name"] = $RECORD_STUDENT["branchyear_name"]; ?></td>
							<td><?php echo $temparray["semeser_name"] = $RECORD_STUDENT["semester_name"]; ?></td>
							<td><?php echo $temparray["student_name"] = $RECORD_STUDENT["student_name"]; ?></td>
						</tr>
						<?php
						$StudentData["data"][$i] = $temparray;
						$i++;
					}
				}
				?>
			</table>
			<br>
			<?php
		}
		?>

		<?php
		/*	$SQL_EMPLOYEE = "select * from cms_employeemaster where 1=1";
										   $RESULT_EMPLOYEE = dbQuery($SQL_EMPLOYEE);*/
		$condition1 = "";
		$condition1 .= " AND month( em.employee_birthdate ) = $curmonth AND DAYOFMONTH( em.employee_birthdate ) = $curdate";
		$condition1 .= " AND em.user_id = '" . $_SESSION['aUserId'] . "'";
		$condition1 .= " AND em.college_id= '" . $_SESSION["VedantnrCollegeId"] . "'";
		$condition1 .= " ORDER BY em.employee_id ";

		$objEmployeeMgmt = new EmployeeMgmt();
		$RESULT_EMPLOYEE = $objEmployeeMgmt->getuseremp($condition1);
		$total = dbRows($RESULT_EMPLOYEE);
		if ($total > 0) {
			$EmployeetData = array("count" => $total, "data" => array());
			?>
			<table border='2'>
				<h1>Employee Birthday</h1>
				<tr class="x-panel-header x-unselectable">
					<th>
						<center>Course</center>
					</th>
					<th>
						<center>Employee_Name</center>
					</th>
					<th>
						<center>Is_Teaching</center>
					</th>
				</tr>
				<?php
				while ($RECORD_EMPLOYEE1 = dbArray($RESULT_EMPLOYEE1)) {
					$employee_id = $RECORD_EMPLOYEE1["employee_id"];
					?>
					<tr>
						<td><?php echo $temparray["branch_name"] = $RECORD_EMPLOYEE["branch_name"]; ?></td>
						<td><?php echo $employee_name = $RECORD_EMPLOYEE["employee_name"]; ?></td>
						<td><?php echo $employee_isteaching = $RECORD_EMPLOYEE["employee_isteaching"]; ?></td>
					</tr>
					<?php
				}
				?>
			</table>
			<?php
		}
		?>
	</div>


	<?php
	if ($_SESSION["VedantnrUserRole"] == "Student") {
		?>
		<span style="float:left;padding:10px 0px 0px 10px;">
			<div id="divbutton">
				<div class="x-panel-header" style="margin-bottom:5px;"><a href="student-fees-report.php">View Fees Info.</a>
				</div>
				<div class="x-panel-header" style="margin-bottom:5px;"><a href="student-result-report.php">View Result
						Info.</a></div>
				<div class="x-panel-header" style="margin-bottom:5px;"><a href="student-attendence-report.php">View
						Attendance Info.</a></div>
				<div class="x-panel-header" style="margin-bottom:5px;"><a href="logout.php">Logout</a></div>
			</div>
		</span>
	<?php }
	if ($_SESSION['VedantnrModuleFolder'] != "library" && $_SESSION["VedantnrUserRole"] != "Student") {
		?>
		<div style="float:left;padding:10px 0px 0px 0px;color:#333">
			<div id="pnlDiv2">

				<div id="contentBirth1" class="x-hidden">
					<?php
					$arr = array();
					$total = 0;
					//subject allocation
					/*$sql = "	SELECT sa.*,
												   (Select branch_name from cms_branchmaster where cms_branchmaster.branch_id = sa.branch_id)as branch_name,
												   (Select year_name from cms_yearmaster where cms_yearmaster.year_id = sa.year_id)as year_name,
												   (Select branchyear_name from cms_branchyear where cms_branchyear.branchyear_id = sa.branchyear_id)as branchyear_name,
												   
												   (Select semester_name from cms_semestermaster where cms_semestermaster.semester_id = sa.semester_id)as semester_name,
				   
												   (Select subject_name from cms_subjectmaster where cms_subjectmaster.subject_id = sa.subject_id)as subject_name,
												   (Select employee_name from cms_employeemaster where cms_employeemaster.employee_id = sa.employee_id)as employee_name
												   FROM work_allotment_subject as sa where 1=1 ";

								   //echo $sql;
								   $sql_res = dbQuery($sql);*/
					$objcms_subject_allocationMgmt = new cms_subject_allocationMgmt();
					$sql_res = $objcms_subject_allocationMgmt->getAllRecords1($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "");

					?>
					<script language="javascript" type="text/javascript">
						Ext.onReady(function () {
							new Ext.Panel({ title: "Employee Subject", renderTo: 'pnlDiv2', height: 300, autoScroll: true, width: 600, contentEl: 'contentBirth1' });
						});
					</script>

					<table class="table-report" border="1" cellpadding="0" cellspacing="0">

						</br>
						</br>
						<tr class="x-panel-header x-unselectable">
							<th>
								<center>Course</center>
							</th>
							<th>
								<center>Batch Year</center>
							</th>
							<th>
								<center>Course Year</center>
							</th>
							<th>
								<center>Semester</center>
							</th>
							<th>
								<center>Employee Name</center>
							</th>
							<th>
								<center>Subject Name</center>
							</th>
						</tr>
						<?php
						while ($row1 = dbArray($sql_res)) {
							?>
							<tr>
								<td><?php echo $row1["branch_name"]; ?></td>
								<td><?php echo $row1["year_name"]; ?></td>
								<td><?php echo $row1["branchyear_name"]; ?></td>
								<td><?php echo $row1["semester_name"]; ?></td>
								<td><?php echo $row1["employee_name"]; ?></td>
								<td><?php echo $row1["subject_name"]; ?></td>
							</tr>
							<?php
						}
						?>
					</table>
				</div>
			</div>
		</div>
		<?php
	}

	?>
	</br>
	</br>
	<script src="js/1_5_jquery.js" type="text/javascript"></script>
	<style type="text/css">
		.x-ticker-wrap {
			border: solid 1px black;
			overflow: hidden;
		}

		.x-panel-body {}

		.x-panel-header {
			text-align: center;
		}

		.x-panel-header a {
			text-decoration: none;
			color: #15428B;
		}

		#pnlDiv {
			margin-top: -475px;
			margin-left: 0px;
			margin-right: 750px;
			width: 500px;
		}

		#pnlDivContent {
			padding-left: 5px;
			font-family: Arial, Helvetica, sans-serif;
		}

		#pnlDiv1 {
			float: right;
			margin-top: 29px;
			margin-right: 250px;
			width: 300px;
		}

		#pnlDiv2 {
			float: left;
			margin-top: 147px;
			margin-left: 10px;
			width: 270px;
		}

		#pnlDivContent1 {
			padding-left: 5px;
			font-family: Arial, Helvetica, sans-serif;
		}

		.ntitle {
			font-weight: bold;
			padding-bottom: 5px;
			font-size: 9pt;
			padding-top: 5px;
		}

		.ntitlenotvisite {
			font-weight: bold;
			color: #F00;
			padding-bottom: 5px;
			font-size: 9pt;
			padding-top: 5px;
			text-align: left;
		}

		.ntitlenotvisite a {
			color: #F00;
			text-decoration: none;
		}

		.ntitle a {
			color: #000066;
			text-decoration: none;
		}

		.ntitle a {
			color: #000066;
			text-decoration: none;
		}

		.ndesc {
			padding-bottom: 10px;
			text-indent: 10px;
			font-size: 12px;
		}

		.ndesc a {
			text-decoration: none;
			color: #000000;
		}

		#divnews {
			float: right;
		}

		#divbutton {
			float: left;
			margin-top: 15px;
			margin-left: 25px;
			width: 190px;
		}
	</style>
	<?php
	if (isset($_SESSION["VedantnrUserRole"]) && $_SESSION["VedantnrUserRole"] == "Faculty") {
		dbquery("SET group_concat_max_len = 102400");
		$visitedqry = "SELECT group_concat(distinct circular_id) as circularids 
										FROM cms_circularlog 
										where  employee_Id = '" . $_SESSION['Employee_Id'] . "' order by circular_id ASC";
		$visitedresult = dbQuery($visitedqry);
		while ($visitedrow = dbArray($visitedresult)) {
			$visitedString = $visitedrow['circularids'];
		}
	}

	$server_date = date('Y-m-d');
	$qry = "SELECT * FROM `cms_circularmaster` WHERE `circular_active` = 1 and circular_start_date<='" . $server_date . "' AND circular_end_date >='" . $server_date . "' order by createdon DESC ";
	$result = dbQuery($qry);
	if (dbRows($result) > 0) {
		?>
		<script language="javascript" type="text/javascript">
			Ext.onReady(function () {
				new Ext.Panel({ title: 'Important Notice', renderTo: 'pnlDiv', height: 150, autoScroll: true, width: 500, contentEl: 'pnlDivContent' });
			});
		</script>
		<div style="clear:both"></div>
		<div id="divnews">
			<div id="pnlDiv"></div>
			<div id="pnlDivContent" class="x-hidden">
				<ul>
					<?php
					$circular_type = 0;

					while ($row = dbArray($result)) {
						if (isset($_SESSION["VedantnrUserRole"]) && $_SESSION["VedantnrUserRole"] == "Faculty") {
							if ($row['branch_id'] != "") {
								$branch_id_array = explode(',', $row['branch_id']);
								$emp_branch = $_SESSION['branch_name'];
								if (!in_array($emp_branch, $branch_id_array)) {
									continue;
								}
							}
						}
						if ($row["circular_type"] == 1) {
							$circular_type = "News";
						} else if ($row["circular_type"] == 2) {
							$circular_type = "Circular";
						} else if ($row["circular_type"] == 3) {
							$circular_type = "Notice";
						}


						if (isset($_SESSION["VedantnrUserRole"]) && $_SESSION["VedantnrUserRole"] == "Faculty") {
							if (isset($_SESSION['Employee_Id'])) {
								$empid = $_SESSION['Employee_Id'];
							} else {
								$empid = "";
							}
							if (isset($_SESSION['student_id']) && $_SESSION['student_id'] != NULL) {
								$student_id = $_SESSION['student_id'];
							} else {
								$student_id = "";
							}
							$pos = strpos($visitedString, $row['circular_id']);
							if ($pos === false) {
								?>
								<li>
									<div class="ntitlenotvisite">
										<?php if ($row['circular_file'] != "") { ?>
											<a
												href="download-circular.php?ID=<?php echo $row['circular_id']; ?>&file=<?php echo $row['circular_file'] ?>">
												<?php print "<span style=text-decoration:underline; >" . $circular_type . "</span> -<span style=color:#606;text-decoration:none> " . $row['circular_subject'] . ' [' . date('d M, Y', strtotime($row['createdon'])) . ']' . "</span>"; ?></a>
										<?php } else { ?>
											<?php print "<span style=text-decoration:underline; >" . $circular_type . "</span> -<span style=color:#606;text-decoration:none> " . $row['circular_subject'] . ' [' . date('d M, Y', strtotime($row['createdon'])) . ']' . "</span>"; ?>
										<?php } ?>
									</div>
								</li>

								<?php
							} else {
								?>
								<li>
									<div class="ntitle">
										<?php if ($row['circular_file'] != "") { ?>
											<a
												href="download-circular.php?ID=<?php echo $row['circular_id']; ?>&file=<?php echo $row['circular_file'] ?>">
												<?php print "<span style=text-decoration:underline;>" . $circular_type . "</span> -<span style=color:#606;text-decoration:none>" . $row['circular_subject'] . ' [' . date('d M, Y', strtotime($row['createdon'])) . ']' . "</span>"; ?></a>
										</div>
									<?php } else { ?>
										<?php print "<span style=text-decoration:underline; >" . $circular_type . "</span> -<span style=color:#606;text-decoration:none> " . $row['circular_subject'] . ' [' . date('d M, Y', strtotime($row['createdon'])) . ']' . "</span>"; ?>
									<?php } ?>
								</li>
							<?php }
							$qry = "SELECT * FROM `cms_circularlog` WHERE employee_id='" . $empid . "' AND circular_id = '" . $row['circular_id'] . "'";
							$res = dbQuery($qry);
							if (dbNumRows($res) == 0) {
								dbQuery("INSERT INTO cms_circularlog( circular_id, student_id, employee_id, datetime ) VALUES ( '" . $row['circular_id'] . "', '" . $student_id . "', '" . $empid . "',NOW() )");
							}
						} else {
							?>

							<li>
								<div class="ntitle" style="text-align:left;">
									<?php if ($row['circular_file'] != "") { ?>
										<a
											href="download-circular.php?ID=<?php echo $row["circular_id"]; ?>&file=<?php echo $row["circular_file"]; ?>">
											<?php print "<span style=text-decoration:underline; >" . $circular_type . "</span> -<span style=color:#606;text-decoration:none> " . $row['circular_subject'] . "</span>" . " [ " . date('d M, Y', strtotime($row['createdon'])) . " ]"; ?></a>
									<?php } else { ?>
										<?php print "<span style=text-decoration:underline;color:#000066; >" . $circular_type . "</span> -<span style=color:#606;text-decoration:none> " . $row['circular_subject'] . "</span>" . " [ " . date('d M, Y', strtotime($row['createdon'])) . " ]"; ?>
									<?php } ?>
								</div>
							</li>
						<?php }
					} ?>
				</ul>
			</div>
		<?php } ?>
	</div>
</div>
<?php require "_footer.php"; ?>