<?php 
require_once("../includes/initialize.php");
// $alldept = ONLINEPAY:: showdept();
// $dprepare ="";
date_default_timezone_set('Africa/Lagos');
session_start();
$fo = $_SESSION["$fo"];
$faculty_dept = ONLINEPAY:: showdept_byf($fo);
$allsession = ONLINEPAY:: showsession();

$admitted_list = ONLINEPAY:: joined_tables();

// $formno = $admitted_list->formno;
// $surname = $admitted_list->surname;
// $othernames = $admitted_list->othernames;
// $email = $admitted_list->email;
// $department = $admitted_list->courses;
// $sex = $admitted_list->sex;
// $sex = $admitted_list->programme; 
$count = 0;

// SELECT formno, COUNT(formno) FROM  admitted_student GROUP BY formno HAVING COUNT(formno) > 1;
// DELETE t1 FROM admitted_student t1 INNER JOIN admitted_student t2 WHERE t1.id < t2.id AND t1.formno = t2.formno;
// DELETE t1 FROM student_activity_level t1 INNER JOIN student_activity_level t2 WHERE t1.std_process_id < t2.std_process_id AND t1.formno = t2.formno;
// DELETE t1 FROM student_activity_level t1 INNER JOIN student_activity_level t2 WHERE t1.id > t2.id AND t1.formno = t2.formno

?>
<title>OSCOTECH::Admitted</title>
           <!-- <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://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
           
           
  <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>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css"/>
           
<div class="container" style="width:1000px;"> 
    <div class="table-responsive"> 
        <?php
        
        echo '<table id="mytable" class="table table-striped table-bordered">
            <thead>
                  <tr>
                      <th>S/N</th>  
                      <th>FORM NO</th>
                      <th>SURNAME</th>     
                      <th>OTHER NAMES</th>  
                      <th>EMAIL</th>  
                      <th>DEPARTMENT</th>
                      <th>SEX</th>
                      <th>LEVEL</th>
                      <th>SESSION</th>
                      <th>FACULTY</th>                         
                  </tr>
            </thead>';
    		foreach($admitted_list as $admitted_list) 
            {
                $formno = $admitted_list->formno;
                $surname = $admitted_list->surname;
                $othername = $admitted_list->othernames;
                $email = $admitted_list->email;
                $department = $admitted_list->courses;
                $sex = $admitted_list->sex;
                $level = $admitted_list->programme;
                $session = $admitted_list->session;
                $date = date('d/m/Y');
                
                // $query = ONLINEPAY::insert_table($formno,$surname,$othername,$email,$department,$sex,$level,$session,$date);
                
              echo  '<tr>'
                    .'<td>'.++$count.'</td>'
					.'<td>'.$formno.'</td>'
					.'<td>'.$surname.'</td>'
					.'<td>'.$othername.'</td>'
					.'<td>'.$email.'</td>'
					.'<td>'.$department.'</td>'
					.'<td>'.$sex.'</td>'
					.'<td>'.$level.'</td>'
					.'<td>'.$session.'</td>'
					.'<td>'.$date.'</td>'
				.'</tr>'; 
            }
          '</table>'
          
          
          
          
?>
</div>
<div>
    <form method="post">  
        <input type="submit" name="insert" id = "insert" class="btn btn-danger" value="Insert" />  
    </form> </div> 
</div>


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

// $("#mytable").DataTable({
//   "processing" : true,
//   "serverSide" : true
//   dom: 'lBfrtip',
//   buttons: [
//     'excel', 'csv', 'pdf', 'copy'
//   ],
//   "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
//   });

// var table = $('#mytable').DataTable();
 
// table.buttons( 'output:name', '.export' ).enable();


});
</script>