<?php 
require_once("includes/initialize.php");
$alldept = ONLINEPAY:: showdept();

session_start();
$allsession = ONLINEPAY:: showsession();

   ?>
<head>
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  
           <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
           <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://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
  </head>
           <!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />-->
    <body>       
		<div class="container">
			<h2 align="center">Welcome :: <?php echo $fo;?> Admission Officer</h2><br/>
			    <form method="POST" >
			        <div class="form-group input-group" align="center">
			           <!-- <div class="col-md-4" align= "center">
                            <input type="text" name="formno" id="formno" class="form-control" placeholder="Form No" style="width:120px"/>
                            <input type="submit" name="f_find" id ="f_find" class="btn btn-success" value="Get FormNo"/>
                        </div> --> <br><br>
			            <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>
                						<option value="">All Department</option>
                							<?php foreach($alldept as $dept){?>
                							<option value="<?php echo $dept->department;?>"><?php 
                							echo ucwords($dept->department);?></option> <?php }?>
                					</select></td>
                					<td>
                					<select name="prog" id="prog" class="form-control action" style="width:120px">
                						<option value="">Select Programme</option>
                						<option value="FT">FT</option>
                	                    <option value="DP">DPT</option>		
                					</select></td>
        					    <td>
                					<select name="level" id="level" class="form-control action" style="width:120px">
                						<option value="">Select Level</option>
                						<option value="ND">ND</option>
                	                    <option value="HND">HND</option>
                	                    <option value="PGD">PGD</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>
                                    <div class="input-daterange">
                                        <div class="col-md-4">
                                            <input type="text" name="start_date" id="start_date" class="form-control" placeholder="From:StartDate"/>
                                        </div>
                                        
                                        <div class="col-md-4">
                                            <input type="text" name="end_date" id="end_date" class="form-control" placeholder="To:EndDate"/>
                                        </div>
                                    </div></td> -->
                                    <td>
                                    <div class="col-md-4">
                                        <input type="submit" name="search" id ="search" value="Search" class="btn btn-info" />
                                    </div> 
            					</td>
            					<td>
            					    <div>
            					        <input type="submit" name="Print_pdf" id ="Print_pdf" class="btn btn-danger" value="Print PDF" />
            					    </div>
            					</td>
        					</tr>
                        </table>
					</div>
			    <!--</form>-->
			    <div class="panel panel-primary chat-panel">
                        <div class="panel-heading ">
                            Student Admitted Table
                        </div>
                <div class="table-responsive">  
                    <div class="dataTable_wrapper" id="showboard" style="height:400px; overflow:scroll; ">
                        <table id="admin_table" class="table table-bordered table-hover" style = "height:20px">  
                            <!--<thead>-->
                            <!--    <tr height="20">  -->
                            <!--        <th width="5%">S/N</th>  -->
                            <!--        <th width="10%">FORM NO</th>  -->
                            <!--        <th width="20%">SURNAME</th>  -->
                            <!--        <th width="30%">OTHER NAMES</th>  -->
                            <!--        <th width="45%">DEPARTMENT</th>-->
                            <!--        <th width="10%">LEVEL</th>-->
                            <!--        <th width="10%">SESSION</th>-->
                            <!--        <th width="10%">DATE/TIME</th>-->
                            <!--   </tr>  -->
                            <!--</thead>-->
                        </table>
                    </div></div>
                     </form>
    </body>
    
<script type="text/javascript" language="javascript" >

 $(document).ready(function(){
$('#search').on("click", function(e){
    e.preventDefault(e);
    
    var department = $('#department').val();
    var level = $('#level').val();
    var prog = $('#prog').val();
    var session = $('#session').val();
    var start_date = $('#start_date').val();
    var end_date = $('#end_date').val();
        {
            $.ajax({
            	url:"admin_fetch.php",
            	method:"POST",
            	data:{department:department,level:level,prog:prog,session:session,start_date:start_date},
            	success:function(data)
            	{
            		$data = $("#admin_table").html(data);
            // 		window.open('admin_report.php');
            	}
            });
        }
 });


$('#Print_pdf').on("click", function(e){
    e.preventDefault(e);
    
        {
            // $.ajax({
            // 	url:"admin_report.php",
            // 	method:"POST",
            // 	data:{department:department,level:level,session:session,start_date:start_date,end_date:end_date},
            // 	success:function(data)
            // 	{
            		window.open("admin_report.php");
            // 	}
            // });
        }
 });

    
    
$('.input-daterange').datepicker({
  todayBtn:'linked',
  format: "yyyy-mm-dd",
  autoclose: true
 });

//  fetch_data('no');

 function fetch_list(department,level,session)
 {
  var dataTable = $('#admin_table').DataTable({
   "processing" : true,
   "serverSide" : true,
   "admin" : [],
   "ajax" : {
    url:"admin_fetch.php",
    type:"POST",
    data:{department:department,level:level,session:session,prog:prog}
   }
  });
 }
 
function fetch_data(is_date_search,start_date,end_date ='')
 {
  var dataTable = $('#admin_table').DataTable({
   "processing" : true,
   "serverSide" : true,
   "admin" : [],
   "ajax" : {
    url:"admin_fetch.php",
    type:"POST",
    // "dataSrc": ""
    data:{
     is_date_search:is_date_search, start_date:start_date, end_date:end_date
   }
   }
  });
 }

 $('#formno').change(function(e){
    if($(this).val() != '')
    {
        var formno = $('#formno').val();
        {
            $.ajax({
        	url:"admin_fetch.php",
        	method:"POST",
        	data:{formno:formno},
        	success:function(data)
        	{
        		$("#admin_table").html(data);
        	}
            });
        }
    }
    else
    {
        alert("formno Field is Required");
    }
 });
 
 
 
  $('#f_find').click(function(e){
    e.preventDefault(e);
    if($(this).val() != '')
    {
        var formno = $('#formno').val();alert(formno);
        {
            $.ajax({
        	url:"admin_fetch.php",
        	method:"POST",
        	data:{formno:formno},
        	success:function(data)
        	{
        	    $("#admin_table").html(data);
        	}
            });
        }
    }
    else
    {
        alert("formno Field is Required");
    }
 });
        
 });
 </script>