<?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 $month=$_GET['month'];
$monthfull   = DateTime::createFromFormat('!m', $month);
$monthfullest = $monthfull->format('F');  

$rolenumber = $_SESSION["rolenumber"];
  $result = $dbh->query("select * from expenses2 where datez like '%-$month-%' order by datez desc");
  $row = $result->fetchObject();
  $count = $result->rowCount();

$monthexpenses= $dbh->query
("select sum(cost) from expenses2 where datez like '%-".$month."-%'");
$rowmexp = $monthexpenses->fetch(); 

?>

<div class="panel panel-yellow"><!--Initiative-->
<div class="panel-heading"><h3 class="panel-title">Expenses in the month of <?php echo $monthfullest. " |  <b>Total: ".number_format($rowmexp['0'])."</b>";?></h3></div>
<div class="panel-body">
<table class="table table-bordered table-hover table-striped sortable">
<thead>
  <tr>
    <th>Date</th>
    <th>Category</th>
    <th>Item</th>
    <th>Cost</th>
  <th>Received by</th>
<th>Section</th>
  <th>Comment</th>

  </tr>
</thead>
<tbody>
  
  <?php
  

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

 echo "
<tr>
  <td>".$row->datez."</td>
  <td>".$row->category."</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>