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

    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    $mctr = $ctr;
    $mctr++;

    Echo "<tr>";
    Echo "<td><i class='fa fa-close remove' $hide_var ></i></td>";
    Echo "<td><input type='text' class='form-control form text-right srno' name='srno_$ctr' value='$mctr'></td>";
    Echo "<td>";
    echo "<input list='itemname' name='item_$ctr' class='itemname form-control form ' autocomplete='off' value='$fitem[name]'> ";
    echo "<datalist id='itemname' char='#'>";
    echo"<option>";

    $msize = mysqli_query($conn, "SELECT `name` FROM `item` group by name") or die(mysqli_error($conn));

    while ($tsize = mysqli_fetch_array($msize)) {
        $sizename = $tsize['name'];
        echo "<option value='$sizename'>";
    }
    echo "</datalist>";
    echo "</td>";
    Echo "<td><input type='text' class='form-control form unit'                name='unit_$ctr'       value='$tran[unit]'></td>";

    Echo "<td><input type='text' class='form-control form hsncode'                name='hsncode_$ctr'       value=''></td>";
    Echo "<td><input type='text' class='form-control form text-right pcs'                name='pcs_$ctr'       value='0'></td>";
    Echo "<td><input type='text' class='form-control form text-right qty'    name='qty_$ctr'     value='0'>"
    . "<input type='hidden' class='form-control form text-right stqty'    name='stqty_$ctr'     value='0'></td>";
    Echo "<td><input type='text' class='form-control form calby'                name='calby_$ctr'       value='P' maxlength='1'></td>";
    Echo "<td><input type='text' class='form-control form text-right rate'  id='rate_$ctr'   name='rate_$ctr'     value='0'></td>";
    Echo "<td><input type='text' class='form-control form text-right amount'   name='amount_$ctr'   value='0' readonly>
         <input type='hidden' class='form-control form text-right mspamount'   name='mspamount_$ctr'   value='0' readonly></td>";
    Echo "<td><input type='text' name='discperc_$ctr' class='discperc form-control text-right  form'  value='0' ></td>";
    Echo "<td><input type='text' name='discamt_$ctr' class='discamt form-control text-right  form' tabindex='-1' value='0' readonly></td>";
    Echo "<td><input type='text' name='subtot_$ctr' class='subtot form-control text-right  form' tabindex='-1' value='0' readonly></td>";
    Echo "<td><input type='text' name='gstperc_$ctr' class='gstperc form-control text-right  form' value='18'>
              <input type='hidden' name='cgstrate_$ctr' class='cgstrate form-control text-right  form' tabindex='-1' value='0' readonly>
              <input type='hidden' name='cgstamt_$ctr' class='cgstamt form-control text-right  form' tabindex='-1' value='0' readonly>
              <input type='hidden' name='sgstrate_$ctr' class='sgstrate form-control text-right  form' tabindex='-1' value='0' readonly>
              <input type='hidden' name='sgstamt_$ctr' class='sgstamt form-control text-right  form' tabindex='-1' value='0' readonly>
              <input type='hidden' name='igstrate_$ctr' class='igstrate form-control text-right  form' tabindex='-1' value='0' readonly>
              <input type='hidden' name='igstamt_$ctr' class='igstamt form-control text-right  form' tabindex='-1' value='0' readonly></td>";
    Echo "<td><input type='text' name='gstamt_$ctr' class='gstamt form-control text-right  form' tabindex='-1' value='0' readonly></td>";
    Echo "<td><input type='text' name='total_$ctr' class='total form-control text-right  form' tabindex='-1' value='0' readonly></td>";
    Echo "</tr >";
    $ctr++;
} else {
    echo "ERROR";
}
?> 