<?php 
require_once("includes/initialize.php");
// $alldept = ONLINEPAY:: showdept();
// $dprepare ="";
session_start();
$fo = $_SESSION["$fo"];

if ($fo == "Dpt" or $fo == '')
{
    $faculty_dept = ONLINEPAY:: showdept();
}
else
{
    $faculty_dept = ONLINEPAY:: showdept_byf($fo);
}
$allsession = ONLINEPAY::showsession();


if (isset($_POST['search']))
{
   $depart = $_POST['department'];
    $level = $_POST['level'];
    $session = $_POST['session'];
    $prog = $_POST['prog'];
    if ($session == '2018/2019')
    {
        $allpayment =ONLINEPAY::get_phone18('acceptance_tranzact',$prog,$depart,$level,$session);
    }else
    {
        $allpayment =ONLINEPAY::get_phone19('acceptance_tranzact',$prog,$depart,$level,$session);
    }
    
    if ($level == 'ND' && $prog == 'PU')
    {
        $msg = 'National Diploma On Full-Time Programme '.$session;
    }
    elseif ($level == 'ND' && $prog == 'DP')
    {
        $msg = 'National Diploma On Daily Part-Time Programme '.$session;
    }elseif ($level == 'HND' && $prog == 'FT')
    {
        $msg = 'Higher National Diploma On Full-Time Programme '.$session;
    }elseif ($level == 'HND' && $prog == 'DP')
    {
        $msg = 'Higher National Diploma On Daily Part-Time Programme '.$session;
    }
    
    
}

$count=0;
?>

<head>
   <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" align="center">
			<h2 align="center">Welcome :: <?php echo $fo;?> Faculty Officer</h2><br/>
			    <form method="post" id="insert_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 foreach($faculty_dept as $dept){?>
                							<option value="<?php echo $dept->department;?>"><?php 
                							echo ucwords($dept->department);?></option> <?php }?>
                					</select></td>
                					<td>
                					<select name="prog" id="prog" class="form-control action" style="width:120px">
                						<option value="">Select Programme</option>
                						<option value="PU">Full Time(ND)</option>
                	                    <option value="DP">DPT</option>
                	                    <option value="FT">Full Time(HND)</option>	
                					</select></td>
        					    <td>
                					<select name="level" id="level" class="form-control action" style="width:120px">
                						<option value="">Select Level</option>
                						<option value="ND">ND</option>
                	                    <!--<option value="ND II">ND II</option>-->
                	                    <option value="HND">HND</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>
                					    <div class="col-md-4">
                                            <input type="submit" name="search" id ="search" value="Search" class="btn btn-info" />
                                        </div>
                					</td>
                					<!--<td>-->
        					        <!--    <input type="submit" name="Print_pdf" id ="Print_pdf" class="btn btn-danger" value="Print PDF" />-->
                					<!--</td>-->
        					</tr> 
                        </table>
					</div>
			    <!--</form>-->
			    <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>S/N</th>  
                                <th>MATRIC NO</th>  
                                <th>FULLNAME</th> 
                                <th>DEPARTMENT</th>
                                <th>LEVEL</th>
                                <th>DATE OF BIRTH</th>
                                <th>LGA</th>
                                <th>STATE</th>
                                <th>PHONE NUMBER</th>
                              </tr>
                             </thead>
                        
                        <?php
                        if (isset($allpayment)){
                            foreach($allpayment as $rows)
                            {
                                $formno = $rows->formno;
                                $getmatric = ONLINEPAY::getMatricNo($formno);
                                foreach ($getmatric as $row)
                                {
                                    if ($row->matricno != 0)
                                    {
                                        $matricno = $row->matricno;
                                    }else
                                    {
                                        $matricno = $row->formno;
                                    }
                                }
                                $fullname = strtoupper($rows->surname).', '.strtolower($rows->othernames);
                                $depart = $rows->department;
                                $level = $rows->level;
                                $dob = strtotime($rows->dob);
                                $lga = $rows->lga;
                                $state = $rows->state;
                                $phone = $rows->phone;
                        
                        echo  '<tr>'
                                .'<td>'.++$count.'</td>'
            					.'<td>'.$matricno.'</td>'
            					.'<td>'.$fullname.'</td>'
            					.'<td>'.ucwords($depart).'</td>'
            					.'<td>'.$level.'</td>'
            					.'<td>'.date("d-m-Y", $dob).'</td>'
            					.'<td>'.$lga.'</td>'
            					.'<td>'.$state.'</td>'
            					.'<td>'.$phone.'</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>