<?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:12px;
		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:5px;
		border-top:0px none;
		border-left:0px none;
	}
	.attendance-table-report th{
		padding:5px;
		font-weight:bold;
		text-align:left;
		border-top:0px none;
		border-left:0px none;
	}	
</style>
<div id="main-report">                                      
<?php
if($_REQUEST['day_date'] == "")
{
?>
	<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']);
	$semester_id	   = Escape($_REQUEST['semester_hidden']);
	$year_id 		 = Escape($_REQUEST['year_hidden']);
	$branchyear_id	   = Escape($_REQUEST['branchyear_hidden']);

	
	$day_date		  = date('Y-m-d',strtotime(str_replace('/','-',Escape($_REQUEST['day_date']))));
	
	if($_SESSION["Employee_Id"]!="" && $_SESSION["Employee_Id"]!=0){
			$where = " and pm.login_id= '".$_SESSION["VedantnrUserId"]."'";
		}
		
	if($branch_id!="" && $branch_id!=0){
		$where.= " and pm.branch_id= '".$branch_id."'";
	}
	if($semester_id!="" && $semester_id!=0){
		$where.= " and pm.semester_id= '".$semester_id."'";
	}
	
	if($_REQUEST["year_name"]!="" && $_REQUEST["year_name"]!=0){
		$where.= " and pm.year_id= '".Escape($_REQUEST["year_name"])."'";
	}

	if($_REQUEST["branchyear_name"]!="" && $_REQUEST["branchyear_name"]!=0){
		$where.= " and pm.branchyear_id= '".Escape($_REQUEST["branchyear_name"])."'";
	}
	
	$where.= " and pm.day_date= '".$day_date."'";
	$objPresentMasterMgmt = new PresentMasterMgmt();		
	$order_field = " branch_name ";
	$order_type = " ASC ";
	$rs = $objPresentMasterMgmt->getpresentdetails($limit,$start,$where,$order_field,$order_type);
	$total=dbRows($rs);
			
	?>
    
    <center><h4>Student Attendance Detail</h4></center>
	<div>
		<div class="left"><b>Date</b> : <?php echo $_REQUEST['day_date']?></div>
	</div>

    <?php
	
		if(dbRows($rs) > 0){?>
    	<table border="1" class="attendance-table-report" cellpadding="0" cellspacing="0" width="100%">
			<tr>
            <th width="5%" style="text-align:center;">Sr</th>
            <th width="8%" style="text-align:center;">Course</th>
			<th width="8%" style="text-align:center;">Batch Year</th>
			<?php if($_REQUEST["branchyear_id"] != "")
				{?>
			<th width="8%" style="text-align:center;">Course Year</th>
			<?php } if($_REQUEST["semester_id"] != "")
				{ ?>
            <th width="8%" style="text-align:center;">Semester</th> 
			<?php
				}?>
            <th width="15%" style="text-align:center;">Subject</th>
            <th width="6%" style="text-align:center;">Batch</th>      
            <th width="6%" style="text-align:center;">Lecture</th>
            <th width="6%" style="text-align:center;">Present</th>
            <th width="6%" style="text-align:center;">Absent</th>
            <th width="20%" style="text-align:center;">Day Comment</th>
            <th width="7%" style="text-align:center;">Present By</th>
            </tr><?php
		$arr = "";
		$i = 0; 
		$sr=1;
		while($row = dbArray($rs)){
			extract($row)
			 ?>
			<tr>
            	<td style="text-align:center;"><?php echo $sr; ?></td>
                <td style="text-align:center;"><?php echo $branch_name; ?></td>
				<td style="text-align:center;"><?php echo $year_name; ?></td>
				<?php if($_REQUEST["branchyear_id"] != "")
				{?>
				<td style="text-align:center;"><?php echo $branchyear_name; ?></td>
				<?php } if($_REQUEST["semester_id"] != "")
				{ ?>
                <td style="text-align:center;"><?php echo $semester_name; ?></td>
				<?php
				}?>
                <td style="text-align:center;"><?php echo $subject_name; ?></td>
                <td style="text-align:center;"><?php echo $batch_name; ?></td>  
                <td style="text-align:center;"><?php echo $lec_name; ?></td>
              
                <?php
				if($row["day_present"] != "")
				{
				$temppr = explode(",",$row["day_present"]);
				$day_present  = count($temppr);
				}
				else
				{
					$day_present=0;
				}
				if($row["day_absent"] != "")
				{
				$tempab = explode(",",$row["day_absent"]);
				$day_absent  = count($tempab);
				}
				else
				{
					$day_absent=0;
				}
				
				?>
                <td style="text-align:center;"><?php echo $day_present; ?></td>
                <td style="text-align:center;"><?php echo $day_absent; ?></td>
                <td style="text-align:center;"><?php echo $day_comment; ?></td>
                <td style="text-align:center;"><?php echo $user_name; ?></td>
            	
            </tr>
		<?php $sr++; }
	?>
        </table><?php
	}
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="";
	$HtmlUrl = "attendancelist-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";
?>
