<?php 
include ("kfunctions.php");
adminall("priaccount2","secaccount2","overadmin");
?>
<html>
<head>
<?php kheader(); ?>

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

                <!-- Page Heading -->
                
                <!-- /.row -->

                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">
                            <div class="panel-body">
                            
<?php
if (isset($_POST['count'])){
$count=$_POST['count'];

if ($count==0){$lim="";}
else {$lim="limit 0,$count";}
}
    else{
$lim="limit 0,20";
}?>

<div class="panel panel-yellow"><!--Initiative-->
<div class="panel-heading"><h3 class="panel-title">View expenses</h3></div>
<div class="panel-body">
  <div class="col-lg-4">
  <form method='post'>
<select name='count' class='form-control' onchange="this.form.submit()">
<option value=''>Count</option>";
<option value='17'>20</option>
<option value='18'>30</option>
<option value='19'>50</option>
<option value='20'>80</option>
<option value='100'>100</option>
<option value='0'>All</option>
</select>

</form>
</div>
<table class="table table-bordered table-hover table-striped sortable">
<thead>
  <tr>

    <th>Added</th>
    <th>Spent</th>
    <th>Expenditure ID</th>
    <th>Item</th>
    <th>Cost</th>
  <th>Received by</th>
<th>Section</th>
  <th>Comment</th>

  </tr>
</thead>
<tbody>
  
  <?php
  $rolenumber = $_SESSION["rolenumber"];
  $result = $dbh->query("select * from expenses2 where ouruser='$rolenumber' order by autodate desc $lim ");
  $row = $result->fetchObject();
  $count = $result->rowCount();

  

if($count>0){
do{
$cost=$row->cost;

 echo "
<tr>
<td>".$row->autodate."</td>
<td>".$row->datez."</td>
  <td>".$row->expid."</td>
  <td>".$row->item."</td>
  <td>".number_format($cost)."</a></td>
  <td>".$row->requestfrom."</td>
 <td>".$row->section."</td>
  <td>".$row->comment."</td>
  </tr>";
}while($row = $result->fetchObject());
}else{echo "<tr><td colspan='5'>So far, No expenses</td></tr>";}
  ?>
 
  </tbody>
</table>
</form>

</div></div>

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

               <?php useractivity("on page","5"); ?>

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

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

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

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

    <!-- Bootstrap Core JavaScript -->
    <script type="text/javascript" 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>
</body>

</html>