 <!-- Main content -->
   <link rel="stylesheet" href="css/bootstrap.min.css">

<style type="text/css">
		tfoot input {
			width: 100%;
			padding: 3px;
			box-sizing: border-box;
		}
	</style>
   
    <link rel="stylesheet" href="css/bootstrap.min.css"> 
    <!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">-->
 
    <link  href="vendor/new/multi/jquery.dataTables.min.css" rel="stylesheet" type="text/css"> 
	<script src="vendor/new/multi/jquery-3.5.1.js" ></script>
	<script src="vendor/new/multi/jquery.dataTables.min.js" ></script>
<?php
require_once("./connection_sql.php");
?>

<style>

    .view-cell{
        background-color: red;
        color: white; 
    }
    .table-hover tbody tr:hover td {
        background: aqua;
    }
</style>

<section class="content" onload="search1();">

    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">LIVE STOCK</h3>
        </div>
        <form role="form" class="form-horizontal">
            <div class="box-body"> 
                <div class="panel-body" style="overflow-x: auto">
                     
                <table width="100%" class="table  table-bordered table-hover" id="example" style="width:auto">
                    <thead> 

                     <tr class="danger"> 
                     <td align="center">Item Code</td>
                              <td align="center">Item Description</td> 
                              <td align="center">Brand</td>
                              <td align="center">Cost</td>
                              <td align="center">Display Cost</td>
                              <td align="center">Display Price</td>
                              <td align="center">Selling Price</td>
							  <td align="center">All Qty</td> 
							  <td align="center">Dep Qty</td> 
                    </tr>
                </thead>


                <tbody>
                    
             <?php 
						 
							 
							$sql="select * from s_mas   ";
						foreach ($conn->query($sql) as $row) {
						     if($_SESSION["CURRENT_DEP"]  ==""){
                                $sql2 = "select * from s_submas where STK_NO='".$row['STK_NO']."' order by QTYINHAND desc";
                            }else{
                                $sql2 = "select * from s_submas   where STO_CODE='".$_SESSION["CURRENT_DEP"] ."'  and STK_NO='".$row['STK_NO']."' order by QTYINHAND desc";    
                            }   
                            $result2 = $conn->query($sql2); 
                            $row2 = $result2->fetch();
					
							echo "<tr>               
                              <td align=\"center\" >".$row['STK_NO']."</a></td>
                              <td >".$row['DESCRIPT']."</a></td>  
							  <td align=\"center\" >".$row['BRAND_NAME']."</a></td>
							  <td align=\"center\" >".$row['COST']."</a></td> 
							  <td align=\"center\" >".$row['DISPLAY_COST']."</a></td> 
							  <td align=\"center\" >".$row['AR_selling']."</a></td> 
							  <td align=\"center\" >".$row['SELLING']."</a></td> 
							  <td align=\"center\" >".$row['QTYINHAND']."</a></td> 
							  <td align=\"center\" >".$row2['QTYINHAND']."</a></td> 
                            </tr>";
							}
							  ?>
       </tbody>
       <tfoot>
		<th>Item Code</th>
                              <th>Item Description</th>
                              <th>PR Rating</th> 
                              <th>Brand</th>
                              <th>Cost</th>
                              <th>Display Cost</th>
                              <th>Selling</th>
							  <th>All Qty</th> 
							  <th>Dp Qty</th> 
		</tfoot>
        </table>

    </div>

    <!-- =============================== -->

 

<!-- =============================== -->



</div>
</form>
</div>
</section>

 <script type="text/javascript">
	$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
    	var title = $(this).text();
    	$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );

    // DataTable
    var table = $('#example').DataTable({
    	
    	lengthChange: true,
    	fixedHeader: true,
    	responsive: true,
    	"deferRender": true,
    	"order": [[ 6, 'desc' ]],
    	lengthMenu: [[ 15, 25, 50,100, -1 ],[ '15 rows', '25 rows', '50 rows', '100 rows', 'Show all' ]],
    	initComplete: function () {
            // Apply the search
            this.api().columns().every( function () {
            	var that = this;

            	$( 'input', this.footer() ).on( 'keyup change clear', function () {
            		if ( that.search() !== this.value ) {
            			that
            			.search( this.value )
            			.draw();
            		}
            	} );
            } );
        }
    });

} );
</script>
