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

    

    $table_name = $_SESSION['tablename'];
    if ($table_name == 'admin_acceptance')
    {
        $table = 'acceptance_tranzact';
    }
    if ($table_name == 'admin_schoolfees')
    {
        $table = 'schoolfees_tranzact';
    }

$allsession ='';

if(isset($_POST['dpt']) && ($_POST['dpt'] !='all'))
{
// $table = $_SESSION['tablename'];
$dept = $_POST['dpt'];
$session = $_POST['ses'];
$level = $_POST['lev'];

$count = 0;

$allsession= ONLINEPAY:: showsessiondetails($table, $dept, $level, $session);

}else if (isset($_POST['dpt']) AND ($_POST['dpt'])=='all'){
    echo "I got here sir";
$dept = $_POST['dpt'];
$session = $_POST['ses'];
$level = $_POST['lev'];

$count = 0;

    $allsession= ONLINEPAY::showalltranzact($table, $level, $session);
    
} else if (($_POST['dpt'])==''){
//     echo "Heey";
//   echo $table = $_SESSION['tablename'];
$dept = $_POST['dpt'];
$session = $_POST['ses'];
$level = $_POST['lev'];

$count = 0;

    //$facul = $_POST['fac'];
  $allsession= ONLINEPAY::showallbyfac($table, $facul, $level, $session);
}   
else {
    "No record to display";
}

$sum = 0;
 echo '<table id="summary" class="table table-striped table-bordered" >
                
                <tr width="100%"><td align="center"><span style="font-weight:bolder; font-size:20px; text-align:center"> Acceptance Fees Details</span></td></tr>
                </table>';
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 NAME</th>  
                                        <th>DEPARTMENT</th>
                                        <th>LEVEL</th>  
                                        <th>DATE/TIME</th>                         
                                    </tr>
                                </thead>
        ';

foreach ($allsession as $student){
    
  
                     echo'<tr>'
							.'<td>'.++$count.'</td>'
							.'<td>'.$student->formno.'</td>'
				// 			.'<td>'.$student->txt_ref.'</td>'
							.'<td>'.$student->surname.'</td>'
							.'<td>'.$student->othernames.'</td>'
							.'<td>'.$student->department.'</td>'
							.'<td>'.$student->level.'</td>'
				// 			.'<td>'.$student->status.'</td>'
							.'<td>'.$student->datetime.'</td>'
						.'</tr>'; 
                    } 
                   
                '</table>';
                // echo '<table id="summary" class="table table-striped table-bordered" >
                
                //  <tr width="100%"><td align="center"><span style="font-weight:bolder; font-size:20px; text-align:center"> Acceptance Fees Summary</span></td></tr>
                // </table>';
                
                // echo '<table id="summary" class="table table-striped table-bordered" >
                //             <tr>
                //                 <td width="200px">Total number of students:</td>
                //                 <td width="100px">'. $count .'</td>
                //                 <td width="200px">Total Acceptance fees paid: </td>
                //                 <td><strike>N</strike>'. $sum .'</td>
                //             </tr>
                //         </table>';
 

?>