<?php 
//require_once("includes/initialize.php");





global $database;
$alldept = ONLINEPAY:: showdept();
$allsession = ONLINEPAY:: showsession();
//session_start();

if (isset($_POST['search']))
{
   $department = $_POST['department'];
   $level = $_POST['level'];
   $session = $_POST['session'];
   $formno = $_POST['formno'];
   $prog = $_POST['programme'];
  
   
    
    // $_SESSION['level'] =  $lev;
    // $_SESSION['programme'] =  $prog;
    // $_SESSION['gender'] = $gend;
    // if( $prog != "" && $department!="" && $session!="")
    // {
        
        // $query = "SELECT * FROM `admission_list` WHERE `formno` LIKE '%$prog%' AND `department` = '$department' AND session = '$session'";
        
        if ((($level=='ND') or ($level=='HND')) and ($department!='')){
            
            //echo $level.$department."t";
        
        
           $result= ONLINEPAY::getStudent($level, $prog, $department);
        
        }else if ((($level=='ND I') or ($level=='HND I')) and ($department!='')){
            
            //echo $level.$department."r";
            
            $result= ONLINEPAY::getStudentI($level, $prog, $department);
        
      
        }
        
        
        else if ((($level=='ND') or ($level=='HND')) and ($department=='')){
        
        //echo $level.$department."u";
        
         $result= ONLINEPAY::getStudentII($level, $prog, $department);
       $query = "";
       
        } else if ((($level=='ND I') or ($level=='HND I')) and ($department=='')){
            
            //echo $level.$department."y";
            
            $result= ONLINEPAY::getStudentIII($level, $prog);
            
             //$query = "";
            
        }
         //$result = mysql_query($query) or die(mysql_error());
   // }
    
    // if($department =="" && $level !="" && $session !="")
    // {
    //     $quy = "SELECT COUNT(admission_list.formno), admission_list.department FROM admission_list JOIN admitted_student_details_2019 
    //                 ON admitted_student_details_2019.formno = admission_list.formno WHERE admission_list.formno LIKE '%$prog%'
    //                 AND admitted_student_details_2019.level LIKE '{$level}' 
    //                 AND admission_list.session LIKE '{$session}' GROUP BY department";
        
    //     $rest = mysql_query($quy) or die(mysql_error());
    // }
    
    if ($level == 'ND' && $prog == 'PU')
    {
        $msg = 'ND I On Full-Time Programme ';
    }
    elseif ($level == 'ND' && $prog == 'DP')
    {
        $msg = 'ND I On Daily Part-Time Programme ';
    }elseif ($level == 'HND' && $prog == 'FT')
    {
        $msg = 'HND I On Full-Time Programme ';
    }elseif ($level == 'HND' && $prog == 'DP')
    {
        $msg = 'HND I On Daily Part-Time Programme';
        
    }elseif ($level == 'ND I' && $prog == 'PU')
    {
        $msg = 'ND II On Full-Time Programme ';
    }
    elseif ($level == 'ND I' && $prog == 'DP')
    {
        $msg = 'ND II On Daily Part-Time Programme ';
    }elseif ($level == 'HND I' && $prog == 'FT')
    {
        $msg = 'HND II On Full-Time Programme ';
    }elseif ($level == 'HND I' && $prog == 'DP')
    {
        $msg = 'HND II On Daily Part-Time Programme';
    }

    
}
$count = 0;

?>



<html>
 <head>
  <title>Gender-Generate</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
    <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"/>
 </head>
 <body>
  <div class="container box">
   <h2 align="center">
       <?php /*
       if (($level=='ND') OR ($level=='HND')){
       echo 'STATISTICS OF UPLOADED STUDENTS IN '.$level.' I'.'<br><br> AS AT '.$date = date('m/d/Y h:i:s a', time());
       
       }else if (($level=='ND I') OR ($level=='HND I')){
       
       echo 'STATISTICS OF REGISTERED STUDENTS IN '.$level.'I'.'<br><br> AS AT '.$date = date('m/d/Y h:i:s a', time());
       } */
       ?> </h2>
   <h3 align="center"></h3>
   <br />
   <form method="POST" action="">                        	
    	<div class="form-group input-group" align="center">
    	<table class="table table-bordered table-hover">
        	<tr>
        	    
        	    <td>
				<select name="department" id="department" class="form-control action" style="width:200px">
					<option value="">Select Department</option>
					<option value="">All Departments</option>
						<?php foreach($alldept as $dept){?>
						<option value="<?php echo $dept->department;?>"><?php 
						echo ucwords($dept->department);?></option> <?php }?>
				</select></td>
        	    
                <td>
                	<select name="level" id="level" class="form-control action" style="width:120px" required>
						<option value="">Select Level</option>
						<option value="ND">ND I</option>
	                    <option value="HND">HND I</option>
	                    <option value="ND I">ND II</option>
	                    <option value="HND I">HND II</option>
					</select>
                </td>
                <td>
    				<select name="programme" id="programme" class="form-control action" style="width:120px" required>
    					<option value="">Select Programme</option>
    					<option value="PU21">ND I Full-Time</option>
    					<option value="DP21">ND I Daily-PartTime</option>
    					<option value="FT21">HND I Full-Time</option>
    					<option value="DP21">HND I Daily-PartTime</option>
    					
    					
    					<option value="PU20">ND II Full-Time</option>
    					<option value="DP20">ND II Daily-PartTime</option>
    					<option value="FT20">HND II Full-Time</option>
    					<option value="DP20">HND II Daily-PartTime</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>
                    <span class="input-group-btn">
                        <input type="submit" class="btn btn-danger" name="search" value="Search" id="search">
                    </span>
                </td>
                <!--<td>-->
                <!--    <div>-->
                <!--        <input type="submit" name="Print_pdf" id ="Print_pdf" class="btn btn-danger" value="Print PDF" />-->
                <!--    </div>-->
                <!--</td>-->
         	</tr>
        </table>
        </div>
    </br>
    
    <div class="panel panel-primary chat-panel" width="50px" style="width:90%">
        <div class="panel-heading ">
            <? echo $msg;?>
        </div><br/>
   <div class="table-responsive">
       <table id="mytable" class="table table-bordered table-striped"  >
     <thead>
      <tr height ="40">
        <th>S/N</th>  
        <th>DEPARTMENT</th>
        <th>NUMBER OF STUDENTS</th>
        <th>LEVEL</th>
        <th>START SESSION</th>
        <th>ADMITTED DATE</th>
      </tr>
     </thead>
    <?
     
  //   print_r($result);
    if (sizeof($result)>0)
    {
        foreach($result as $row){
        echo    '<tr>'
                    .'<td>'.++$count.'</td>'
                    .'<td>'.$row->department.'</td>'
                    
                    .'<td>'.$row->number_of_student.'</td>'
                    .'<td>'.$level.' I'.'</td>'
                    .'<td>'.$row->start_session.'</td>'
                    
                    .'<td>'.$row->admitted_date.'</td>'
				.'</tr>';
         }
                   
        
    }
    if ($rest){
        echo '<table id="summary" class="table table-striped table-bordered" >
                <tr>
                    <td width="50px">Total number of students:</td>
                    <td width="100px"> Department </td>';
                    while($row = mysql_fetch_array($rest)){
                        echo    '<tr>'
                                .'<td>'.$row['admission_list.formno'].'</td>'
                                .'<td>'.$row['department'].'</td>'
    						.'</tr>';
                     }
                   
                '</tr>';
            '</table>';
        
        }
    ?>
    </table>
   </div>
   </div>
  </div>
  <br />
  </form><br />
 </body>
</html>



    <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 type="text/javascript" language="javascript" >
  {
    $('#mytable').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'copy', 'csv', 'excel', 'pdf', 'print'
        // extend:'print',
            // autoPrint: true,
            //     title: '2019/2020 ADIMISSION LIST',
    ]
});
  }
</script>