<!DOCTYPE html>
<?php //include '../includes/connection.php'; ?>
<html>
    
    <head>
        <?php include("../includes/header-links.php");?>
       
        <!-- Bootstrap -->
        <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="../assets/styles.css" rel="stylesheet" media="screen">
        <link href="../assets/DT_bootstrap.css" rel="stylesheet" media="screen">
        <link rel="stylesheet" href="../data-table-css/bootstrap-table.css">
    <link rel="stylesheet" href="../data-table-css/bootstrap-editable.css">
        <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="vendors/flot/excanvas.min.js"></script><![endif]-->
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="../vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
    </head>
    
    <body>
        <?php include '../includes/header.php'; ?>
        <div class="container-fluid">
            <div class="row-fluid">
                <?php include '../includes/sidebar.php'; ?>
                <!--/span-->
                <div class="span10" id="content">


                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Expenses Today</div>
                                
                            </div>
                            <div class="block-content collapse in">
                             
                                    
                                    <table id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true"
                                        data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar" data-export-options='{"fileName": "Testing_filename"}'>
                                    
                                        <thead>
                                            <th data-field="state" data-checkbox="true"></th>
                                                <th data-field="id">ID</th>
                                                <th>Category</th>
                                                <th>Amount</th>
                                                <th>Description</th>
                                                <th>Date</th>
                                                
                                                <th>Expense By</th>
                                                
                                        </thead>
                                        <tbody id="fulldata">
                                        <?php
                                        $today=date('Y-m-d');
if( $_SESSION['role']=="Super Admin"){
$sql = "SELECT id, description, (select categoryName from expense_categories where id=expenses.category && business_id='$business') as category, amount, date, date_created, (select name from users where id=expenses.expense_by && business_id='$business')as name FROM expenses where date='$today' && business_id='$business' order by id DESC";  
}else{
 $sql = "SELECT id, description, (select categoryName from expense_categories where id=expenses.category && branch_id='$branch') as category, amount, date, date_created, (select name from users where id=expenses.expense_by && branch_id='$branch')as name FROM expenses where date='$today' && branch_id='$branch' order by id DESC";   
}

$result = mysqli_query($conn, $sql);


    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        ?>
<tr>
    <td></td>
    <td>1</td>
    <td><?php echo $row['category']; ?></td>
    <td><?php echo $row['amount']; ?></td>
    <td><?php echo $row['description']; ?></td>
    <td><?php echo $row['date']; ?></td>
    
    <td><?php echo $row['name']; ?></td>
    
    
</tr>
<?php
    }
                                       
    $today=date('Y-m-d');
    $dailyexpense=mysqli_fetch_array(mysqli_query($con,"SELECT sum(Amount) as spent from expenses where date='$today' && branch_id='$branch'"));
$totalspent=$dailyexpense['spent'];
    ?>
    <tr>
    <td></td>
        <td colspan="2" ><h4 style="text-align: center;">TOTAL EXPENSES</h4></td>
        <td><h4><?php echo number_format($totalspent);?></h4></td>
        <td colspan="3"></td>
    </tr>
    
    
                                            
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <script src="../vendors/jquery-1.9.1.js"></script>
        <script src="../bootstrap/js/bootstrap.min.js"></script>
        <script src="../vendors/datatables/js/jquery.dataTables.min.js"></script>
        <script src="../data-table-js/bootstrap-table.js"></script>
    <script src="../data-table-js/tableExport.js"></script>
    <script src="../data-table-js/data-table-active.js"></script>
    <script src="../data-table-js/bootstrap-table-editable.js"></script>
    <script src="../data-table-js/bootstrap-editable.js"></script>
    <script src="../data-table-js/bootstrap-table-resizable.js"></script>
    <script src="../data-table-js/colResizable-1.5.source.js"></script>
    <script src="../data-table-js/bootstrap-table-export.js"></script>


        <script src="../assets/scripts.js"></script>
        <script src="../assets/DT_bootstrap.js"></script>
        <script>
        $(function() {
            
        });
        </script>
    </body>

</html>