<?php require "_header.php";
?>
<div id="main-content" >
<style>
.x-panel-header a { text-decoration:none;color:#15428B;}
table.report-color{
font-family:Georgia, "Times New Roman", Times, serif;
}
table.report-color th
{
	font-size: 12px;
	font-weight: bold;
	padding: 2px 2px;
	border: 1px medium #CCC;
	color: #039;
	background: #d0dafd;
}
table.report-color td
{
	padding: 2px 2px;
	font-size: 12px;
	font-weight: 100;
	border: 1px medium #fff;
	color: #669;
	background: #eff2ff;
}
table.report-color tr:hover td
{
	background: #d0dafd;
	color: #339;
}
</style>
<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="student-download.php" >Download</a></div>
    <div class="x-panel-header" style="margin-bottom:5px;"><a href="logout.php" >Logout</a></div>
</div>
</span>
<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:25px;margin-left:5px;margin-right:15px; width:500px;}
		#pnlDivContent {padding-left:5px;font-family:Arial,Helvetica,sans-serif;}
		#pnlDiv1 {margin-top:10px;margin-left:25px;margin-right:25px;width:300px;}
		#pnlDivContent1 {padding-left:5px;font-family:Arial,Helvetica,sans-serif;}
		.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 {font-weight:bold;padding-bottom:5px;font-size:9pt;padding-top:5px;text-align:left;}
		.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
	 dbquery("SET group_concat_max_len = 102400");
	  $visitedqry ="SELECT group_concat(distinct circular_id) as circularids 
	  				FROM cms_circularlog 
					where  student_id = '". $_SESSION['student_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 all_student_id='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:300, autoScroll:true, width: 500,contentEl: 'pnlDivContent'});
	});
</script>
<div id="divnews">
    <div id="pnlDiv"></div>
    <div id="pnlDivContent" class="x-hidden">
		<ul>
		<?php 
		$circular_type=0;
		if(isset($_SESSION['student_id']) && $_SESSION['student_id']!= NULL){
		$student_id = $_SESSION['student_id'];
		}
		else {
			$student_id = "";
		}
		if(isset($_SESSION['employee_id']) && $_SESSION['employee_id']!= NULL){
			$emp_id = $_SESSION['employee_id'];
		}else{
			$emp_id="";
		}
		
		while($row = dbArray($result)){
		if($row['branch_id']!=""){
			$branch_id_array=explode(',',$row['branch_id']);
			$studemt_branch=$_SESSION['cur_branchid'];
			if(!in_array($studemt_branch,$branch_id_array)){
			continue;
			}
		
		}
		if($row['semester_id']!=""){
			$semester_id_array=explode(',',$row['semester_id']);
			$studemt_semester=$_SESSION['cur_semesterid'];
			if(!in_array($studemt_semester,$semester_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";
		}
		$createdon= date('d-m-Y',strtotime($row["createdon"]));	
		$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'].' ['.$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'].' ['.$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'].' ['.$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'].' ['.$createdon.']'."</span>"; ?>
                <?php } ?>
			</li>
		<?php } 
		$qry= "SELECT * FROM `cms_circularlog` WHERE student_id='".$student_id."' 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."', '".$emp_id."',NOW() )");
		} }?>
		</ul>
	<?php } ?>
	</div>
</div>
</div>
</div>
<?php require "_footer.php";?>