<?php require "_header.php";?>
<script language="javascript" type="text/javascript">
document.getElementById("main-content").style.display = 'none';
</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;
	}	
</style>

<div id="main-report">
<?php
if($_REQUEST['branch_hidden'] == "")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-Alumni-list.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
	ob_start();
	$branch_id 		= Escape($_REQUEST['branch_hidden']);
	$semester_id	  = Escape($_REQUEST['semester_hidden']);
	$div_id		   = Escape($_REQUEST['division_id']);
	$shift			= Escape($_REQUEST['shift']);
	$branch_disp 	  = Escape($_REQUEST['branch_disp']);
	$semester_disp	= Escape($_REQUEST['semester_disp']);
	
	$order_by 		 = $_REQUEST['hid_orderby'];
	
	$SQL_CONDITION  = "";
	
	$SQL_STUDENT = "
		SELECT 
			sm.student_id,
			leave_date,
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_gturegno,
			student_gender,
			branch_name,
			sm.student_address,
			sm.student_admby,
			sm.student_mobilestudents,
			sm.student_mobileparents, 
			semester_name,
			sd.cur_divison
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd,
			cms_branchmaster bm,
			cms_semestermaster sem
		WHERE 
			sm.student_active = 0 AND 
			sm.leave_type = 'a' AND
			sm.student_id = sd.student_id AND
			
			sd.cur_semesterid = sem.semester_id AND
			sd.cur_branchid = bm.branch_id AND
			sd.year_id != ".$_SESSION["VedantnrYearId"];
	
	if($branch_id != "" && $branch_id != "All"){
		$SQL_CONDITION .= " AND sd.cur_branchid = ".$branch_id;
	}
	if($semester_id != "" && $semester_id != "undefined"){
		$SQL_CONDITION .= " AND sd.cur_semesterid = ".$semester_id;
	}
	if($div_id != ""){
		$SQL_CONDITION .= " AND sd.cur_divison = '".$div_id."'";
	}
	if($shift != ""){
		$SQL_CONDITION .= " AND sd.cur_shift = '".$shift."'";
	}
	
	$SQL_CONDITION .= " GROUP BY sm.student_id ";
	$SQL_CONDITION .= " ORDER BY sd.cur_semesterid ";
	
	if($order_by != "" && $order_by != "undefined"){
		$SQL_CONDITION .= ",".$order_by." ASC ";
	}
	else{
		$SQL_CONDITION .= " ,student_gturegno ASC ";
	}
	
	if($SQL_CONDITION != ""){
		$SQL_STUDENT .= $SQL_CONDITION;
	}
	
	// echo $SQL_STUDENT; exit;
	$RES_STUDENT = dbQuery($SQL_STUDENT);
	
	if(dbRows($RES_STUDENT)>0){?>
        <center><h4>Alumni Student List</h4></center>
        <div align="left"><b>Branch</b> : 
		<?php 
			if($branch_disp != "" && $branch_disp != ":: All ::"){
				echo "<b>Branch</b> : ".$branch_disp;	
				
			}
			if($semester_disp != ""){
				echo " - ".$semester_disp;	
			}
		?></div><br />
		<table class="table-report" border="1" cellpadding="0" cellspacing="0" width="100%">
        <tr>
        	<th width="5%" style="text-align:center;">Sr</th>
           
            <th width="10%" style="text-align:center;">Leave Date</th>
                <th style="text-align:center;" width="8%">Adm. By</th>
            <th width="12%" style="text-align:center;">Enrollment No</th>
            <th width="38%" style="text-align:left;">Student Name</th>
             <th style="text-align:left;"   width="19%">Address</th>
              <th style="text-align:center;" width="10%" >Ph(Parents)</th>
            <th style="text-align:center;" width="10%">Ph(Student)</th>
            <th width="30%" style="text-align:center;">Remarks</th>
        </tr>
        
		<?php
		$i = 1;
		$temp = "";
		while($REC_STUDENT = dbArray($RES_STUDENT)){
			 if(($REC_STUDENT['branch_name'] != $temp && $branch_disp==':: All ::') || ($REC_STUDENT['semester_name'] != $temp1 && $semester_disp=='' ) ){
				$temp = $REC_STUDENT['branch_name'];
				$temp1 = $REC_STUDENT['semester_name'];
				$i = 1;?>
                <tr><th colspan="10"><?php echo strtoupper($temp)."  ".$REC_STUDENT['semester_name'].'-'.$REC_STUDENT['cur_divison']; ?></th></tr><?php
			}?>
            <tr>
                <td style="text-align:center;">&nbsp;<?php echo $i++; ?></td>
            
                <td style="text-align:center;">&nbsp;<?php echo date("d-m-Y",strtotime($REC_STUDENT['leave_date'])); ?></td>
              <td style="text-align:center;"><?php  echo $REC_STUDENT['student_admby'];?></td>
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_gturegno']; ?></td>
                <td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_name']; ?></td>
                  <td style="text-align:left;">&nbsp;<?php echo $REC_STUDENT['student_address']; ?></td>
                   <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_mobileparents']; ?></td>
                <td style="text-align:center;">&nbsp;<?php echo $REC_STUDENT['student_mobilestudents']; ?></td>
                <td style="text-align:center;">&nbsp;</td>
       		</tr><?php
		}
		?>
		</table>
		<?php
	}
	else{
		echo "NO DATA FOUND!";	
	}
	
?>

<?php

	$HtmlCode = ob_get_contents();
	ob_end_flush();
	$header_row_string="Student Attendance Sheet";
	$HtmlUrl = "Alumnilist-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";
?>
