<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</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['branch_hidden'] == "" && $_REQUEST['semester_hidden'] == "" && $_REQUEST['subject_hidden'] == "")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-atktlist.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
	ob_start();
	
	$branch_id 	  = Escape($_REQUEST['branch_hidden']);
	$semester_id	= Escape($_REQUEST['semester_hidden']);
	$division_id	= Escape($_REQUEST['division_id']);
	$subject_id	 = Escape($_REQUEST['subject_hidden']);
	$branch_disp 	= Escape($_REQUEST['branch_disp']);
	$semester_disp  = Escape($_REQUEST['semester_disp']);
	$subject_disp   = Escape($_REQUEST['subject_disp']);
	
	$SQL_CONDITION  = "";
	$SQL_STUDENT = "
		SELECT 
			sm.student_id,
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_gturegno,
			student_mobilestudents,
			student_mobileparents,
			sub.subject_name
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd,
			cms_subjectmaster sub,
			cms_atktmaster am
		WHERE 
			sm.student_active = 1 AND 
			
			am.status = 1 AND
			sm.student_id = sd.student_id AND 
			sm.student_id = am.student_id AND 
			am.subject_id = sub.subject_id AND
			am.branch_id = ".$branch_id." AND
			am.semester_id = ".$semester_id." AND
			am.year_id = ".$_SESSION["VedantnrYearId"]." AND
			sub.branch_id = ".$branch_id." AND
			sub.semester_id = ".$semester_id." AND
			sd.cur_branchid = ".$branch_id." AND
			sd.cur_semesterid = ".$semester_id." AND
			sd.cur_divison = '".$division_id."' AND
			sd.year_id = ".$_SESSION["VedantnrYearId"];
			
	if($subject_id != "" && $subject_id != "undefined"){
		$SQL_STUDENT .= " AND sub.subject_id = ".$subject_id;
	}		
		
	$SQL_STUDENT .= " ORDER BY sub.subject_id,student_gturegno ASC ";
	
	$RES_STUDENT = dbQuery($SQL_STUDENT); ?>
    
   
    <?php
	
	if(dbRows($RES_STUDENT) > 0){
		$temp = "";
		?>
         <center><h4>ATKT Student List</h4></center>
	<div>
		<div class="left"><b>Branch</b> : <?php echo $branch_disp." - ".$semester_disp." - ".$division_id;?></div>
		<div class="right"><?php if($subject_id != "" && $subject_id != "undefined"){ ?><b>Subject</b> : <?php echo $subject_disp; } ?></div>
	</div>

    	<table border="1" class="attendance-table-report" cellpadding="0" cellspacing="0" width="100%">
			<tr>
            	<th width="15%" style="text-align:center;">Enrollment No</th>
            	<th width="25%" style="text-align:left;">Student Name</th>
                <th width="15%" style="text-align:center;">Mobile (Student)</th>
                <th width="15%" style="text-align:center;">Mobile (Parents)</th>
            </tr><?php
		$arr = "";
		$i = 0; 
			
		while($REC_STUDENT = dbArray($RES_STUDENT)){
            	if($temp != $REC_STUDENT['subject_name'] && $subject_id == "undefined"){
					$temp = $REC_STUDENT['subject_name']; ?>
        	<tr>
            	<th style="text-align:left;" colspan="4"><?php echo $REC_STUDENT['subject_name']; ?>&nbsp;</th>
            </tr>
            <?php
				}
			?>
            <tr>
            	<td style="text-align:center;"><?php echo $REC_STUDENT['student_gturegno']; ?>&nbsp;</td>
            	<td style="text-align:left;"><?php echo $REC_STUDENT['student_name']; ?>&nbsp;</td>
                <td style="text-align:center;"><?php echo $REC_STUDENT['student_mobilestudents']; ?>&nbsp;</td>
                <td style="text-align:center;"><?php echo $REC_STUDENT['student_mobileparents']; ?>&nbsp;</td>
            </tr><?php
			
		}?>
        </table><?php
	
	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="Student Attendance List";
	$HtmlUrl = "atktlist-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 "<b>No Data Found</b>";
} }
 ?>
</div>
<?php 
	require "_footer.php";
?>