<?php 
include ("kfunctions.php");?>
<html>
<head>
<?php kheader(); ?>
<?php 
require_once("connect.php");

?>
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script src="js/sorttable.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">

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

                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                            
                            <form method='post'>

<div class='controls input-append date form_date col-lg-3' data-date='' data-date-format='yyyy-mm-dd' data-link-field='dtp_input2' data-link-format='yyyy-mm-dd'>
<input size='16' readonly type='text' name='date1' placeholder='Date' class='form-control' id='bpnextdate1'>
<span class='add-on'><i class='icon-th'></i></span>
</div>

<div class='controls input-append date form_date col-lg-3' data-date='' data-date-format='yyyy-mm-dd' data-link-field='dtp_input2' data-link-format='yyyy-mm-dd'>
<input size='16' readonly type='text' name='date2' placeholder='Date' class='form-control' id='bpnextdate1'>
<span class='add-on'><i class='icon-th'></i></span>
</div>
<input type='submit' name='submit' class='btn btn-sm btn-primary' value='Show all in range'>

</form>

<div class="panel panel-green"><!--Initiative-->
<div class="panel-heading"><h3 class="panel-title">Last 10 incomes</h3></div>
<div class="panel-body">
<table class="table table-bordered table-hover table-striped sortable">

 <thead>
<tr>
<th>ID</th>
<th>Date earned</th>
<th>Slip date</th>
<th>Student name</th>
<th>Slip ID</th>
<th>Term</th>
<th>Amount</th>
<th>Balance	</th>
</tr></thead>
<?php

require_once("connect.php");

if(isset($_POST['submit'])){
$date1 = $_POST["date1"];
$date2 = $_POST["date2"];
$daterange="and (dateclose>='$date1' && dateclose<='$date2')";}
else
{$daterange="limit 0,10";}

$result=$dbh->query("select * from received $daterange");
$row=$result->fetchObject();
$count=$result->rowCount();

 


// If result matched $myusername and $mypassword, table row must be 1 row


if($count>0){ 
do {
	$result2=$dbh->query("select * from children where cid='$row->cid'");
$row2=$result2->fetchObject();
echo "
<tr>
<td><a href='transupdate.php?tid=".$row->tid." & term=".$row->term."'>".$row->tid."</td>
<td>".$row->autodate."</td>
<td>".$row->datepaid."</td>
<td>".$row->cid."-".$row2->fname."&nbsp;".$row2->sname."</td>
<td>".$row->slipid."</td>
<td>".$row->term."</td>
<td>".$row->amount."</td>
<td>".$row->bcf."</td>
</tr>";}
while($row=$result->fetchObject());
}
else {echo "So far, no children have paid.";}
?>
</table>


</div></div>

</div>
                            </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>
    <script type="text/javascript" src="js/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript">
    $('.form_datetime').datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
        showMeridian: 1
    });
	$('.form_date').datetimepicker({
        language:  'en',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0
    });
	$('.form_time').datetimepicker({
        language:  'en',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 1,
		minView: 0,
		maxView: 1,
		forceParse: 0
    });
</script>
<script>
function goback(){
window.history.back();	
}
</script>
</body>

</html>