<!DOCTYPE html>
<?php include '../includes/connection.php';
include("../includes/header-links.php");
 ?>
<html>
    
    <head>
       
        <!-- 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">Damages Reports</div>
                                
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                
                                    
                                    <div class="datatable-dashv1-list custom-datatable-overright">
                                         <div class="span12">
                                            
                                    <div class="span4">
                                        <label>Date from</label>
                                        <input type="date" name="datefrom" id="dfrom" onchange="filterData(this.value)">
                                    </div>
                                    <div class="span4">
                                        <label>Date To</label>
                                        <input type="date" name="dateto" id="dto" onchange="filterdate2(this.value)" disabled>
                                    </div>
                                            
                                           
                                        </div>
 <script type="text/javascript">
     function filterData(val){
        var text=document.getElementById("dfrom").value;
        document.getElementById("dto").disabled=false;
        document.getElementById("test").innerHTML=text;
var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("filtered").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "returns_filter.php?from="+val, true);
  xhttp.send();

     }

     function filterdate2(vall){
        var from=document.getElementById("dfrom").value;
        var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("filtered").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "returns_filter2.php?from="+from+"&to="+vall, true);
  xhttp.send();
     }
 </script>                                       
                                        <div id="test">&nbsp</div>
<hr>
                                    <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="false" data-search="true" data-show-columns="false" data-show-pagination-switch="false" data-show-refresh="true" data-key-events="true" data-show-toggle="false" 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,price,Reason,date,(select product_name from products where id=returns_out.product_id)as name from returns_out");
//$result = mysqli_query($con, $sql);


                                   ?>
                                        <thead>
                                            <tr>
                                                <th  width="10%">S/NO</th>
                                                
                                                   
                                                   
                                                    <th >Product</th>
                                                    <th >Quantity</th>
                                                    <th >Unit Price</th>
                                                     <th >Date</th>
                                                        <th >Reason</th>
                                                
                                            </tr>
                                        </thead>
                                        <tbody id="filtered">
                                        <?php
        if (mysqli_num_rows($sql) > 0) {
    // output data of each row
                                        $n=0;
              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 $row['price']; ?></td>
                                                <td><?php echo $row['date']; ?></td>
                                                <td><?php echo $row['Reason']; ?></td>
                                                
                                                
                                                
                                            </tr>
               <?php                             
    }
} else {
    echo "<td>No results</td><td></td><td></td><td></td><td></td><td></td>";
}

//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="../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>