<?php 
require_once("./includes/initialize.php");
global $database;
// $allsession = ONLINEPAY:: showsession();
// $session = $allsession->session;
// $allpayment =ONLINEPAY::showpayment_online("acceptance_tranzact");
// $level = COURSECLASS::course_authenticate();
session_start();
// if(isset($_POST['search']))
// {
  $department = $_POST['department'];
  $level = $_POST['level'];
  $session = $_POST['session'];
  $start_date = $_POST['start_date'];
  $end_date = $_POST['end_date'];
  $formno = $_POST['formno'];
  $prog = $_POST['prog'];
  
  $department;
  echo $formno;
 $_SESSION['department'] =  $department;
 $_SESSION['level'] =  $level;
 $_SESSION['session'] =  $session;
 $_SESSION['start_date'] =  $start_date;
 $_SESSION['end_date'] =  $end_date;
 $_SESSION['prog'] =  $prog;
 
 

 if ($department !="" && $prog !="" && $level !="" && $session !="")
 {
    $show = ONLINEPAY::search_session($department,$prog, $level, $session);
 }
 else
 {
     $show = ONLINEPAY::search_all($department, $level, $session, $start_date, $end_date);
 }
 if($department =="" && $level =="" && $session =="")
 {
    //  $show = ONLINEPAY::search_by_date($start_date,$end_date);
 }
 if($department =="" && $level !="" && $session !="")
 {
     $show = ONLINEPAY::search_level($level, $session);
    $query = "SELECT admission_list.department, COUNT(admitted_student_details_2019.formno) FROM admission_list JOIN admitted_student_details_2019 
                ON admitted_student_details_2019.formno = admission_list.formno  WHERE admitted_student_details_2019.level= '{$level}' 
                AND admission_list.session= '{$session}' GROUP BY department";
    
    $result = mysql_query($query) or die(mysql_error());
 }
  if ($formno !="")
 {
     $show = ONLINEPAY::search_by_formno($formno);
 }
 
    $cont = 0;
          echo '<table id="admin_table" class="table table-striped table-bordered">
                              <thead>
                                      <tr height="20">
                                          <th>S/N</th>  
                                          <th>FORM NO</th>
                                          <th>SURNAME</th>     
                                          <th>OTHER NAMES</th>
                                          <th>DEPARTMENT</th>
                                          <th>LEVEL</th>
                                          <th>SESSION</th>
                                          <th>DATE/TIME</th>                         
                                      </tr>
                                  </thead> 
                                  </div> </div>';            
            		foreach($show as $pay) 
                    {
                        echo '<tbody>
                                    <tr>'
            							.'<td>'.++$cont.'</td>'
            							.'<td>'.$pay->formno.'</td>'
            							.'<td>'.$pay->surname.'</td>'
            							.'<td>'.$pay->othernames.'</td>'
            							.'<td>'.$pay->department.'</td>'
            				// 			.'<td>'.$pay->sex.'</td>'
            							.'<td>'.$pay->level.'</td>'
            							.'<td>'.$pay->session.'</td>'
            							.'<td>'.$pay->admitted_date.'</td>'
            						.'</tr>'
    						.'</tbody>'; 
                    } 
                    // echo '</table>';
                    
                    if ($result){
                    echo '<table id="summary" class="table table-striped table-bordered" >
                            <tr>
                                <td width="200px">Total number of students:</td>
                                <td width="100px"> Department </td>';
                                while($row = mysql_fetch_array($result)){
                                    echo    '<tr>'
                                            .'<td>'.$row['formno'].'</td>'
                                            .'<td>'.$row['department'].'</td>'
                						.'</tr>';
                                 }
                               
                            '</tr>';
                        '</table>';
                    
                    }
                    
                    
                    
    //   }else{echo 'No Session90 Post';}
?>