<?php
session_start();
require_once("includes/initialize.php");
global $database;
// global $mail;
date_default_timezone_set('Africa/Lagos');
ini_set('max_execution_time', 300);



$alldept = ONLINEPAY::showdept();

// date_default_timezone_set('Africa/Lagos');
// $dprepare ="";
$allsession = ONLINEPAY::showsession();

// $tag = $_GET['type'];
// $_SESSION['tablename'] =$tag;

$_SESSION['ptype']='Testpass';

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

$allsession = ONLINEPAY:: showsession();

$semesters = ONLINEPAY:: showsemester();




 $output=''; $output2='';$prog='';
  $course_arr=array();
 $courses='';
                

// //if(isset($_POST['fac']) || ($_POST['dpt']))
 if (isset($_POST['search']))
 {
 
 $dept = $_POST['department'];
 $session = $_POST['session'];
 $level = $_POST['level'];

  $semester = $_POST['semester'];
  
  
  
  
  $_SESSION['dept']= $dept;
  $_SESSION['sess']= $session;
  $_SESSION['lev']= $level;
 $_SESSION['semester']= $semester;
 
 
  
  switch ($level)
  {
  case 'ND I':
      $table='admitted_student_details_2019';
      $ctable='ndi_tbl';
      $ses_sem_id=1;
    break;  
  case 'HND I':
      $table='admitted_student_details_2019';
       $ctable='hndi_tbl';
        $ses_sem_id=1;
       
       break;
  case 'ND II':
      $table='admitted_student_details';
      // $ctable='ndii_tbl';
      $date='2019-12-03';
       $ctable='ndi_tbl';
        $ses_sem_id=1;
       break;
  case 'HND II': 
       $table='admitted_student_details';
       //$ctable='hndii_tbl';
        $date='2019-12-09';
        $ctable='hndi_tbl';
       $ses_sem_id=1;
         
  }
  
  $_SESSION['ses_sem_id'] =  $ses_sem_id;
  $table2="student_activity_level";
  //echo $table;
  $paydetails=array();
 $count = 0; $total_sum=0; $brief='';

    if ($level=='ND I'){
        $nlevel =substr($level, 0,2);
    }else{
       $nlevel =substr($level, 0,3); 
    }
   
   
   //echo "guyy: ".$nlevel." po:m ". $level."<br>";
    //if ($level=='ND II'){ 
    //echo $ctable."    ?".$dept."     ?".$ses_sem_id."    ?".$date;
        
     $regnoresult = ONLINEPAY::shownoresult($ctable,$dept,$ses_sem_id,$date);   
        
        
     // print_r($regnoresult);  
     
    }
          
     //   }
        
      
        
            
  ?>          
            
  
<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 $Hod;?> Head of Department</h2><br/>
			    <form method="post" action="?type=noresult" enctype="multipart/form-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 I">ND I</option>
                	                    <option value="ND II">ND II</option>
                	                    <option value="HND I">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>
                				
        					      
        					</tr> 
                        </table>
					</div>
					
					
					
					 <div class="panel panel-primary chat-panel">
                    <div class="panel-heading ">
                     <h3><? echo $msg;?></h3>
                    </div><br/>
                <div class="table-responsive">
                    <table class="table table-bordered table-hover table-condensed" id="fo_table">
                   
                    <thead>
                        <tr>
                            <th colspan="3" style="text-align: center"><h1>Department: <?php echo $_SESSION['dept']; ?></h1></th>
                            </tr>
                            
                            <tr>
                            <th><strong>Session: <?php echo $semester; ?></strong></th>
                            
                             <th><strong>Level: <?php echo $level; ?></strong></th>
                             
                             <th><strong>Semester: <?php echo $semester; ?></strong></th>
                        </tr>
                             
                             <tr><th colspan="3"></th></tr>
                              <tr>
                                
                                
                                     <th>S/N</th>  
                                         <th>MATRIC NO</th>  
                                         
                                         <th>FULLNAME</th>     
                                          
                                     </tr>
                                
                              </tr>
                     </thead>   
                        
                        <?php
                        
                  if (isset($regnoresult)){
                        foreach ( $regnoresult as $student){
                        
                       // echo $student->matricno;
                       $matr = ONLINEPAY::getMatricNoRes($student->matricno);
                       
                       //echo $table.''. $student->matricno.''.$matr->matricno;
                       $st = ONLINEPAY::search_by_formno_18($table, $student->matricno);
                       
                       //echo $st->surname.' '.$st->othernames;
					   echo '<tr>'
 							.'<td>'.++$count.'</td>'
 							.'<td>'.$matr->matricno.'</td>'
 							.'<td>'.strtoupper($st->surname.' '.$st->othernames).'</td>
 							
 							
 							
 						</tr>'; 
                     } 
                  }   
                  
                        
                            
                            
                        
                        
                        ?>
					
					 </table>;
					 </div>
                    </div>
					
					
			    </form>
			    
                 </div>
                 
                 
    </body>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
        <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>

    
<script>
  {
    $('#fo_table').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
    ]
});
  }
</script>
            
            
            
            
            
            
