<?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"];

echo "<table class='table table-striped table-condensed table-bordered'  style='width: 100%'>";
echo "<thead>";
echo"<tr style='background-color: #6082BF;'>";
echo "<th width='3%'></th>";
echo "<th width='6%'>Sr</th>";
echo"<th width='25%'>Ingredients</th>";
echo"<th width='15%'>Unit</th>";
echo"<th width='8%'>Qty. %</th>";
echo"<th width='8%'>Qty. Per Batch in kg.</th>";
echo"<th width='8%'>Issued Qty.</th>";
echo"<th width='8%'>AR.No.</th>";
echo"<th width='8%'>ID.No.</th>";
echo"</tr>";
echo"</thead>";
echo"<tbody class='tbody3'>";
$ctr = 0;
$gettran = mysqli_query($conn, "SELECT * FROM `finprodraw` WHERE `code`='$product' order by `srno`")or die(mysqli_error($conn));
while ($tran = mysqli_fetch_array($gettran)) {
    $getraw = mysqli_query($conn, "SELECT code,name FROM `item` WHERE `code`='$tran[rawmat]' ")or die(mysqli_error($conn));
    $raw = mysqli_fetch_array($getraw);
    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 rawmat select2' name='rawmat_$ctr' style='width:100%' readonly>";
    Echo "<option value='$raw[code]'>$raw[name]</option>";
    Echo "</select>";
    Echo "</td>";
    Echo "<td>";
    Echo "<select class='form-control form unit select2' name='runit_$ctr' style='width:100%' readonly>";
    Echo "<option value='$tran[unit]'>$tran[unit]</option>";
    Echo "</select>";
    Echo "</td>";
    Echo "<td><input type='number' class='form-control form text-right qtyperc'   name='qtyperc_$ctr'  step='any'   value='$tran[qtyperc]' readonly></td>";
    Echo "<td><input type='number' class='form-control form text-right qtybatch'   name='qtybatch_$ctr'  step='any'   value='0' readonly></td>";
    Echo "<td><input type='number' class='form-control form text-right issuedqty'   name='issuedqty_$ctr'  step='any'   value='0'></td>";
    Echo "<td><input type='text' class='form-control form  arno'   name='arno_$ctr'  step='any'   value=''></td>";
    Echo "<td><input type='text' class='form-control form  idno'   name='idno_$ctr'  step='any'   value=''></td>";
    Echo "</tr>";
    $ctr++;
}
echo "</tbody>";
echo "<input type='hidden' class='form-control form items3' id='items3' name='items3' value='$ctr'>";
echo "</table>";
?>