<?php 
include ("kfunctions.php");
role("overadmin");
?>

<html>
<head>
<?php kheader(); ?>

<script src="js/sorttable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>
<script src="js/print.js"></script>
</head>
<body>

    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <!-- Brand and toggle get grouped for better mobile display -->
            <?php ktopbar(); ?>
            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <?php kleftbar(); ?>
            <!-- /.navbar-collapse -->
        </nav>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- /.row -->          

  
     <form method="post">
<input type="button" value="Print table" style="float:right;margin-right:15px;" class="btn btn-sm btn-info" onclick="PrintDiv('myDiv')" />
                            <div id="myDiv">

<div class="col-lg-12">
  <div class="panel panel-green">
                <div class="panel-heading">
                                                  <h3 class="panel-title">Names of students</h3>
                            </div>
                            <div class="panel-body">
                              <table class="table table-bordered table-hover table-striped sortable">
                                <thead>
                                <th>No</th>
                                <th>Names</th>
                                <th>Category</th>
                                <th>Fee structure</th>
                                <th>Fee bal</th>
                                <th>Reqmt bal</th>
                                <th>Total bal</th>
                              </thead>
                              <tbody>
                              <?php
                            
                              $daclass = $_GET["daclass"];
                              $dayear = $_GET["dayear"];
                              $daterm = $_GET["daterm"];

                              $result = $dbh->query("select * from $daterm where schoolclass='$daclass' and schoolyear='$dayear'");
                              $row = $result->fetchObject();
                              $count = $result->rowCount();

                              if($count>0){
                                $x=1;
                                
                                do{

                                  $result2 = $dbh->query("select * from children where cid='$row->cid'");
                              $row2 = $result2->fetchObject();
                              $count2 = $result2->rowCount();

                                  echo "
                                  <tr>
                                  <td>".$x++."</td>
                                  <td>"; if($count2>0){echo $row2->fname." ".$row2->sname;}else{} echo "</td>
                                  <td>".$row2->category."</td>
                                  <td>".number_format($row->ownfee)."</td>
                                  <td>".number_format($row->feesbalance)."</td>
                                  <td>".number_format($row->reqsbalance)."</td>
                                  <td>"; echo number_format($row->reqsbalance + $row->feesbalance); echo "</td>
                                  </tr>

                                  ";

                                }while($row = $result->fetchObject());

                              }else{
                                echo "<tr><td colspan='6'>So far, there is NO data. </td></tr>";
                              }

                                ?>
                              </tbody>


                              </table>
                              </div>
                                </div>
                                
                            </div>
                        



                  </div>
                <!-- /.row -->

            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Morris Charts JavaScript -->
<?php useractivity("on page","2"); ?>

</body>

</html>