<?php
session_start();
require_once("includes/initialize.php");
global $database;
// global $mail;
date_default_timezone_set('Africa/Lagos');


if (isset($_POST['search']))
{
    $count = 0;
        $ptype=$_POST['ptype'];
        $student_name = ONLINEPAY::find_cert_name('certificate_tranzact',$ptype);
        foreach ($student_name as $name)
        {
            $count = $count+1;
            $matricno= $name->matricno;
            $fullname= $name->fullname;
            $dept= $name->department;
            $email= $name->email;
            $certQuest= $name->level;
            $date= $name->datetime;
            ?>
            <!-- <tr>
              <td align="center"><?php echo $count; ?></td>
              <td align="center"><?php echo $matricno; ?></td>
              <td align="center"><?php echo $fullname; ?></td>
              <td align="center"><?php echo $dept; ?></td>
              <td align="center"><?php echo $email; ?></td>
              <td align="center"><?php echo $certQuest; ?></td>
              <td align="center"><?php echo $date; ?></td>
              <td align="center">
                <a class="btn btn-primary"
                href="mCertMsg.php?mat=<?php echo $matricno;?>"
                >Send Msg</a>
              </td>
            </tr> -->
            <?php
        }
        $_SESSION['ptype']=$ptype;
        if ($ptype = "FT")
        {
            $msg = "Full Time Applicants";
        }
        elseif($ptype ="PT"){ $msg = "Part Time Applicants";}
        elseif($ptype ="DP"){ $msg = "Daily Part Time Applicants";}
        elseif($ptype ="CAP"){ $msg = "Continuous Academic Program Applicants";}
        elseif($ptype ="EAP"){ $msg = "Evening Academic Program Applicants";}
        elseif($ptype ="certificate"){ $msg = "Certificate Program Applicants";}
        elseif($ptype ="advancecertificate"){ $msg = "Advance Certificate Program Applicants";}
}
else {
    // echo 'No ptype post';
}

?>
<!DOCTYPE html>
<html lang="en">
  <head>

    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Bootstrap, a sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.">
    <meta name="keywords" content="HTML, CSS, JS, JavaScript, framework, bootstrap, front-end, frontend, web development">

    <title></title>
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/r/dt/jq-2.1.4,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.9,af-2.0.0,b-1.0.3,b-colvis-1.0.3,b-html5-1.0.3,b-print-1.0.3,se-1.0.1/datatables.min.css"/>
        <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" />

  </head>
  <body>
       <!--<div class="container">-->
          
           <form method="post" action="?certificate_tracking1.php" role="form" enctype="multipart/form-data">                        	-->
	        <div class="form-group input-group" align="center">
            <div class="col-sm-4">
    	    <table class="table table-bordered table-hover">
                <tr>
                    <td>
                        <label  style="margin-left:20px; width:100%" >Programme type</label>
                        <select class="form-control action" name='ptype' id="ptype" style="padding:5px; width:150px; border-radius:5px">
                            <option value="">Choose...</option>
                            <option value="FT">Full Time </option>
                            <option  value="PT"> Part Time </option>
                                        
                             <option  value="DP">  Daily Part Time </option>
                            
                            <option value="CAP">Continuous Academic Program </option>
                            
                            <option value="EAP">Evening Academic Program</option>
                            <option value="certificate">Certificate </option>
                            
                            <option value="advancecertificate">Advance Certificate</option>
                            <option value="PGD"> PGD</option>
                        </select>
                    </td>
                <td>
                    <input type="submit" name="search" class="btn btn-success" value="Search">
                    </td>
                  </tr>
                  </table>
                  </div>
  <div class="col-sm-12" align="center">
      <div class="panel-heading ">
            <? echo $msg;?>
        </div><br/>
    <table class="table table-bordered table-hover table-condensed" id="myTable" name="myTable" style="width:100%; margin:5px">
        <thead>
            <tr class="info">
              <th><p align="center">S/N</p></th>
              <th><p align="center">Matric No.</p></th>
              <th><p align="center">Full Name</p></th>
              <th><p align="center">Department</p></th>
              <th><p align="center">E-mail</p></th>
              <th><p align="center">Certificate Type</p></th>
              <th><p align="center">Application Date</p></th>
              <th><p align="center">Message</p></th>
            </tr>
        </thead>
        <tbody>
<?php

// if (isset($_POST['search']))
// {
//     $count = 0;
//         $ptype=$_POST['ptype'];
//         $student_name = ONLINEPAY::find_cert_name($ptype);
//         foreach ($student_name as $name)
//         {
//             $count = $count+1;
//             $matricno= $name->matricno;
//             $fullname= $name->fullname;
//             $dept= $name->department;
//             $email= $name->email;
//             $certQuest= $name->level;
//             $date= $name->datetime;
//             ?>
            <?php
            foreach ($student_name as $name)
            {?>
             <tr>
               <td align="center"><?php echo $count++; ?></td>
               <td align="center"><?php echo $name->matricno; ?></td>
               <td align="center"><?php echo $name->fullname; ?></td>
               <td align="center"><?php echo $name->dept; ?></td>
               <td align="center"><?php echo $name->email; ?></td>
               <td align="center"><?php echo $certQuest; ?></td>
               <td align="center"><?php echo $date; ?></td>
               <td align="center">
                 <a class="btn btn-primary"
                 href="mCertMsg.php?mat=<?php echo $matricno;?>"
                 >Send Msg</a>
               </td>
             </tr>
             <?php
         }?>
//         $_SESSION['ptype']=$ptype;
//         if ($ptype = "FT")
//         {
//             $msg = "Full Time Applicants";
//         }
//         elseif($ptype ="PT"){ $msg = "Part Time Applicants";}
//         elseif($ptype ="DP"){ $msg = "Daily Part Time Applicants";}
//         elseif($ptype ="CAP"){ $msg = "Continuous Academic Program Applicants";}
//         elseif($ptype ="EAP"){ $msg = "Evening Academic Program Applicants";}
//         elseif($ptype ="certificate"){ $msg = "Certificate Program Applicants";}
//         elseif($ptype ="advancecertificate"){ $msg = "Advance Certificate Program Applicants";}
// }
// else {
//     echo 'No ptype post';
// }
?>
        </tbody>
        <tr class="info">
          <th><p align="center">S/N</p></th>
          <th><p align="center">Matric No.</p></th>
          <th><p align="center">Full Name</p></th>
          <th><p align="center">Department</p></th>
          <th><p align="center">E-mail</p></th>
          <th><p align="center">Certificata Type</p></th>
          <th><p align="center">Application Date</p></th>
          <th><p align="center">Message</p></th>
        </tr>
    </table>
</div>
        <!--</div>-->
        </form>
</br></br>
        

</div>
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
   <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>
  <script type="text/javascript" src="https://cdn.datatables.net/r/dt/jq-2.1.4,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.9,af-2.0.0,b-1.0.3,b-colvis-1.0.3,b-html5-1.0.3,b-print-1.0.3,se-1.0.1/datatables.min.js"></script>

    <!-- FOR DataTable -->
    <script>
      {
        $(document).ready(function()
        {
          $('#myTable').DataTable();
        });
      }
    </script>

    <!-- this function is for modal -->
    <script>
      $(document).ready(function()
      {
        $("#myBtn").click(function()
        {
          $("#myModal").modal();
        });
      });
    </script>
  </body>
</html>