<?php 
require_once("./includes/initialize.php");
session_start();
$fo = $_SESSION["$fo"];
$faculty_dept = ONLINEPAY:: showdept_byf($fo);
$allsession = ONLINEPAY:: showsession();
$alldept = ONLINEPAY:: showdept();
$semesters = ONLINEPAY:: showsemester();

$count=0;
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
	<title>Registered Students</title>
	
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
   <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>  
   <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>            
   <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
</head>
   <body>       
		<div class="container" align="center">
			<h2 align="center">Registered Students :: <?php echo $fo;?> </h2><br/>
			    <form method="post">
			        <div class="form-group input-group" align="center">
			            <table class="table table-bordered table-hover" align="center">
                        	<tr>
                            	<td>
                					<select name="department" id="department" class="form-control action" style="width:200px">
                						<option value="">Select Department</option>
                							<?php foreach($alldept as $dept){?>
                							<option value="<?php echo $dept->department;?>"><?php 
                							echo strtolower($dept->department);?></option> <?php }?>
                					</select></td>
        					    <td>
                					<select name="level" id="level" class="form-control action" style="width:120px">
                						<option value="">Select Level</option>
                						<option value="ND">ND I</option>
                	                    <option value="ND II">ND II</option>
                	                    <option value="HND">HND I</option>
                	                    <option value="HND II">HND II</option>		
                					</select></td>
        					    <td>
                					<select name="session" id="session" class="form-control action" style="width:120px">
                						<option value="">Select Session</option>
                						<?php foreach($allsession as $session){?>
                						<option value="<?php echo $session->session;?>"><?php 
                						echo $session->session?></option><?php }?>
                					</select></td>
                                <td>
                                    <select name="semester" id="semester" class="form-control action" style="width:120px">
                                        <option value="">Select Semester</option>
                                        <?php foreach($semesters as $sem){?>
                                        <option value="<?php echo $sem->semester;?>"><?php 
                                        echo $sem->semester?></option><?php }?>
                                    </select></td>
                					<td>
                					    <div class="col-md-4">
                                            <input type="submit" name="search" id ="search" value="Search" class="btn btn-info" />
                                        </div>
                					</td>
                					<td>
        					            <input type="submit" name="Print_pdf" id ="Print_pdf" class="btn btn-danger" value="Print PDF" />
                					</td>
        					</tr> 
                        </table>
					</div>
                
                     </form>
                      <div class="table-responsive" align="center">
                     <table id="mytable" class="table table-bordered table-hover" style = "height:20px">  
                            <thead>
                                <tr>  
                                    <th width="5%">S/N</th>  
                                    <th width="10%">FORM NO</th>
                                    <th width="15%">SURNAME</th>
                                    <th width="40%">OTHER NAMES</th>
                                    <th width="40%">DEPARTMENT</th>
                                    <th width="50%">COURSES</th>
                                    <th width="30%">REGISTERED DATE</th>
                               </tr>  
                            </thead>
                        </table>
                    </div>
        </div>
    </body>
</html>

<script>

$(document).ready(function(){
     
$('#search').on("click",function(e){
    
    e.preventDefault(e);
    
    var department = $('#department').val();
    var level = $('#level').val();
    var session = $('#session').val();
    var semester = $('#semester').val();
        {
            $.ajax({
            	url:"fetch_RegStudent.php",
            	method:"POST",
            	data:{department:department,level:level,session:session,semester:semester},
            	success:function(data)
            	{
            	    if(data)
            	    {
            	        $("#mytable").html(data);
            	    }
            	    else
            	    {
            	        alert('Error!!!')
            	    }
            	}
            });
        }
 });
 
 $('#Print_pdf').on("click", function(e){
    e.preventDefault(e);
    
        {
		    window.open("RegReport.php");
        }
 });
     
     
//     $('#session').on("change",function(e){
//         e.preventDefault(e);
// 		if($(this).val() != '')
// 		{
// 			var department = $('#department').val();
// 			var level = $('#level').val();
// 			var session = $('#session').val();		
// 			{
// 				$.ajax({
// 					method:"POST",
// 					url:"fetch_data.php",
// 					data:{department:department,level:level,session:session},
// 					success:function(data)
// 					{
// 						$("#fo_table").html(data);
// 					}
// 				})
// 			}
// 		}
// 	});   
	
// 	$('#department').on("change",function(e){
//         e.preventDefault(e);
// 		if($(this).val() != '')
// 		{
// 			var department = $('#department').val();
// 			var level = $('#level').val();
// 			var session = $('#session').val();			
// 			{
// 				$.ajax({
// 					method:"POST",
// 					url:"fetch_data.php",
// 					data:{department:department,level:level,session:session},
// 					success:function(data)
// 					{
// 						$("#fo_table").html(data);
// 					}
// 				})
// 			}
// 		}
// 	});   
	
	
// 	$('#level').on("change",function(e){
//         e.preventDefault(e);
// 		if($(this).val() != '')
// 		{
// 			var department = $('#department').val();
// 			var level = $('#level').val();
// 			var session = $('#session').val();		
// 			{
// 				$.ajax({
// 					method:"POST",
// 					url:"fetch_data.php",
// 					data:{department:department,level:level,session:session},
// 					success:function(data)
// 					{
// 						$("#fo_table").html(data);
// 					}
// 				})
// 			}
// 		}
// 	});
	
	
	
	
     
//     var dataTable =  $('#mytable').DataTable( {
// 		processing:true,
// 		serverSide: true,
//             ajax{
//             	url:"fetch_RegStudent.php",
//             	method:"POST",
//             	data:{
//             "department" :$('#department').val(),
//             "level" : $('#level').val(),
//             "session" : $('#session').val(),
//             "semester" : $('#semester').val();
//             	},
//             	success:function(data)
//             },
// 		"ajax": {
//  			"url": "/*php echo base_url('data/ajax'); ?>",*/
// 			"type": "POST",
// 			"data":function(data) {},
// 		},
		
// 	} ); 
	
	
	
	
	
	
        
 });  
</script>  


