 <!-- 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;
        font-weight: bold;
    }
</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 style="font-weight: bold;" class="danger"> 
                     <td align="center">Item</td>
                              <td align="center">Item Description</td> 
                              <td align="center">Pattern</td>
                              <td align="center">Brand</td>
                              <td align="center">Note</td>
                              <td hidden align="center">Cat</td>
                              <!--
                              <td align="center">Avg.Cost</td>
                              <td align="center">Last Cost</td> -->
                              <td align="center">List Price</td> 
                              <td align="center">Cash Price</td> 
                              <td align="center">Credit Price</td> 
							  <td align="center">SAHAN</td> 
							  <td hidden align="center">BANDARAWELA</td> 
							  <td align="center">SAHAN NEW</td>  
                    </tr>
                </thead>


                <tbody>
                    
             <?php 
						 
						 
							$sql="select * from s_mas   ";
						foreach ($conn->query($sql) as $row) { 
                            $sql1 = "select * from s_submas   where STO_CODE='01' and STK_NO='".$row['STK_NO']."' ";   
                            $result1 = $conn->query($sql1); 
                            $row1 = $result1->fetch();
                            
                            $sql2 = "select * from s_submas   where STO_CODE='03' and STK_NO='".$row['STK_NO']."' ";   
                            $result2 = $conn->query($sql2); 
                            $row2 = $result2->fetch();
                            
                            $sql3 = "select * from s_submas   where STO_CODE='05' and STK_NO='".$row['STK_NO']."' ";   
                            $result3 = $conn->query($sql3); 
                            $row3 = $result3->fetch();
                             
                          
							echo "<tr style=\"font-weight: bold;\">               
                              <td align=\"center\" >".$row['STK_NO']."</a></td>
                              <td >".$row['DESCRIPT']."</a></td>
                              <td align=\"center\" >".$row['PART_NO']."</a></td>
							  <td align=\"center\" >".$row['BRAND_NAME']."</a></td>
							  <td align=\"center\" >".$row['GROUP1']."</a></td>
							  <td hidden align=\"center\" >".$row['Cat1']."</a></td>";
							  /* if ($_SESSION['User_Type'] == "1") {
                                    echo "<td align=\"center\" >".$row['acc_cost']."</a></td>
                                    <td align=\"center\" >".$row['COST_LAST']."</a></td>";
                              }else{
                                    echo "<td align=\"center\" ></a></td>
                                    <td align=\"center\" ></a></td>";
                              } */
							  echo "<td align=\"center\" >".$row['SELLING']."</a></td>   
							  <td align=\"center\" style='background-color:#e0b3db' >".$row['CA_SELLING']."</a></td>   
							  <td align=\"center\" style='background-color:#d495a7' >".$row['CR_SELLING']."</a></td>  
							  <td align=\"center\" style='background-color:#aaf6aa'>".$row1['QTYINHAND']."</a></td> 
							  <td hidden align=\"center\" >".$row2['QTYINHAND']."</a></td> 
							  <td align=\"center\" style='background-color:yellow'>".$row3['QTYINHAND']."</a></td>  
                            </tr>";
							}
							  ?>
       </tbody>
       <tfoot>
		<th>Item Code</th>
                              <th>Item Description</th>
                              <th>Pattern</th>
                              <th>Brand</th>
                              <th>Note</th>
                              <th hidden>Cat</th> 
                              <!-- <th>Avg.Cost</th>
                              <th>Last Cost</th> -->
                              <th>List Price</th> 
                              <th>Cash Price</th> 
                              <th>Credit Price</th> 
							  <th>BADULLA</th> 
							  <th hidden>BANDARAWELA</th> 
							  <th>BADULLA 2</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: [[  25, 50,100, -1 ],[  '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>
