<?php 
include ("kfunctions.php");
role2("overadmin","priaccount");
?>

<html>
<head>
<?php kheader(); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!--<script src="js/thousandseparator.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" style='margin-top:10px;'>

      
            <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">
                           Transactions
                        
                        </h1>
                    </div>
                </div>
                <!-- /.row -->

                    
                        <div class="col-lg-12">
  <div class="panel panel-green">
                <div class="panel-heading">
                                <h3 class="panel-title">Recent Transactions</h3>
                            </div>
                            <div class="panel-body">

<table class='table table-bordered table-hover table-striped sortable'>
<thead>
<tr>
<th>No</th>
<th>Date</th>
<th>Transaction ID</th>
<th>Name</th>
<th>Class</th>
<th>Added By</th>
<th>Total Paid</th>
<th>Action</th>
</tr>
<?php
$result_clo = $dbh->query("select * from clo order by autoid desc");
$row_clo = $result_clo->fetchObject();
$count_clo = $result_clo->rowCount();

if($count_clo>0){ $x=1;
  do{
    $result_children = $dbh->query("select * from children where cid='$row_clo->cid'");
$row_children = $result_children->fetchObject();
$count_children = $result_children->rowCount();

$result_user = $dbh->query("select * from users where rolenumber='$row_clo->ouruser'");
$row_user = $result_user->fetchObject();
$count_user = $result_user->rowCount();



$result_hom = $dbh->query("select * from homeland where cid='$row_clo->cid' and paydate='$row_clo->date_received'");
$row_hom = $result_hom->fetchObject();
$count_hom = $result_hom->rowCount();

$result_scrapp=$dbh->query("select * from scrap where  item='$row_hom->schoolclass' and type='priclas'");
$row_scrapp=$result_scrapp->fetchObject();
$count_scrapp=$result_scrapp->rowCount();

if(empty($row_clo->date_received)){
    $date=explode(" ", $row_clo->autodate);
    $date_show=$date[0];
} else {
    $date_show= $row_clo->date_received;
}


    echo "<tr>
    <td>".$x++."</td>
    <td>".$date_show."</td>
    <td>".substr($row_clo->transactionid,2)."</td>
    <td>"; if($count_children>0){echo $row_children->fname." ".$row_children->sname."<span style='color:blue'> [".$row_clo->cid."]</span>";} echo "</td>
    <td>".$row_scrapp->item2."</td>
    <td>"; if($count_user>0){ echo "@".$row_user->firstname;} echo "</td>
    <td>".number_format($row_clo->totalpaid)."</td>
    <td><a href='receipt.php?cid=".$row_clo->cid."&transactionid=".$row_clo->transactionid."&t=".$row_children->term."&schoolyear=".$row_children->schoolyear."' class='btn btn-md btn-primary'>View Receipt</a></td>
 
    </tr>";

  }while($row_clo = $result_clo->fetchObject());
}
?>
</thead>

                  
                  </div> 
                   </div>


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

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

    </div>
    <!-- /#wrapper -->
<?php useractivity("on page","2"); ?>
    <!-- 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 -->

</body>

</html>
