<?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>
</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 -->

                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                              <div class="col-lg-12">
  <div class="panel panel-green">
                <div class="panel-heading">
                                <h3 class="panel-title">Select to filter</h3>
                            </div>
                            <div class="panel-body">
                              <div class='col-lg-3'>

                                <form method='post'>
                              <select class='form-control' name='schoolyear'>
                                <?php
                                include ("connect.php");
                                $result56 = $dbh->query("select * from scrap where type='ya'");
                                $row56 = $result56->fetchObject();
                                $count56 = $result56->rowCount();

echo "<option value='".$thisyearshort."'>".$thisyearlong."</option>";

                                if($count56>0){
                                  do{
                                    
                                    echo "<option value='".$row56->item."'>".$row56->item2."</option>";

                                    
                                  }while($row56 = $result56->fetchObject());
                                }else{
                                  echo "<option value=''>Sorry: please contact your IT departmant</option>";
                                }
                                ?>
                              </select>
                            </div>
                            <div class='col-lg-3'>
                              <select class='form-control' name='term'>
                                <option value=''>Term </option>
                                <option value='1'>Term 1</option>
                                <option value='2'>Term 2</option>
                                <option value='3'>Term 3</option>
                              </select>

                            </div>
                            <div class='col-lg-3'>
                              <input type='submit' name='submit670' class='btn btn-sm btn-primary' value='Filter'>
                            </form>

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

     <form method="post">               
<div class="col-lg-12">
  <div class="panel panel-yellow">
                <div class="panel-heading">
                  <?php
include ("compareexpected.php");
                                  ?>
                                <h3 class="panel-title"><?php if(isset($_POST["submit670"])){
                                  if($term=='t1'){
                                    $terma = "Term 1";

                                  }elseif($term=='t2'){
                                    $terma = "Term 2";
                                  
                                  }elseif($term=='t3'){
                                    $terma = "Term 3";
                                  }

                                  echo $terma."&nbsp;&nbsp; 20".$schoolyear;


                                }else{

 if($term=='t1'){
                                    $terma = "Term 1";

                                  }elseif($term=='t2'){
                                    $terma = "Term 2";
                                  
                                  }elseif($term=='t3'){
                                    $terma = "Term 3";
                                  }

                                  echo  $terma."&nbsp;&nbsp;".date("Y"); }?></h3>
                            </div>
                            <div class="panel-body">
                              <table class="table table-bordered table-hover table-striped sortable">
                                <thead>
                                <th></th>
                                <th>Expected</th>
                                <th>Income</th>
                                <th>Variance</th>
                                <th>%</th>
                                <th>No of children</th>
                              </thead>
                              <tbody>
                                <tr>
                                  
                                  <td>Baby</td>
                                  <td><?php echo number_format($row8t1[0]); ?></td>
                                  <td><?php echo number_format($row8inc[0]); ?></td>
                                  <td><?php echo number_format(($row8inc[0]-$row8t1[0])); ?></td>
                                  <td><?php if($row8t1[0]>0){echo number_format((($row8inc[0] / $row8t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=8&dayear=".$schoolyear."&daterm=".$term."'>".$count8t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Middle</td>
                                  <td><?php echo number_format($row9t1[0]); ?></td>
                                  <td><?php echo number_format($row9inc[0]); ?></td>
                                  <td><?php echo number_format(($row9inc[0]-$row9t1[0])); ?></td>
                                  <td><?php if($row9t1[0]>0){echo number_format((($row9inc[0] / $row9t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=9&dayear=".$schoolyear."&daterm=".$term."'>".$count9t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Top</td>
                                  <td><?php echo number_format($row10t1[0]); ?></td>
                                  <td><?php echo number_format($row10inc[0]); ?></td>
                                  <td><?php echo number_format(($row10inc[0]-$row10t1[0])); ?></td>
                                  <td><?php if($row10t1[0]>0){echo number_format((($row10inc[0] / $row10t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=10&dayear=".$schoolyear."&daterm=".$term."'>".$count10t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 1</td>
                                  <td><?php echo number_format($row1t1[0]); ?></td>
                                  <td><?php echo number_format($row1inc[0]); ?></td>
                                  <td><?php echo number_format(($row1inc[0]-$row1t1[0])); ?></td>
                                  <td><?php if($row1t1[0]>0){echo number_format((($row1inc[0] / $row1t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=1&dayear=".$schoolyear."&daterm=".$term."'>".$count1t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 2</td>
                                  <td><?php echo number_format($row2t1[0]); ?></td>
                                  <td><?php echo number_format($row2inc[0]); ?></td>
                                  <td><?php echo number_format(($row2inc[0]-$row2t1[0])); ?></td>
                                  <td><?php if($row2t1[0]>0){echo number_format((($row2inc[0] / $row2t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=2&dayear=".$schoolyear."&daterm=".$term."'>".$count2t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 3</td>
                                  <td><?php echo number_format($row3t1[0]); ?></td>
                                  <td><?php echo number_format($row3inc[0]); ?></td>
                                  <td><?php echo number_format(($row3inc[0]-$row3t1[0])); ?></td>
                                  <td><?php if($row3t1[0]>0){echo number_format((($row3inc[0] / $row3t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=3&dayear=".$schoolyear."&daterm=".$term."'>".$count3t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 4</td>
                                  <td><?php echo number_format($row4t1[0]); ?></td>
                                  <td><?php echo number_format($row4inc[0]); ?></td>
                                  <td><?php echo number_format(($row4inc[0]-$row4t1[0])); ?></td>
                                  <td><?php if($row4t1[0]>0){echo number_format((($row4inc[0] / $row4t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=4&dayear=".$schoolyear."&daterm=".$term."'>".$count4t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 5</td>
                                  <td><?php echo number_format($row5t1[0]); ?></td>
                                  <td><?php echo number_format($row5inc[0]); ?></td>
                                  <td><?php echo number_format(($row5inc[0]-$row5t1[0])); ?></td>
                                  <td><?php if($row5t1[0]>0){echo number_format((($row5inc[0] / $row5t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=5&dayear=".$schoolyear."&daterm=".$term."'>".$count5t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 6</td>
                                  <td><?php echo number_format($row6t1[0]); ?></td>
                                  <td><?php echo number_format($row6inc[0]); ?></td>
                                  <td><?php echo number_format(($row6inc[0]-$row6t1[0])); ?></td>
                                  <td><?php if($row6t1[0]>0){echo number_format((($row6inc[0] / $row6t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=6&dayear=".$schoolyear."&daterm=".$term."'>".$count6t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Primary 7</td>
                                  <td><?php echo number_format($row7t1[0]); ?></td>
                                  <td><?php echo number_format($row7inc[0]); ?></td>
                                  <td><?php echo number_format(($row7inc[0]-$row7t1[0])); ?></td>
                                  <td><?php if($row7t1[0]>0){echo number_format((($row7inc[0] / $row7t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=7&dayear=".$schoolyear."&daterm=".$term."'>".$count7t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 1</td>
                                  <td><?php echo number_format($row21t1[0]); ?></td>
                                  <td><?php echo number_format($row21inc[0]); ?></td>
                                  <td><?php echo number_format(($row21inc[0]-$row21t1[0])); ?></td>
                                  <td><?php if($row21t1[0]>0){echo number_format((($row21inc[0] / $row21t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=21&dayear=".$schoolyear."&daterm=".$term."'>".$count21t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 2</td>
                                  <td><?php echo number_format($row22t1[0]); ?></td>
                                  <td><?php echo number_format($row22inc[0]); ?></td>
                                  <td><?php echo number_format(($row22inc[0]-$row22t1[0])); ?></td>
                                  <td><?php if($row22t1[0]>0){echo number_format((($row22inc[0] / $row22t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=22&dayear=".$schoolyear."&daterm=".$term."'>".$count22t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 3</td>
                                  <td><?php echo number_format($row23t1[0]); ?></td>
                                  <td><?php echo number_format($row23inc[0]); ?></td>
                                  <td><?php echo number_format(($row23inc[0]-$row23t1[0])); ?></td>
                                  <td><?php if($row23t1[0]>0){echo number_format((($row23inc[0] / $row23t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=23&dayear=".$schoolyear."&daterm=".$term."'>".$count23t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 4</td>
                                  <td><?php echo number_format($row24t1[0]); ?></td>
                                  <td><?php echo number_format($row24inc[0]); ?></td>
                                  <td><?php echo number_format(($row24inc[0]-$row24t1[0])); ?></td>
                                  <td><?php if($row24t1[0]>0){echo number_format((($row24inc[0] / $row24t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=24&dayear=".$schoolyear."&daterm=".$term."'>".$count24t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 5</td>
                                  <td><?php echo number_format($row25t1[0]); ?></td>
                                  <td><?php echo number_format($row25inc[0]); ?></td>
                                  <td><?php echo number_format(($row25inc[0]-$row25t1[0])); ?></td>
                                  <td><?php if($row25t1[0]>0){echo number_format((($row25inc[0] / $row25t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=25&dayear=".$schoolyear."&daterm=".$term."'>".$count25t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                  <td>Senior 6</td>
                                  <td><?php echo number_format($row26t1[0]); ?></td>
                                  <td><?php echo number_format($row26inc[0]); ?></td>
                                  <td><?php echo number_format(($row26inc[0]-$row26t1[0])); ?></td>
                                  <td><?php if($row26t1[0]>0){echo number_format((($row26inc[0] / $row26t1[0])*100),0)."%";}else{echo "0";} ?></td>
                                  <td><?php echo "<a href='studentnumber.php?daclass=26&dayear=".$schoolyear."&daterm=".$term."'>".$count26t1c."</a>"; ?></td>
                                  </tr>
                                  <tr>
                                    <td>Total</td>
                                    <td><?php $rowt1=$row8t1[0] + $row9t1[0] + $row10t1[0] + $row1t1[0] + $row2t1[0] + $row3t1[0] + $row4t1[0] +  $row5t1[0] + $row6t1[0] + $row7t1[0] + $row21t1[0] + $row22t1[0] + $row23t1[0] + $row24t1[0] + $row25t1[0] + $row26t1[0];
                                     echo number_format($rowt1); ?></td>

                                    <td><?php $rowinc = $row8inc[0] + $row9inc[0] + $row10inc[0] + $row1inc[0] + $row2inc[0] + $row3inc[0] + $row4inc[0] + $row5inc[0] + $row6inc[0] + $row7inc[0] + $row21inc[0] + $row22inc[0] + $row23inc[0] + $row24inc[0] + $row25inc[0] + $row26inc[0];
                                     echo number_format($rowinc); ?></td>
                                     <td><?php echo number_format(($rowinc-$rowt1)); ?></td>

                                     <td><?php if($rowt1>0){echo number_format((($rowinc / $rowt1)*100),0)."%";}else{echo "0";} ?></td>
                                     
                                    <td><?php echo $count8t1c + $count9t1c + $count10t1c + $count1t1c + $count2t1c + $count3t1c + $count4t1c + $count5t1c + $count6t1c + $count7t1c + $count21t1c + $count22t1c + $count23t1c + $count24t1c + $count25t1c + $count26t1c; ?></td> 

                                  </tr>

                              </tbody>

                              </table>
                                </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>