<?php 
require_once("config/configDB.php"); 
//session_start();
require "userPermission.php";
require 'financial_year_calculation.php';
?>

<!DOCTYPE html>
<html>
<head>
    <?php 
        require 'meta.php';  
        require 'header.php'; 
    ?>
   <style>
   
   .container{
    margin: 0 auto;
}


.edit{
    width: 100%;
    height: 25px;
}
.editMode{
    /*border: 1px solid black;*/
 
}

.txtedit{
    display: none;
    width: 99%;
    height: 30px;
}

/* Table Layout */
table {
    border:3px solid lavender;
    border-radius:3px;
}

table tr:nth-child(1){
    background-color:dodgerblue;
}
table tr:nth-child(1) th{
    color:white;
    padding:10px 0px;
    letter-spacing: 1px;
}

/* Table rows and columns */
table td{
    padding:10px;
}
table tr:nth-child(even){
    background-color:lavender;
    color:black;
}
   
   </style>
</head>
<body>
    <?php require 'menu.php' ?>



<div class='container'>
              
            <table width='100%' border='0'>
                <tr>
                    <th width='10%'>S.no</th>
                    <th width='40%'>Product&nbsp;Name</th>
                    <th width='40%'>Product&nbsp;Name</th>
                    <th width='40%'>Old Rate</th>
                    <th width='40%'>New Rate</th>
                </tr>
            <?php 
                $query = "select * from product_master where isdelete='1' order by productname ";
                $result = mysqli_query($conn,$query);
                $count = 1;
                while($row = mysqli_fetch_array($result) ){
                    $id = $row['id'];
                    $username = $row['productname'];
					$product_tamil = $row['product_tamil'];
                    $name = $row['purchase_rate'];
					
					$sql_rate=mysqli_query($conn,"select purchase_rate from product_rate_update where productid='$id' ORDER BY id DESC LIMIT 1");
	
	//echo "select purchase_rate from product_rate_update where productid='$editid' ORDER BY id DESC LIMIT 1";
	
	$row_rate=mysqli_fetch_array($sql_rate,MYSQLI_ASSOC);
    
	$oldrate=$row_rate['purchase_rate']
            ?>
                    <tr>
                        <td><?php echo $count; ?></td>
                        <td> <div  id='username_<?php echo $id; ?>'> <?php echo $username; ?></div> </td>
                         <td> <div  ><?php echo $product_tamil; ?> </div> </td>
                        <td> <div  ><?php echo $oldrate; ?> </div> </td>
                        <td> <div contentEditable='true' class='edit' id='name_<?php echo $id; ?>'><?php echo $name; ?> </div> </td>
                    </tr>
            <?php
                    $count ++;
                }
            ?>  
            </table>
             
        </div>



    <?php require 'footer.php' ?>
    <script type="text/javascript">var base_url = "<?= $base_url ?>";</script>
    
    <script src='script.js' type='text/javascript'></script>
</body>
</html>