<!DOCTYPE html>
// <?php include '../includes/connection.php'; ?>
<html>
    
    <head>
        <title>Purchases Report</title>
        <!-- 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="span9" id="content">


                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Purchases Reports</div>
                                
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                   <div class="table-toolbar">
                                     
                                     
                                    <div class="datatable-dashv1-list custom-datatable-overright">
                                    <div id="toolbar">
                                        <select class="form-control">
                                                <option value="">Export Basic</option>
                                                <option value="all">Export All</option>
                                                <option value="selected">Export Selected</option>
                                            </select>
                                    </div>
                                    <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"}'>
                                    <?php
include '../includes/connection.php';
                                   // Create connection


$sql= mysqli_query($con,"SELECT id,quantity,unit_price,total_price,date_time,supplier,AddedBy,(select product_name from products where id=purchases.product_id)as name from purchases");
//$result = mysqli_query($con, $sql);
$n=0;
if (mysqli_num_rows($sql) > 0) {
    // output data of each row
    


                                   ?>
                                        <thead>
                                            <tr>
                                                <th  width="10%">ID</th>
                                                
                                                   
                                                   
                                                    <th >Product</th>
                                                    <th >Quantity</th>
                                                    <th >Unit Price</th>
                                                     <th >Total price</th>
                                                        <th >Date</th>
                                                        <th >Supplier</th>
                                                        <th >Added By</th>
                                                
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
              while($row = mysqli_fetch_assoc($sql)) {
                $n++;
                        
                    ?>
                                            <tr class="odd gradeX">
                                                <td><?php echo $n; ?></td>
                                                
                                                <td><?php echo $row['name']; ?></td>
                                                <td><?php echo $row['quantity']; ?></td>
                                                <td><?php echo number_format($row['unit_price']); ?>/=</td>
                                                <td><?php echo number_format($row['total_price']); ?>/=</td>
                                                <td><?php echo $row['date_time']; ?></td>
                                                <?php 
                                              $nn=  $row['supplier'];
                                                $supname1=mysqli_fetch_array(mysqli_query($con,"SELECT * from suppliers where supplier_id ='$nn'"));
                                                    $sname1=$supname1['name'];
                                                 ?>
                                                <td><?php echo $sname1; ?></td>
                                                <?php
                                                $uid=$row['AddedBy'];
                                                $user=mysqli_fetch_array(mysqli_query($con,"select * from users where id='$uid'"));
                                                ?>
                                                <td><?php echo $user['name']; ?></td>
                                                
                                                
                                                
                                            </tr>
               <?php                             
    }
} else {
    echo "0 results";
}

//mysqli_close($conn);
?>
                                            
                                        </tbody>
                                    </table>
                                </div>
                                </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="../assets/scripts.js"></script>
        <script src="../assets/DT_bootstrap.js"></script>
        <script>
        $(function() {
            
        });
        </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>
    </body>

</html>