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

$Hod = $_SESSION["$HoD"];
// print_r($Hod);

$allsession = ONLINEPAY:: showsession();

$semesters = ONLINEPAY:: showsemester();

$count=0;



global $database;
$mat = array();
$mat2 = array();
session_start();

//   $department = $_POST['department'];
//   $level = $_POST['level'];
//   $session = $_POST['session'];
//   $semester = $_POST['semester'];
//   $batch = $_POST['batch'];
  
//   $_SESSION['department'] =  $department;
//  $_SESSION['level'] =  $level;
//  $_SESSION['session'] =  $session;
//  $_SESSION['semester'] =  $semester;
//  $_SESSION['batch'] =  $batch;
  
    // $get_id = ONLINEPAY::get_ses_sem_id($session,$semester);
  
 
$count = 0;
  
if(isset($_POST['search']))
{
    $department = $_POST['department'];
    $level = $_POST['level'];
    $session = $_POST['session'];
    $semester = $_POST['semester'];
    // $id = 1;//$get_id->ses_sem_id;
    
    $_SESSION['department'] =  $department;
 $_SESSION['level'] =  $level;
 $_SESSION['session'] =  $session;
 $_SESSION['semester'] =  $semester;
    
    
    $get_id = ONLINEPAY::get_ses_sem_id($session,$semester);
    foreach ($get_id as $reg){ $id =$reg->ses_sem_id; }
    
    // echo 'Hello'.$id.$semester.$session.$level.$department;
    if ($level == 'ND' && $semester=='First')
    {
        $table = 'ndi_tbl';
        $Epass = ONLINEPAY :: student_EpassFirst($table,$department,$id);
        
        //print_r($Epass);
    }elseif ($level == 'ND' && $semester=='Second')
    {
         $table = 'ndi_tbl';
        $Epass = ONLINEPAY :: student_Epass($table,$department,$id);
    }
    elseif ($level == 'ND II')
    {
        $table = 'ndii_tbl';
        $Epass = ONLINEPAY :: student_Epass($table,$department,$id);
    }
    elseif ($level == 'HND' && $semester=='First')
    {
         $table = 'hndi_tbl';
         $Epass = ONLINEPAY :: student_EpassFirst($table,$department,$id);
    } 
    elseif ($level == 'HND' && $semester=='Second')
    {
         $table = 'hndi_tbl';
         $Epass = ONLINEPAY :: student_Epass($table,$department,$id);
    }
    elseif ($level == 'HND II')
    {
         $table = 'hndii_tbl';
        $Epass = ONLINEPAY :: student_Epass($table,$department,$id);
    }
    
    
    else{ echo "Error 442";}
    
  
}?>





















<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>
    <body> 
    
     
    
		<div class="container" align="center">
			<h2 align="center">Welcome :: <?php echo ucwords(strtolower($_SESSION['access_level']));?> Head of Department</h2><br/>
			    <form method="post" id="insert_data">
			        <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 if (is_array($Hod))
                							{
                							    foreach($Hod as $dept)
                							{ ?>
                							<option value="<?php echo $dept;?>"><?php 
                							echo strtoupper($dept);?></option> <?php }}
                							else 
                							{?>
                							    <option value="<?php echo $Hod;?>"><?php 
                							echo strtoupper($Hod);?></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 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>-->
                                    <!--<select name="batch" id="batch" class="form-control action" style="width:120px">-->
                                    <!--    <option value="">Select Matric Batch</option>-->
                                    <!--    <option value="1">Batch 1</option>-->
                                    <!--    <option value="2">Batch 2</option>-->
                                    <!--    <option value="3">Batch 3</option>-->
                                    <!--    <option value="4">Batch 4</option>-->
                                    <!--</select></td>-->
                					<td>
                					    <div class="col-md-4">
                                            <input type="submit" name="search" id ="search" value="View" class="btn btn-info" />
                                        </div>
                					</td>
                					<td>
        					            <input type="submit" name="Print_pdf" id ="Print_pdf" class="btn btn-danger" value="Print All (PDF)" />
                					</td>
        					</tr> 
                        </table>
					</div>
			    </form>
                <div class="table-responsive">  
                    <div id="showboard" style="width:90%; height = 70; overflow:auto; ">
                        <table id="mytable" class="table table-bordered table-hover" style = "height:20">  
                   <?php
                   
                      echo '<table id="mytable" class="table table-bordered table-hover" style = "height:20px">  
            <thead>
                <tr>  
                    <th width="5%">S/N</th>
                    <th width="10%">MATRIC 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>';
      
      if (isset($Epass)){      
            //print_r($Epass);
    foreach($Epass as $pay) 
    {
        //echo "<br>Tests: ".$pay->formno." UUUUU: ".$pay->matricno;
        $row = ONLINEPAY:: Epass_detailsFirst($pay->formno);
        //$mat[] = $pay->matricno;
    
            $surname = $row->surname;
           $othernames = $row->othernames;
         $pix = substr($row->pix,11);
           $sex = $row->sex;
        
        echo '<tr>'
				.'<td>'.++$count.'</td>'
				.'<td>'.$pay->matricno.'</td>'
				.'<td>'.strtoupper($surname).'</td>'
				.'<td>'.strtoupper($othernames).'</td>'
				.'<td>'.$pay->department.'</td>'
				.'<td>'.$pay->courses.'</td>'
				.'<td>
                    	<p style=" text-transform:uppercase; color:#030; font-size:14px; font-weight:bolder; font-stretch:extra-expanded">
                    	'.$pay->regDate." ".$pay->formno.
                    	
                    	
'</p>
                </td>'
			.'</tr>'; 
			
		//	echo "NM: ".$pix;
			$all_stu_data[]= array($pay->matricno,$surname,$othernames,$department,$pix, $sex);
			
    }
    
      }
    echo '</table>';
    
    //***********************************
    
//<a href="./Report_E.php?formno='.$pay->formno.'&email='.$pay->email.'" target ="_new"> <input type="button" class ="print" value="Exam-Pass" /></a>
  
  //+++++++++++++++++++++++++++++++++++++
  
  $_SESSION['names'] = $mat;
  $_SESSION['names2'] = $mat2;
 
  $name = $_SESSION['names'];
 $name2 = $_SESSION['names2'];
$_SESSION['all_stu_data']= $all_stu_data;
                   
            ?>       
                        </table>
                    </div>
                     <!--</form>  -->
                 </div>
    </body>
<script>
 
 /*$(document).ready(function(){
     
$('#searchrr').on("click", function(e){
    e.preventDefault(e);
    
    var department = $('#department').val();
    var level = $('#level').val();
    var session = $('#session').val();
    var semester = $('#semester').val();
    // var batch = $('#batch').val();
    alert(department+level+session+semester);
        {
            $.ajax({
            	url:"fetch_exampass2.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");
		    
		     window.open("RegReportAllPass.php");
        }
 });   
	
        
 });  */
 </script>  
 
 
 
 <script type="text/javascript">




$(document).ready(function() {
    
$('#Print_pdf').on("click", function(e){
    e.preventDefault(e);
    
   
        {
    		//window.open("certificate_report2.php");
    		window.open("RegReportAllPass.php");
        }
 });
    
});

</script>
