<?php

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

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

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $prodtype = $_REQUEST["prodtype"];
    $godown = $_REQUEST["godown"];
    $hide_var = "";

    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    //    $mctr++;
    $ctr--;
    echo "<tr>";
    echo "<td><i class='fa fa-close remove' $hide_var ></i></td>";
    echo "<td><input type='text' name='srno_$ctr' class='srno form-control  form '  value='$mctr'></td>";
    echo "<td><input type='text' name='barcode_$ctr' class='barcode form-control focusFld_$ctr  form' value='' ></td>";

    echo "<td>";
    echo "<select name='itemcode_$ctr' class='form-control form itemcode select2 fetchpart_$ctr' style='width:100%'>";
    echo "<option value=''></option>";
    $mownitm = mysqli_query($conn, "SELECT `code`, `name` FROM `product` ORDER BY `name`") or die(mysqli_error($conn));
    while ($trowitm = mysqli_fetch_array($mownitm)) {
        echo "<option value='$trowitm[code]'>$trowitm[name]</option>";
    }
    echo "</td>";

    echo "<td><input type='text'    name='type_$ctr' class='type form-control form' value=''></td>";
    echo "<td><input type='text'    name='batch_$ctr' class='batch form-control form' value=''></td>";
    echo "<td><input type='number'  name='bbfmon_$ctr' class='bbfmon form-control form' value=''></td>";
    echo "<td><input type='number'  name='bbfyear_$ctr' class='bbfyear form-control form' value=''></td>";
    echo "<td><input type='number'  step='any' name='qty_$ctr' class='qty form-control  text-right form' value='0'></td>";
    echo "<td><input type='text'  step='any' name='weight_$ctr' class='weight form-control form text-right' value=''></td>";
//    echo "<td><input type='text'    name='unit_$ctr' class='unit form-control form' value=''></td>";
    echo "</tr>";
    $ctr++;
} else {
    echo "ERROR";
}
?>