<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$product = $_REQUEST["product"];


$gettran = mysqli_query($conn, "SELECT * FROM `finrelprod` WHERE `code`='$product' order by `srno`")or die(mysqli_error($conn));


echo "<table class='table-striped table-condensed table-bordered tab' width='100%'>";
echo "<thead  class='mySearchTr'>";
echo "<tr>";
echo "<th style='width: 2%'></th>";
echo "<th style='width: 3%'>Sr.</th>";
echo "<th style='width: 8%;'>Product Code</th> ";
echo "<th style='width: 15%;'>Name</th>";
echo "<th style='width: 6%'>Net Wt.</th>";
echo "<th style='width: 6%' class='text-right'>Approx. Pcs.</th>";
echo "<th style='width: 6%' class='text-right'>Consumption in Kg.</th>";
echo "<th style='width: 6%' class='text-right'>Actual pcs.</th>";
echo "<th style='width: 10%'>Approved By</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody class='tbody'>";
$ctr = 0;
while ($tran = mysqli_fetch_array($gettran)) {
    echo "<tr>";
    echo "<td align='center' valign='top'><span class='remove fa fa-times' name='remove' value='remove' $hide_var></span></td>";
    Echo "<td><input type='text' value='$tran[srno]'  name='srno_$ctr'  class='srno form-control form ' readonly></td>";
    Echo "<td>";
    Echo "<select class='form-control form prodcode' name='prodcode_$ctr' style='width:100%' >";
    Echo "<option value='$tran[prodcode]'>$tran[prodcode]</option>";
    Echo "</select>";
    Echo "</td>";
    Echo "<td><input type='text' class='form-control form  prodname'   name='prodname_$ctr'   value='$tran[prodname]' readonly></td>";
    Echo "<td><input type='text' class='form-control form  netwt'   name='netwt_$ctr'  step='any'   value='$tran[netwt]' readonly></td>";
    Echo "<td><input type='number' class='form-control form text-right approxpcs'   name='approxpcs_$ctr'  step='any'  value='0'></td>";
    Echo "<td><input type='number' class='form-control form text-right conskg'   name='conskg_$ctr'  step='any'   value='$tran[approxkg]'></td>";
    Echo "<td><input type='number' class='form-control form text-right actpcs'   name='actpcs_$ctr'  step='any'   value='0'></td>";
    Echo "<td>";
    Echo "<select class='form-control form approvby' name='approvby_$ctr' style='width:100%' >";
    Echo "<option value=''></option>";
    $stff = mysqli_query($conn, "SELECT accode,name FROM `accmast` where `grpcode`='040' order by name")or die(mysqli_error($conn));
    while ($mstff = mysqli_fetch_array($stff)) {
        Echo "<option value='$mstff[accode]'>$mstff[name]</option>";
    }
    Echo "</select>";
    Echo"</td>";
    Echo "</tr>";
    $ctr++;
}
echo "</tbody>";
Echo "<input type='hidden' class='form-control form items' id='items' name='items'   value='$ctr'></td>";
echo "</table>";
?>